from catalogue.utils import get_random_hash
from polls.models import Poll
from django.contrib.sites.models import Site
from catalogue.utils import get_random_hash
from polls.models import Poll
from django.contrib.sites.models import Site
target = models.DecimalField(_('target'), decimal_places=2, max_digits=10)
start = models.DateField(_('start'), db_index=True)
end = models.DateField(_('end'), db_index=True)
target = models.DecimalField(_('target'), decimal_places=2, max_digits=10)
start = models.DateField(_('start'), db_index=True)
end = models.DateField(_('end'), db_index=True)
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)
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)
- """ Returns current fundraiser or None. """
+ """ Returns current fundraiser or None.
+
+ Current fundraiser is the one that:
+ - has already started,
+ - hasn't yet ended,
+ - if there's more than one of those, it's the one that ends last.
+
+ """
- """ QuerySet for all current and past fundraisers. """
- today = date.today()
- return cls.objects.filter(end__lt=today)
+ """ QuerySet for all past fundraisers. """
+ objects = cls.public()
+ current = cls.current()
+ if current is not None:
+ objects = objects.exclude(pk=current.pk)
+ return objects
assert not self.is_current()
self.notify_all(
_('The fundraiser has ended!'),
assert not self.is_current()
self.notify_all(
_('The fundraiser has ended!'),
'remaining': self.remaining(),
'current': self.current(),
})
'remaining': self.remaining(),
'current': self.current(),
})
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 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({
send_mail(subject,
render_to_string(template_name, context),
getattr(settings, 'CONTACT_EMAIL', 'wolnelektury@nowoczesnapolska.org.pl'),
send_mail(subject,
render_to_string(template_name, context),
getattr(settings, 'CONTACT_EMAIL', 'wolnelektury@nowoczesnapolska.org.pl'),