added a campaign.rightsholder property to make it not annoying to put rh names into templates

pull/1/head
Andromeda Yelton 2012-05-12 21:49:18 -04:00
parent 6fe7aeeabb
commit 33f7c99a5b
1 changed files with 15 additions and 3 deletions

View File

@ -212,7 +212,7 @@ class Campaign(models.Model):
self.save() self.save()
ungluers = self.work.wished_by() ungluers = self.work.wished_by()
notification.queue(ungluers, "wishlist_active", {'campaign':self, 'active_claim':active_claim, 'site': Site.objects.get_current()}, True) notification.queue(ungluers, "wishlist_active", {'campaign':self, 'site': Site.objects.get_current()}, True)
return self return self
@ -260,9 +260,21 @@ class Campaign(models.Model):
return Premium.objects.filter(q).exclude(type='XX').order_by('amount') return Premium.objects.filter(q).exclude(type='XX').order_by('amount')
def custom_premiums(self): def custom_premiums(self):
"""returns only the active custom premiums for the Campaign """ """returns only the active custom premiums for the Campaign"""
return Premium.objects.filter(campaign=self).filter(type='CU') return Premium.objects.filter(campaign=self).filter(type='CU')
@property
def rightsholder(self):
"""returns the name of the rights holder for an active or initialized campaign"""
try:
if self.status=='ACTIVE' or self.status=='INITIALIZED':
q = Q(status='ACTIVE') | Q(status='INITIALIZED')
rh = self.work.claim.filter(q)[0].rights_holder.rights_holder_name
return rh
except:
pass
return ''
class Identifier(models.Model): class Identifier(models.Model):
# olib, ltwk, goog, gdrd, thng, isbn, oclc, olwk, olib, gute, glue # olib, ltwk, goog, gdrd, thng, isbn, oclc, olwk, olib, gute, glue
type = models.CharField(max_length=4, null=False) type = models.CharField(max_length=4, null=False)