diff --git a/backend/clubs/management/commands/expire_membership_invites.py b/backend/clubs/management/commands/expire_membership_invites.py index ba76164a7..7ffbae994 100644 --- a/backend/clubs/management/commands/expire_membership_invites.py +++ b/backend/clubs/management/commands/expire_membership_invites.py @@ -1,3 +1,5 @@ +import traceback + from django.core.management.base import BaseCommand from django.utils import timezone @@ -17,10 +19,10 @@ def handle(self, *args, **kwargs): self.stdout.write( self.style.SUCCESS("Successfully marked all stale invites as expired!") ) - except Exception as e: + except Exception: self.stdout.write( self.style.ERROR( "An error was encountered while expiring stale membership invites!" ) ) - self.stdout.write(e) + self.stdout.write(self.style.ERROR(traceback.format_exc())) diff --git a/backend/clubs/management/commands/find_broken_images.py b/backend/clubs/management/commands/find_broken_images.py index 8c2397049..03c01e330 100644 --- a/backend/clubs/management/commands/find_broken_images.py +++ b/backend/clubs/management/commands/find_broken_images.py @@ -1,4 +1,5 @@ import os +import traceback import requests from django.conf import settings @@ -41,6 +42,7 @@ def handle(self, *args, **kwargs): "{} has broken image {}".format(club.code, club.image.url) ) ) + self.stdout.write(self.style.ERROR(traceback.format_exc())) if not self.dry_run: club.image.delete(save=True) broken_list.append( diff --git a/backend/clubs/management/commands/update_club_counts.py b/backend/clubs/management/commands/update_club_counts.py index 01ff17676..69640747b 100644 --- a/backend/clubs/management/commands/update_club_counts.py +++ b/backend/clubs/management/commands/update_club_counts.py @@ -1,3 +1,5 @@ +import traceback + from django.core.management.base import BaseCommand from django.db.models import Count, Q @@ -26,11 +28,10 @@ def handle(self, *args, **kwargs): "Successfully updated all club favorite and membership counts!" ) ) - except Exception as e: + except Exception: self.stdout.write( self.style.ERROR( - "An error was encountered while updating" - + "club favorite and membership counts!" + "Error while updating club favorite & membership counts!" ) ) - self.stdout.write(e) + self.stdout.write(self.style.ERROR(traceback.format_exc())) diff --git a/backend/clubs/models.py b/backend/clubs/models.py index 257848ac7..238984a2d 100644 --- a/backend/clubs/models.py +++ b/backend/clubs/models.py @@ -956,10 +956,6 @@ def create_thumbnail(self, request=None): def __str__(self): return self.name - @property - def tickets_count(self): - return Ticket.objects.count(event=self) - class Favorite(models.Model): """ diff --git a/backend/clubs/serializers.py b/backend/clubs/serializers.py index 04d1d70ab..496b7566b 100644 --- a/backend/clubs/serializers.py +++ b/backend/clubs/serializers.py @@ -2338,6 +2338,8 @@ def get_xlsx_column_name(key): label = json.loads(fair.questions)[index]["label"] return f"[{fair.name}] {label}" return f"Registered for {fair.name}" + else: + return key class Meta(AuthenticatedClubSerializer.Meta): pass diff --git a/backend/tests/clubs/test_views.py b/backend/tests/clubs/test_views.py index 6ddc03be0..0750c611b 100644 --- a/backend/tests/clubs/test_views.py +++ b/backend/tests/clubs/test_views.py @@ -1688,14 +1688,12 @@ def test_send_invite_with_acceptance_email(self): expiry_date = now + timezone.timedelta(days=5) # Compare the expiry dates excluding microseconds - self.assertEqual( - invite1.expires_at.replace(microsecond=0), - expiry_date.replace(microsecond=0), + self.assertLessEqual( + abs(invite1.expires_at - expiry_date), timezone.timedelta(minutes=5) ) - self.assertEqual( - invite2.expires_at.replace(microsecond=0), - expiry_date.replace(microsecond=0), + self.assertLessEqual( + abs(invite2.expires_at - expiry_date), timezone.timedelta(minutes=5) ) # Check that applicants not accepted are not invited