from django.template.loader import render_to_string
from django.db import models
from django.utils.timezone import utc
-from django.utils.translation import ugettext_lazy as _, ugettext, override
+from django.utils.translation import ugettext_lazy as _, override
import getpaid
from catalogue.models import Book
from catalogue.utils import get_random_hash, related_tag_name
redakcja_url = models.URLField(_('redakcja URL'), blank=True)
book = models.ForeignKey(Book, null=True, blank=True,
help_text=_('Published book.'))
- cover = models.ImageField(_('Cover'), upload_to = 'funding/covers')
- poll = models.ForeignKey(Poll, help_text = _('Poll'), null = True, blank = True, on_delete = models.SET_NULL)
+ cover = models.ImageField(_('Cover'), upload_to='funding/covers')
+ poll = models.ForeignKey(Poll, help_text=_('Poll'), null=True, blank=True, on_delete=models.SET_NULL)
notified_near = models.DateTimeField(_('Near-end notifications sent'), blank=True, null=True)
notified_end = models.DateTimeField(_('End notifications sent'), blank=True, null=True)
return u'<img src="%s" />' % self.cover.url
cover_img_tag.short_description = _('Cover preview')
cover_img_tag.allow_tags = True
-
+
class Meta:
verbose_name = _('offer')
verbose_name_plural = _('offers')
return reverse('funding_offer', args=[self.slug])
def save(self, *args, **kw):
- published_now = (self.book_id is not None and
+ published_now = (self.book_id is not None and
self.pk is not None and
type(self).objects.values('book').get(pk=self.pk)['book'] != self.book_id)
retval = super(Offer, self).save(*args, **kw)
def get_perks(self, amount=None):
""" Finds all the perks for the offer.
-
+
If amount is provided, returns the perks you get for it.
"""
class Perk(models.Model):
""" A perk offer.
-
+
If no attached to a particular Offer, applies to all.
"""
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)
- language_code = models.CharField(max_length = 2, null = True, blank = True)
+ language_code = models.CharField(max_length=2, null=True, blank=True)
notifications = models.BooleanField(_('notifications'), default=True, db_index=True)
notify_key = models.CharField(max_length=32)