Skip to content

Commit

Permalink
Included focal length in the searh fields of the batch model
Browse files Browse the repository at this point in the history
  • Loading branch information
frasanz committed Oct 16, 2024
1 parent 2e08292 commit 5d2e0f8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
9 changes: 8 additions & 1 deletion georeferencing/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,21 @@ def fetch_api_data(self, request):
Raises:
requests.RequestException: If there is an issue with the HTTP request.
"""
print(request.GET)
feat_value = request.GET.get('feat', '')
mission = request.GET.get('mission', '')
fcltle = request.GET.get('fcltle', '')
fcltge = request.GET.get('fcltge', '')
url = 'https://eol.jsc.nasa.gov/SearchPhotos/PhotosDatabaseAPI/PhotosDatabaseAPI.pl'
query = 'query=images|directory|like|*large*'
if feat_value:
query = f'{query}|frames|feat|like|*{feat_value}*'
elif mission:
if mission:
query = f'{query}|frames|mission|like|*{mission}'
if fcltle:
query = f'{query}|frames|fclt|le|{fcltle}'
if fcltge:
query = f'{query}|frames|fclt|ge|{fcltge}'
key = config('NASA_API_KEY')
url_request = (
f'{url}?{query}&return=frames|frame|frames|geon|frames|feat|frames|roll|'
Expand Down
23 changes: 23 additions & 0 deletions georeferencing/migrations/0031_batch_fcltge_batch_fcltlt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.16 on 2024-10-16 22:05

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('georeferencing', '0030_geoattempt_assigneduser'),
]

operations = [
migrations.AddField(
model_name='batch',
name='fcltge',
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='batch',
name='fcltlt',
field=models.IntegerField(blank=True, null=True),
),
]
18 changes: 18 additions & 0 deletions georeferencing/migrations/0032_rename_fcltlt_batch_fcltle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2024-10-16 22:06

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('georeferencing', '0031_batch_fcltge_batch_fcltlt'),
]

operations = [
migrations.RenameField(
model_name='batch',
old_name='fcltlt',
new_name='fcltle',
),
]
3 changes: 2 additions & 1 deletion georeferencing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class Batch(models.Model):
# Search fields
feat = models.CharField(max_length=100, blank = True, null = True)
mission = models.CharField(max_length=100, blank = True, null = True)

fcltle = models.IntegerField(blank = True, null = True, verbose_name="Focal length <=")
fcltge = models.IntegerField(blank = True, null = True, verbose_name="Focal length >=")
user = models.ForeignKey(User, on_delete=models.CASCADE)
result = models.JSONField(default=dict, blank=True, null=True)
numberImages = models.IntegerField(default=0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
$('#fetch-data-btn').on('click', function () {
var featValue = $('input[name="feat"]').val();
var mission = $('input[name="mission"]').val();
var requestUrl = '{{ fetch_api_url }}?feat=' + featValue + '&mission=' + mission;
var fcltle = $('input[name="fcltle"]').val();
var fcltge = $('input[name="fcltge"]').val();
var requestUrl = '{{ fetch_api_url }}?feat=' + featValue + '&mission=' + mission + '&fcltle=' + fcltle + '&fcltge=' + fcltge;
$.ajax({
url: requestUrl,
method: 'GET',
Expand Down

0 comments on commit 5d2e0f8

Please sign in to comment.