dnscms: improve venue selection for event occurrences
This commit is contained in:
+10
-1
@@ -478,7 +478,7 @@ class EventOccurrence(Orderable):
|
||||
),
|
||||
FieldRowPanel(
|
||||
children=[
|
||||
FieldPanel("venue", heading=_("Venue")),
|
||||
FieldPanel("venue", heading=_("Venue"), widget=forms.Select),
|
||||
FieldPanel("venue_custom", heading=_("Venue as free text")),
|
||||
],
|
||||
),
|
||||
@@ -492,6 +492,15 @@ class EventOccurrence(Orderable):
|
||||
]
|
||||
|
||||
def clean(self):
|
||||
if self.venue_custom:
|
||||
trimmed = self.venue_custom.strip()
|
||||
self.venue_custom = trimmed
|
||||
if trimmed:
|
||||
match = VenuePage.objects.filter(title=trimmed).first()
|
||||
if match:
|
||||
self.venue = match
|
||||
self.venue_custom = ""
|
||||
|
||||
if self.venue and self.venue_custom:
|
||||
raise ValidationError(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user