X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/75957f735219259d3b4bc361f80ccd3d7b92a0e9..08e9107a1047a466e8499a18d9742a66fb8c4b3c:/src/funding/models.py
diff --git a/src/funding/models.py b/src/funding/models.py
index 3e20efc7b..0e3fa425d 100644
--- a/src/funding/models.py
+++ b/src/funding/models.py
@@ -10,6 +10,7 @@ from django.db import models
from django.dispatch import receiver
from django.template.loader import render_to_string
from django.urls import reverse
+from django.utils.html import mark_safe
from django.utils.timezone import utc
from django.utils.translation import ugettext_lazy as _, override
import getpaid
@@ -38,9 +39,8 @@ class Offer(models.Model):
notified_end = models.DateTimeField(_('End notifications sent'), blank=True, null=True)
def cover_img_tag(self):
- return u'' % self.cover.url
+ return mark_safe('' % self.cover.url)
cover_img_tag.short_description = _('Cover preview')
- cover_img_tag.allow_tags = True
class Meta:
verbose_name = _('offer')
@@ -48,7 +48,7 @@ class Offer(models.Model):
ordering = ['-end']
def __str__(self):
- return u"%s - %s" % (self.author, self.title)
+ return "%s - %s" % (self.author, self.title)
def get_absolute_url(self):
return reverse('funding_offer', args=[self.slug])
@@ -194,7 +194,7 @@ class Offer(models.Model):
offer_sum = self.sum()
return {
'offer': self,
- 'sum': offset_sum,
+ 'sum': offer_sum,
'is_current': self.is_current(),
'is_win': offer_sum >= self.target,
'missing': self.target - offer_sum,
@@ -258,7 +258,7 @@ class Perk(models.Model):
ordering = ['-price']
def __str__(self):
- return "%s (%s%s)" % (self.name, self.price, u" for %s" % self.offer if self.offer else "")
+ return "%s (%s%s)" % (self.name, self.price, " for %s" % self.offer if self.offer else "")
class Funding(models.Model):
@@ -270,6 +270,7 @@ class Funding(models.Model):
offer = models.ForeignKey(Offer, models.PROTECT, verbose_name=_('offer'))
name = models.CharField(_('name'), max_length=127, blank=True)
email = models.EmailField(_('email'), blank=True, db_index=True)
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, models.SET_NULL, blank=True, null=True)
amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10)
payed_at = models.DateTimeField(_('payed at'), null=True, blank=True, db_index=True)
perks = models.ManyToManyField(Perk, verbose_name=_('perks'), blank=True)
@@ -304,6 +305,9 @@ class Funding(models.Model):
'key': self.notify_key,
}))
+ def wl_optout_url(self):
+ return 'https://wolnelektury.pl' + self.get_disable_notifications_url()
+
def save(self, *args, **kwargs):
if self.email and not self.notify_key:
self.notify_key = get_random_hash(self.email)
@@ -358,7 +362,7 @@ class Spent(models.Model):
ordering = ['-timestamp']
def __str__(self):
- return u"Spent: %s" % str(self.book)
+ return "Spent: %s" % str(self.book)
@receiver(getpaid.signals.new_payment_query)