mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Fix subscription form
This commit is contained in:
@ -69,7 +69,7 @@ class Subscription(models.Model):
|
||||
except: # This should not happen, because the form should have handled the data before, but sadly, it still
|
||||
# calls the model validation :'(
|
||||
# TODO see SubscriptionForm's clean method
|
||||
raise ValidationError(_("You are trying to create a subscription without member"))
|
||||
raise ValidationError(_("Subscription error"))
|
||||
|
||||
def save(self):
|
||||
super(Subscription, self).save()
|
||||
|
@ -9,6 +9,7 @@
|
||||
<div id="user_info"></div>
|
||||
<form action="" method="post" id="subscription_form">
|
||||
{% csrf_token %}
|
||||
{{ form.non_field_errors() }}
|
||||
<p>{{ form.member.errors }}<label for="{{ form.member.name }}">{{ form.member.label }}</label> {{ form.member }}</p>
|
||||
<div id="new_member">
|
||||
<p>{{ form.first_name.errors }}<label for="{{ form.first_name.name }}">{{ form.first_name.label }}</label> {{ form.first_name }}</p>
|
||||
|
@ -48,6 +48,8 @@ class SubscriptionForm(forms.ModelForm):
|
||||
and "first_name" not in self.errors.as_data()
|
||||
and "email" not in self.errors.as_data()):
|
||||
self.errors.pop("member", None)
|
||||
if self.errors:
|
||||
return cleaned_data
|
||||
if Subscriber.objects.filter(email=cleaned_data.get("email")).first() is not None:
|
||||
self.add_error("email", ValidationError(_("A user with that email address already exists")))
|
||||
else:
|
||||
|
Reference in New Issue
Block a user