From 8acdb721d10f652f18099673d839418fe8547a04 Mon Sep 17 00:00:00 2001 From: Les Orchard Date: Sun, 13 May 2012 00:07:54 -0400 Subject: [PATCH] Add allows_delete_by permission method to Badge model --- badger/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/badger/models.py b/badger/models.py index d92e965..fbbf94b 100644 --- a/badger/models.py +++ b/badger/models.py @@ -394,6 +394,15 @@ class Badge(models.Model): return True return False + def allows_delete_by(self, user): + if user.is_anonymous(): + return False + if user.has_perm('badger.change_badge'): + return True + if user == self.creator: + return True + return False + def allows_award_to(self, user): """Is award_to() allowed for this user?""" if None == user: