Permalink
Browse files

Implemented deferred form for changing e-mail address

  • Loading branch information...
1 parent 0b02a2d commit 6104b0d80be86cf435219e05e0a9598878d731f9 @anttihirvonen committed Sep 14, 2012
View
16 dotmembership/apps/members/forms.py
@@ -19,7 +19,7 @@ class MemberForm(forms.ModelForm):
"""
class Meta:
model = Member
- fields = ("first_name", "last_name", "email", "home_town",
+ fields = ("first_name", "last_name", "home_town",
"school", "major", "class_year")
@@ -29,6 +29,20 @@ class Meta:
fields = ("email",)
+class MemberEmailEditForm(DeferredForm):
+ class Meta:
+ model = Member
+ fields = ("email",)
+
+ def send_notification(self, user=None, instance=None):
+ subject = _(u"Hyväksy uusi sähköpostiosoite")
+ body = render_to_string("members/mails/change_email.txt",
+ {'token': instance.token,
+ 'base_url': "http://{0}".format(Site.objects.get_current().domain),
+ })
+ send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [self.cleaned_data['email']])
+
+
class MemberJoinForm(DeferredForm):
"""
The main form for registering a new member.
View
10 dotmembership/apps/members/templates/members/mails/change_email.txt
@@ -0,0 +1,10 @@
+Hei!
+
+Halusit muuttaa DOTin jäsenrekisterissä käyttämäsi
+sähköpostiosoitteen tähän osoitteeseen. Sinun tulee
+käydä hyväksymässä muutos allaolevan linkin kautta:
+
+{{ base_url }}{% url members-confirm_email_change token %}
+
+--
+Digitaalisen median ammattiainekerho DOT ry

0 comments on commit 6104b0d

Please sign in to comment.