Allow to delete organizers

This commit is contained in:
Raphael Michel
2018-11-05 10:55:06 +01:00
parent 87f3318431
commit 0a5347c08b
8 changed files with 143 additions and 9 deletions

View File

@@ -31,6 +31,29 @@ class OrganizerForm(I18nModelForm):
return slug
class OrganizerDeleteForm(forms.Form):
error_messages = {
'slug_wrong': _("The slug you entered was not correct."),
}
slug = forms.CharField(
max_length=255,
label=_("Event slug"),
)
def __init__(self, *args, **kwargs):
self.organizer = kwargs.pop('organizer')
super().__init__(*args, **kwargs)
def clean_slug(self):
slug = self.cleaned_data.get('slug')
if slug != self.organizer.slug:
raise forms.ValidationError(
self.error_messages['slug_wrong'],
code='slug_wrong',
)
return slug
class OrganizerUpdateForm(OrganizerForm):
def __init__(self, *args, **kwargs):