Skip to content

Commit

Permalink
fix: Show catalogue after CR (#1287)
Browse files Browse the repository at this point in the history
## Describe your changes

Fixes: #
  • Loading branch information
didrikmunther authored Nov 9, 2024
1 parent 5b2eac2 commit 6909dc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion apps/dashboard/src/screens/dashboard/screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ export function DashboardScreen({
title: "You have completed initial registration"
},
{
when: ["complete_registration:::*:::*"],
when: [
"*:::signed_cr:::*",
"complete_registration:::*:::*"
],
title: "Final registration",
badgeText: `${DateTime.fromISO(
dates.fr.start
Expand Down
5 changes: 4 additions & 1 deletion dashboard/api/registration/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ def submit_cr(request, company, fair, contact, exhibitor):
)

handle_submitted_order(fair, company)
send_cr_confirmation_email(request, fair, company, exhibitor, signature)
try:
send_cr_confirmation_email(request, fair, company, exhibitor, signature)
except Exception as e:
print("Failed to send email", e)

try:
registration = get_registration(company, fair, contact, exhibitor)
Expand Down
12 changes: 9 additions & 3 deletions fair/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class Fair(models.Model):
def get_period(self):
time = timezone.now()

fair_days = FairDay.objects.filter(fair=self).values_list("date", flat=True)
if not fair_days:
raise ValueError("No fair days found for fair %s" % self)

if time < self.registration_start_date:
return RegistrationPeriod.BEFORE_IR
elif time >= self.registration_start_date and time < self.registration_end_date:
Expand All @@ -116,13 +120,15 @@ def get_period(self):
return RegistrationPeriod.CR
elif (
time >= self.complete_registration_close_date
and time < self.events_start_date
and min(fair_days) > time.date()
):
return RegistrationPeriod.AFTER_CR
elif time >= self.events_start_date and time < self.events_end_date:
elif min(fair_days) <= time.date() <= max(fair_days):
return RegistrationPeriod.FAIR
elif time >= self.events_end_date:
elif time.date() > max(fair_days):
return RegistrationPeriod.AFTER_FAIR
else:
raise ValueError("No period found for time %s" % time)

def is_member_of_fair(self, user):
if user.is_superuser:
Expand Down

0 comments on commit 6909dc1

Please sign in to comment.