]> git.openstreetmap.org Git - osqa.git/commitdiff
start awarding users who validate their emails with a badge, include email validation...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 7 Sep 2011 12:37:15 +0000 (12:37 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 7 Sep 2011 12:37:15 +0000 (12:37 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1170 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/views/auth.py
forum_modules/default_badges/badges.py

index 1b18d6c08ee459315430155677af0ed7d617da87..c9f3111109b5397411a8f603a738d40509018366 100644 (file)
@@ -14,6 +14,7 @@ from django.contrib.auth import login, logout
 
 from writers import manage_pending_data
 
+from forum.actions import EmailValidationAction
 from forum.utils import html
 from forum.views.decorators import login_required
 from forum.modules import decorate
@@ -296,8 +297,7 @@ def validate_email(request, user, code):
     user = get_object_or_404(User, id=user)
 
     if (ValidationHash.objects.validate(code, user, 'email', [user.email])):
-        user.email_isvalid = True
-        user.save()
+        EmailValidationAction(user=user, ip=request.META['REMOTE_ADDR']).save()
         return login_and_forward(request, user, reverse('index'), _("Thank you, your email is now validated."))
     else:
         return render_to_response('auth/mail_already_validated.html', { 'user' : user }, RequestContext(request))
index 893d32a322457732e8acbc299d930383ef9762a1..f9da788d6c5ad434a22f7d7475b90f4ac9e2d014 100644 (file)
@@ -320,3 +320,11 @@ class Taxonomist(AbstractBadge):
     def award_to(self, action):
         return None
 
+class ValidatedEmail(AbstractBadge):
+    type = Badge.BRONZE
+    listen_to = (EmailValidationAction,)
+    name = _("Validated Email")
+    description = _("User who has validated email associated to the account")
+
+    def award_to(self, action):
+        return action.user
\ No newline at end of file