Points for email address confirm, fix little bug
authorCharles Connell <charles@connells.org>
Thu, 23 Jan 2014 16:49:52 +0000 (11:49 -0500)
committerCharles Connell <charles@connells.org>
Thu, 23 Jan 2014 16:50:06 +0000 (11:50 -0500)
karmaworld/apps/notes/gdrive.py
karmaworld/apps/notes/views.py
karmaworld/apps/users/models.py

index ade782bad36d26ba359a285a3fa8d37fabbc1841..db39265cae3f9d799a38c7b3c408dc5cadd61424 100644 (file)
@@ -4,7 +4,6 @@
 
 import datetime
 from django.contrib.auth.models import User
-from django.contrib.sessions.backends.db import SessionStore
 from django.core.exceptions import ObjectDoesNotExist
 from karmaworld.apps.users.models import NoteKarmaEvent
 import os
index 09b7827babae4dc8675986d490592ab4ed859ef7..2a19ae9c7e8d8bb8794d0391fbefd465d11fbd1e 100644 (file)
@@ -231,7 +231,7 @@ class NoteSearchView(ListView):
 
 def process_note_thank_events(request_user, note):
     # Give points to the person who uploaded this note
-    if note.user != request_user:
+    if note.user != request_user and note.user:
         NoteKarmaEvent.create_event(note.user, note, NoteKarmaEvent.THANKS)
 
 
@@ -246,7 +246,7 @@ def process_note_flag_events(request_user, note):
         NoteKarmaEvent.create_event(request_user, note, NoteKarmaEvent.GIVE_FLAG)
     # If this is the 6th time this note has been flagged,
     # punish the uploader
-    if note.flags == 6:
+    if note.flags == 6 and note.user:
         NoteKarmaEvent.create_event(note.user, note, NoteKarmaEvent.GET_FLAGGED)
 
 
index b13f4792819ed51b2eb807646a67eaf35a59f2a4..3ea4f5fc5a5b97f8e70e62ffe552bfbc93fbbf5f 100644 (file)
@@ -3,6 +3,7 @@
 # Copyright (C) 2013  FinalsClub Foundation
 import logging
 import datetime
+from allauth.account.signals import email_confirmed, email_added
 from django.contrib.auth.models import User
 from django.db.models import Sum
 from django.db.models.signals import post_save
@@ -75,6 +76,11 @@ class UserProfile(models.Model):
         return self.user.__unicode__()
 
 
+@receiver(email_confirmed, weak=True)
+def give_email_confirm_karma(sender, **kwargs):
+    GenericKarmaEvent.create_event(kwargs['email_address'].user, "You confirmed your email address", 5)
+
+
 class BaseKarmaEvent(models.Model):
     points    = models.IntegerField()
     user      = models.ForeignKey(User)