Skip to content

Commit 9196fe9

Browse files
committed
Fix lint
1 parent a8d7c0c commit 9196fe9

3 files changed

Lines changed: 36 additions & 17 deletions

File tree

src/config/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
import os
33
import re
44
import sys
5+
import tomllib
56
from datetime import timedelta
67
from socket import gethostbyname, gethostname
8+
79
import environ
810
import sentry_sdk
911
from django.utils.translation import gettext_lazy as _
1012
from django_prose_editor.config import html_tags
1113
from sentry_sdk.integrations.django import DjangoIntegration
12-
import tomllib
1314

1415
ROOT_DIR = environ.Path(__file__) - 3 # three folders back (/jandig/src/config)
1516
BASE_DIR = ROOT_DIR.path("src")

src/core/models.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ def augmenteds_count(self):
9494
def exhibits_count(self):
9595
return self.exhibits.count()
9696

97-
98-
9997
def used_in_html_string(self):
10098
used_in = "{} {} {} {} {} {} {}".format(
10199
USED_IN,
@@ -606,23 +604,35 @@ def artwork_post_save(sender, instance, **kwargs):
606604
old_marker_id = getattr(instance, "_old_marker_id", None)
607605
if old_marker_id and old_marker_id != instance.marker_id:
608606
if not Artwork.objects.filter(marker_id=old_marker_id).exists():
609-
Marker.objects.filter(pk=old_marker_id).update(in_use=False, is_used_by_other_user=False)
607+
Marker.objects.filter(pk=old_marker_id).update(
608+
in_use=False, is_used_by_other_user=False
609+
)
610610
else:
611611
old_marker = Marker.objects.get(pk=old_marker_id)
612-
still_used_by_other = old_marker.artworks.exclude(author=old_marker.owner).exists()
612+
still_used_by_other = old_marker.artworks.exclude(
613+
author=old_marker.owner
614+
).exists()
613615
if not still_used_by_other:
614-
Marker.objects.filter(pk=old_marker_id).update(is_used_by_other_user=False)
616+
Marker.objects.filter(pk=old_marker_id).update(
617+
is_used_by_other_user=False
618+
)
615619

616620
# If object changed, check if the old one is still in use
617621
old_augmented_id = getattr(instance, "_old_augmented_id", None)
618622
if old_augmented_id and old_augmented_id != instance.augmented_id:
619623
if not Artwork.objects.filter(augmented_id=old_augmented_id).exists():
620-
Object.objects.filter(pk=old_augmented_id).update(in_use=False, is_used_by_other_user=False)
624+
Object.objects.filter(pk=old_augmented_id).update(
625+
in_use=False, is_used_by_other_user=False
626+
)
621627
else:
622628
old_object = Object.objects.get(pk=old_augmented_id)
623-
still_used_by_other = old_object.artworks.exclude(author=old_object.owner).exists()
629+
still_used_by_other = old_object.artworks.exclude(
630+
author=old_object.owner
631+
).exists()
624632
if not still_used_by_other:
625-
Object.objects.filter(pk=old_augmented_id).update(is_used_by_other_user=False)
633+
Object.objects.filter(pk=old_augmented_id).update(
634+
is_used_by_other_user=False
635+
)
626636

627637
# If sound changed, check if the old one is still in use
628638
old_sound_id = getattr(instance, "_old_sound_id", None)
@@ -634,14 +644,18 @@ def artwork_post_save(sender, instance, **kwargs):
634644
def artwork_post_delete(sender, instance, **kwargs):
635645
"""When an artwork is deleted, check if its marker/object/sound are still in use."""
636646
if not Artwork.objects.filter(marker_id=instance.marker_id).exists():
637-
Marker.objects.filter(pk=instance.marker_id).update(in_use=False, is_used_by_other_user=False)
647+
Marker.objects.filter(pk=instance.marker_id).update(
648+
in_use=False, is_used_by_other_user=False
649+
)
638650
else:
639651
marker = Marker.objects.get(pk=instance.marker_id)
640652
if not marker.artworks.exclude(author=marker.owner).exists():
641653
Marker.objects.filter(pk=marker.pk).update(is_used_by_other_user=False)
642654

643655
if not Artwork.objects.filter(augmented_id=instance.augmented_id).exists():
644-
Object.objects.filter(pk=instance.augmented_id).update(in_use=False, is_used_by_other_user=False)
656+
Object.objects.filter(pk=instance.augmented_id).update(
657+
in_use=False, is_used_by_other_user=False
658+
)
645659
else:
646660
obj = Object.objects.get(pk=instance.augmented_id)
647661
if not obj.artworks.exclude(author=obj.owner).exists():
@@ -659,9 +673,7 @@ def _recalculate_sound_flags(sound_id):
659673
return
660674

661675
is_in_use = (
662-
sound.artworks.exists()
663-
or sound.ar_objects.exists()
664-
or sound.exhibits.exists()
676+
sound.artworks.exists() or sound.ar_objects.exists() or sound.exhibits.exists()
665677
)
666678
used_by_other = (
667679
sound.artworks.exclude(author=sound.owner).exists()

src/core/views/views.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ def marker_preview(request):
281281
1,
282282
attributes={
283283
"marker_id": marker.id,
284-
"user": request.user.username if request.user.is_authenticated else "anonymous",
284+
"user": request.user.username
285+
if request.user.is_authenticated
286+
else "anonymous",
285287
},
286288
)
287289
artwork = {
@@ -529,7 +531,9 @@ def artwork_preview(request):
529531
1,
530532
attributes={
531533
"artwork_id": artwork_id,
532-
"user": request.user.username if request.user.is_authenticated else "anonymous",
534+
"user": request.user.username
535+
if request.user.is_authenticated
536+
else "anonymous",
533537
},
534538
)
535539

@@ -786,7 +790,9 @@ def exhibit(request, slug):
786790
1,
787791
attributes={
788792
"exhibit_id": exhibit.id,
789-
"user": request.user.username if request.user.is_authenticated else "anonymous",
793+
"user": request.user.username
794+
if request.user.is_authenticated
795+
else "anonymous",
790796
"slug": slug,
791797
},
792798
)

0 commit comments

Comments
 (0)