Helpers for listing nominations on profile
This commit is contained in:
Родитель
4b7a568626
Коммит
e3ebb183b4
|
@ -0,0 +1,38 @@
|
||||||
|
import hashlib
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
from django.contrib.auth.models import SiteProfileNotAvailable
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
|
||||||
|
try:
|
||||||
|
from commons.urlresolvers import reverse
|
||||||
|
except ImportError, e:
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
|
try:
|
||||||
|
from tower import ugettext_lazy as _
|
||||||
|
except ImportError, e:
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
import jingo
|
||||||
|
import jinja2
|
||||||
|
from jinja2 import evalcontextfilter, Markup, escape
|
||||||
|
from jingo import register, env
|
||||||
|
|
||||||
|
from badger.models import (Progress,
|
||||||
|
BadgeAwardNotAllowedException)
|
||||||
|
|
||||||
|
from .models import Badge, Award, Nomination
|
||||||
|
|
||||||
|
@register.function
|
||||||
|
def nominations_pending_approval(user):
|
||||||
|
return Nomination.objects.filter(badge__creator=user,
|
||||||
|
approver__isnull=True)
|
||||||
|
|
||||||
|
@register.function
|
||||||
|
def nominations_pending_acceptance(user):
|
||||||
|
return Nomination.objects.filter(nominee=user,
|
||||||
|
approver__isnull=False,
|
||||||
|
accepted=False)
|
|
@ -106,6 +106,10 @@ class Nomination(models.Model):
|
||||||
return u'Nomination for %s to %s by %s' % (self.badge, self.nominee,
|
return u'Nomination for %s to %s by %s' % (self.badge, self.nominee,
|
||||||
self.creator)
|
self.creator)
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('badger_multiplayer.views.nomination_detail',
|
||||||
|
args=(self.badge.slug, self.id))
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
# Signals and some bits of logic only happen on a new nomination.
|
# Signals and some bits of logic only happen on a new nomination.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче