"""Record that somebody has downloaded a note"""
if request_user.is_authenticated() and request_user != note.user:
NoteKarmaEvent.create_event(request_user, note, NoteKarmaEvent.DOWNLOADED_NOTE)
- if request_user.is_authenticated() and note.user:
+ if request_user.is_authenticated() and note.user and note.user != request_user:
NoteKarmaEvent.create_event(note.user, note, NoteKarmaEvent.HAD_NOTE_DOWNLOADED)
except ObjectDoesNotExist:
self.fail("Karma event not created")
+ def test_download_own_note_karma(self):
+ """No karma change for downloading your own note"""
+ downloaded_note(self.request1, self.note.pk)
+ try:
+ NoteKarmaEvent.objects.get(event_type=NoteKarmaEvent.DOWNLOADED_NOTE, user=self.user1)
+ self.fail("Karma debited for downloading own note, but shouldn't have been.")
+ except ObjectDoesNotExist:
+ pass
+ try:
+ NoteKarmaEvent.objects.get(event_type=NoteKarmaEvent.HAD_NOTE_DOWNLOADED, user=self.user1)
+ self.fail("Karma given for downloading own note, but shouldn't have been.")
+ except ObjectDoesNotExist:
+ pass
+
def test_email_confirm_karma(self):
class FakeEmailAddress:
user = self.user1