Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/temp' into temp
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Dec 2, 2023
2 parents 32f97fa + bbfd1ea commit 2ef08e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Meta:
model = Team
fields = ("name",)


class TeamJoinForm(forms.Form):
code = forms.CharField(
label=_l("join code"),
Expand Down
17 changes: 8 additions & 9 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Hunt(models.Model):
"e.g. {{this form}}, users will only see 'this form' but can click it to get to the form specified above",
max_length=250,
)

def __str__(self):
return self.name

Expand All @@ -218,21 +218,21 @@ def current_hunt(cls):
return cls.objects.get(start__lt=timezone.now(), end__gt=timezone.now())
except cls.DoesNotExist:
return None

def clean(self):
"""
Due to how this was designed, it is not possible to have multiple hunts running at the same time.
This method prevents that from happening.
"""
overlapping_events = self.objects.filter(
start_date__lte=self.start,
end_date__gte=self.end
start_date__lte=self.start, end_date__gte=self.end
).exclude(pk=self.pk)

if overlapping_events.exists():
raise ValidationError('This event overlaps with existing events. Please choose a different time. Or Delete the other event.')


raise ValidationError(
"This event overlaps with existing events. Please choose a different time. Or Delete the other event."
)

class Meta:
constraints = [
models.CheckConstraint(
Expand All @@ -251,7 +251,6 @@ class Meta:
name="form_in_ending_text",
),
# Ensure there isn't a different hunt running in that timespan

]


Expand Down

0 comments on commit 2ef08e3

Please sign in to comment.