Skip to content
Snippets Groups Projects
Commit d0c2e336 authored by Roang's avatar Roang
Browse files

Merge branch 'fix/voucher' into 'develop'

Fix leftover channel targets in voucher model

See merge request hub/hub!1067
parents 15a87853 01f286ad
Branches
Tags prod-2024-12-05_00-48
No related merge requests found
...@@ -124,7 +124,7 @@ class Voucher(models.Model): ...@@ -124,7 +124,7 @@ class Voucher(models.Model):
def do_auto_assignments(cls, conference: Conference = None, assemblies: list[Assembly] | None = None) -> int: def do_auto_assignments(cls, conference: Conference = None, assemblies: list[Assembly] | None = None) -> int:
qs = cls.objects.filter(conference=conference) if conference is not None else cls.objects.all() qs = cls.objects.filter(conference=conference) if conference is not None else cls.objects.all()
qs = qs.filter(enabled=True) qs = qs.filter(enabled=True)
qs = qs.filter(target__in=Voucher.ASSEMBLY_TARGETS) qs = qs.filter(target=Voucher.Target.ASSEMBLY)
total = 0 total = 0
for voucher in qs.iterator(): for voucher in qs.iterator():
...@@ -137,7 +137,7 @@ class Voucher(models.Model): ...@@ -137,7 +137,7 @@ class Voucher(models.Model):
return total return total
def do_auto_assignment(self, assemblies: list[Assembly]) -> int: def do_auto_assignment(self, assemblies: list[Assembly]) -> int:
if self.target not in self.ASSEMBLY_TARGETS: if self.target != self.Target.ASSEMBLY:
raise NotImplementedError('Auto-Assignment of non assemblies not implemented yet.') raise NotImplementedError('Auto-Assignment of non assemblies not implemented yet.')
# nothing to do if we're not enabled or set to manual assignment # nothing to do if we're not enabled or set to manual assignment
...@@ -199,7 +199,7 @@ class VoucherEntry(models.Model): ...@@ -199,7 +199,7 @@ class VoucherEntry(models.Model):
@cached_property @cached_property
def target(self): def target(self):
if self.voucher.target in Voucher.ASSEMBLY_TARGETS: if self.voucher.target == Voucher.Target.ASSEMBLY:
return self.assigned_assembly return self.assigned_assembly
if self.voucher.target == Voucher.Target.USER: if self.voucher.target == Voucher.Target.USER:
...@@ -218,7 +218,7 @@ class VoucherEntry(models.Model): ...@@ -218,7 +218,7 @@ class VoucherEntry(models.Model):
else: else:
# assembly assigned without a timestamp? # assembly assigned without a timestamp?
if self.voucher.target in Voucher.ASSEMBLY_TARGETS and self.assigned_assembly is not None: if self.voucher.target == Voucher.Target.ASSEMBLY and self.assigned_assembly is not None:
self.assigned = timezone.now() self.assigned = timezone.now()
else: else:
self.assigned_assembly = None self.assigned_assembly = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment