Skip to content

Commit

Permalink
[AJP-2]
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Grund authored and Anna Grund committed Sep 27, 2023
1 parent b8753de commit 32c447c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 94 deletions.
2 changes: 1 addition & 1 deletion ajapaik/ajapaik/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,4 @@ class ApiWikidocsAlbumSearchForm(forms.Form):

class CsvImportForm(forms.Form):
zip_file = forms.FileField(required=False)
csv_file = forms.FileField()
csv_file = forms.FileField()
1 change: 0 additions & 1 deletion ajapaik/ajapaik/static/css/ajp-geotagger-plugin.css
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@
border-radius: 0;
}


#ajp-geotagging-container div.gm-style-mtc > div:nth-of-type(2) {
bottom: auto;
}
41 changes: 11 additions & 30 deletions ajapaik/ajapaik/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
from ajapaik.utils import get_etag, calculate_thumbnail_size, convert_to_degrees, calculate_thumbnail_size_max_height, \
distance_in_meters, angle_diff, last_modified, suggest_photo_edit
from .fotis_utils import parse_fotis_timestamp_data
from .utils import get_comment_replies, get_pagination_parameters, ImportBlacklistService
from .utils import get_comment_replies, get_pagination_parameters

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -1531,10 +1531,10 @@ def photoslug(request, photo_id=None, pseudo_slug=None):
next_similar_photo = next_photo
compare_photos_url = request.build_absolute_uri(
reverse('compare-photos', args=(photo_obj.id, next_similar_photo.id)))
image_similarities = ImageSimilarity.objects.filter(from_photo_id=photo_obj.id).exclude(similarity_type=0)
if image_similarities.exists():
imageSimilarities = ImageSimilarity.objects.filter(from_photo_id=photo_obj.id).exclude(similarity_type=0)
if imageSimilarities.exists():
compare_photos_url = request.build_absolute_uri(
reverse('compare-photos', args=(photo_obj.id, image_similarities.first().to_photo_id)))
reverse('compare-photos', args=(photo_obj.id, imageSimilarities.first().to_photo_id)))

people = [x.name for x in photo_obj.people]
similar_photos = ImageSimilarity.objects.filter(from_photo=photo_obj.id).exclude(similarity_type=0)
Expand Down Expand Up @@ -2336,22 +2336,11 @@ def curator_photo_upload_handler(request):
# 15 => unknown copyright
unknown_licence = Licence.objects.get(pk=15)
flickr_licence = Licence.objects.filter(url='https://www.flickr.com/commons/usage/').first()
import_blacklist_service = ImportBlacklistService()

for k, v in selection.items():
upload_form = CuratorPhotoUploadForm(v)
created_album_photo_links = []
awarded_curator_points = []
if upload_form.is_valid():
source_key = upload_form.cleaned_data['identifyingNumber']

if source_key and import_blacklist_service.is_blacklisted(source_key):
context['photos'][k] = {
'error': _(
f'Could not import picture, as it is blacklisted from being imported: {upload_form.cleaned_data["imageUrl"]}')}
context['photos'][k]['success'] = False
continue

if not upload_form.cleaned_data['institution']:
licence = unknown_licence
source = Source.objects.get(name='AJP')
Expand Down Expand Up @@ -2389,7 +2378,7 @@ def curator_photo_upload_handler(request):
existing_photo = None
if upload_form.cleaned_data['id'] and upload_form.cleaned_data['id'] != '':
if upload_form.cleaned_data['collections'] == 'DIGAR':
incoming_muis_id = source_key
incoming_muis_id = upload_form.cleaned_data['identifyingNumber']
else:
incoming_muis_id = upload_form.cleaned_data['id']
if 'ETERA' in upload_form.cleaned_data['institution']:
Expand All @@ -2403,7 +2392,7 @@ def curator_photo_upload_handler(request):
muis_id = incoming_muis_id
muis_media_id = None
if upload_form.cleaned_data['collections'] == 'DIGAR':
source_key = \
upload_form.cleaned_data['identifyingNumber'] = \
f'nlib-digar:{upload_form.cleaned_data["identifyingNumber"]}'
muis_media_id = 1
try:
Expand Down Expand Up @@ -2616,8 +2605,9 @@ def curator_photo_upload_handler(request):
ap.delete()
for cp in awarded_curator_points:
cp.delete()
context['photos'][k] = {'error': _('Error uploading file: %s (%s)' %
(e, upload_form.cleaned_data['imageUrl']))}
context['photos'][k] = {}
context['photos'][k]['error'] = _('Error uploading file: %s (%s)' %
(e, upload_form.cleaned_data['imageUrl']))
else:
if general_albums.exists():
for a in general_albums:
Expand Down Expand Up @@ -2755,7 +2745,6 @@ def csv_import(request):
not_found_list = []
profile = request.get_user().profile
skipped_list = []
blacklisted_list = []
success = None
unique_album_list = []
upload_folder = f'{settings.MEDIA_ROOT}/uploads/'
Expand Down Expand Up @@ -2845,11 +2834,6 @@ def del_evenReadonly(action, name, exc):
source = Source.objects.filter(id=row['source']).first()
if 'source_key' in row.keys():
source_key = row['source_key']

if source_key and import_blacklist_service.is_blacklisted(source_key):
blacklisted_list.append(row['file'])
continue

if 'source_url' in row.keys():
source_url = row['source_url']
if 'date_text' in row.keys():
Expand Down Expand Up @@ -2886,7 +2870,7 @@ def del_evenReadonly(action, name, exc):
lon=lon,
geography=geography,
source=source,
source_key=source_key,
source_key=upload_form.cleaned_data['identifyingNumber'],
source_url=source_url,
date_text=date_text,
licence=licence,
Expand Down Expand Up @@ -3002,9 +2986,6 @@ def del_evenReadonly(action, name, exc):
if len(skipped_list) > 0:
already_exists_error = "Some imports were skipped since they already exist on Ajapaik:"
errors.append({'message': already_exists_error, 'list': list(set(skipped_list))})
if len(blacklisted_list) > 0:
blacklisted_error = "Some images are blacklisted from Ajapaik, they were not added"
errors.append({'message': blacklisted_error, 'list': list(set(blacklisted_list))})
if len(errors) < 1:
success = 'OK'

Expand Down Expand Up @@ -3911,4 +3892,4 @@ class MyConnectionsView(LoginRequiredMixin, ConnectionsView):


class MyEmailView(LoginRequiredMixin, EmailView):
success_url = reverse_lazy('user_settings')
success_url = reverse_lazy('user_settings')
62 changes: 0 additions & 62 deletions ajapaik/ajapaik_object_categorization/api.py

This file was deleted.

Binary file removed ajapaik/settings/.DS_Store
Binary file not shown.

0 comments on commit 32c447c

Please sign in to comment.