fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into rwd
[wolnelektury.git]
/
apps
/
funding
/
models.py
diff --git
a/apps/funding/models.py
b/apps/funding/models.py
index
3a74238
..
ba14947
100644
(file)
--- a/
apps/funding/models.py
+++ b/
apps/funding/models.py
@@
-12,7
+12,7
@@
from django.db import models
from django.utils.translation import ugettext_lazy as _, ugettext, override
import getpaid
from catalogue.models import Book
from django.utils.translation import ugettext_lazy as _, ugettext, override
import getpaid
from catalogue.models import Book
-from catalogue.utils import get_random_hash
+from catalogue.utils import get_random_hash
, related_tag_name
from polls.models import Poll
from django.contrib.sites.models import Site
from . import app_settings
from polls.models import Poll
from django.contrib.sites.models import Site
from . import app_settings
@@
-124,6
+124,9
@@
class Offer(models.Model):
""" QuerySet for all completed payments for the offer. """
return Funding.payed().filter(offer=self)
""" QuerySet for all completed payments for the offer. """
return Funding.payed().filter(offer=self)
+ def funders(self):
+ return self.funding_payed().order_by('-amount', 'payed_at')
+
def sum(self):
""" The money gathered. """
return self.funding_payed().aggregate(s=models.Sum('amount'))['s'] or 0
def sum(self):
""" The money gathered. """
return self.funding_payed().aggregate(s=models.Sum('amount'))['s'] or 0
@@
-172,7
+175,7
@@
class Offer(models.Model):
'funding/email/published.txt', {
'offer': self,
'book': self.book,
'funding/email/published.txt', {
'offer': self,
'book': self.book,
- 'author': ", ".join(
a[0]
for a in self.book.related_info()['tags']['author']),
+ 'author': ", ".join(
related_tag_name(a)
for a in self.book.related_info()['tags']['author']),
'current': self.current(),
})
'current': self.current(),
})
@@
-230,6
+233,9
@@
class Funding(models.Model):
def get_absolute_url(self):
return reverse('funding_funding', args=[self.pk])
def get_absolute_url(self):
return reverse('funding_funding', args=[self.pk])
+ def perk_names(self):
+ return ", ".join(perk.name for perk in self.perks.all())
+
def get_disable_notifications_url(self):
return "%s?%s" % (reverse("funding_disable_notifications"),
urlencode({
def get_disable_notifications_url(self):
return "%s?%s" % (reverse("funding_disable_notifications"),
urlencode({