Add nominations_accepted flag to close #32

This commit is contained in:
Les Orchard 2012-05-17 22:03:31 -04:00
Родитель 11e1d53150
Коммит 55b81750ef
1 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -59,6 +59,11 @@ if "notification" in settings.INSTALLED_APPS:
else:
notification = None
if "badger_multiplayer" in settings.INSTALLED_APPS:
import badger_multiplayer
else:
badger_multiplayer = None
from .signals import (badge_will_be_awarded, badge_was_awarded)
@ -337,6 +342,13 @@ class Badge(models.Model):
help_text="Should awards of this badge be restricted to "
"one-per-person?")
if badger_multiplayer:
# HACK: This belongs in the badger_multiplayer model, ugh
# https://github.com/lmorchard/django-badger/issues/15
nominations_accepted = models.BooleanField(default=True,
help_text="Does this badge accept nominations from "
"other users?")
if taggit:
tags = TaggableManager(blank=True)
@ -381,6 +393,11 @@ class Badge(models.Model):
dict(badge=self,
protocol=DEFAULT_HTTP_PROTOCOL))
def delete(self, **kwargs):
"""Make sure deletes cascade to awards"""
self.award_set.all().delete()
super(Badge, self).delete(**kwargs)
def allows_detail_by(self, user):
# TODO: Need some logic here, someday.
return True