From 5c862f5a564dad4d28c98e2aab58349864041227 Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Thu, 23 Jan 2014 11:49:52 -0500 Subject: [PATCH] Points for email address confirm, fix little bug --- karmaworld/apps/notes/gdrive.py | 1 - karmaworld/apps/notes/views.py | 4 ++-- karmaworld/apps/users/models.py | 6 ++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/karmaworld/apps/notes/gdrive.py b/karmaworld/apps/notes/gdrive.py index ade782b..db39265 100644 --- a/karmaworld/apps/notes/gdrive.py +++ b/karmaworld/apps/notes/gdrive.py @@ -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 diff --git a/karmaworld/apps/notes/views.py b/karmaworld/apps/notes/views.py index 09b7827..2a19ae9 100644 --- a/karmaworld/apps/notes/views.py +++ b/karmaworld/apps/notes/views.py @@ -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) diff --git a/karmaworld/apps/users/models.py b/karmaworld/apps/users/models.py index b13f479..3ea4f5f 100644 --- a/karmaworld/apps/users/models.py +++ b/karmaworld/apps/users/models.py @@ -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) -- 2.25.1