# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from datetime import date, datetime
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from datetime import date, datetime
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.core.mail import send_mail
from django.db import models
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.core.mail import send_mail
from django.db import models
from django.template.loader import render_to_string
from django.utils.timezone import utc
from django.utils.translation import ugettext_lazy as _, override
from django.template.loader import render_to_string
from django.utils.timezone import utc
from django.utils.translation import ugettext_lazy as _, override
start = models.DateField(_('start'), db_index=True)
end = models.DateField(_('end'), db_index=True)
redakcja_url = models.URLField(_('redakcja URL'), blank=True)
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.'))
+ 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)
return u"%s - %s" % (self.author, self.title)
def get_absolute_url(self):
return reverse('funding_offer', args=[self.slug])
def save(self, *args, **kw):
return u"%s - %s" % (self.author, self.title)
def get_absolute_url(self):
return reverse('funding_offer', args=[self.slug])
def save(self, *args, **kw):
type(self).objects.values('book').get(pk=self.pk)['book'] != self.book_id)
retval = super(Offer, self).save(*args, **kw)
self.flush_includes()
type(self).objects.values('book').get(pk=self.pk)['book'] != self.book_id)
retval = super(Offer, self).save(*args, **kw)
self.flush_includes()
assert not self.is_current()
self.notify_all(
_('The fundraiser has ended!'),
assert not self.is_current()
self.notify_all(
_('The fundraiser has ended!'),
def get_absolute_url(self):
return reverse('funding_funding', args=[self.pk])
def get_absolute_url(self):
return reverse('funding_funding', args=[self.pk])
return ", ".join(perk.name for perk in self.perks.all())
def get_disable_notifications_url(self):
return ", ".join(perk.name for perk in self.perks.all())
def get_disable_notifications_url(self):
- def notify_funders(cls, subject, template_name, extra_context=None,
- query_filter=None, payed_only=True):
+ def notify_funders(cls, subject, template_name, extra_context=None, query_filter=None, payed_only=True):
funders = cls.objects.exclude(email="").filter(notifications=True)
if payed_only:
funders = funders.exclude(payed_at=None)
funders = cls.objects.exclude(email="").filter(notifications=True)
if payed_only:
funders = funders.exclude(payed_at=None)
- send_mail(subject,
- render_to_string(template_name, context),
- settings.CONTACT_EMAIL,
- [self.email],
- fail_silently=False
- )
+ send_mail(
+ subject, render_to_string(template_name, context), settings.CONTACT_EMAIL, [self.email],
+ fail_silently=False)
def new_payment_query_listener(sender, order=None, payment=None, **kwargs):
""" Set payment details for getpaid. """
payment.amount = order.amount
payment.currency = 'PLN'
def new_payment_query_listener(sender, order=None, payment=None, **kwargs):
""" Set payment details for getpaid. """
payment.amount = order.amount
payment.currency = 'PLN'
def user_data_query_listener(sender, order, user_data, **kwargs):
""" Set user data for payment. """
user_data['email'] = order.email
def user_data_query_listener(sender, order, user_data, **kwargs):
""" Set user data for payment. """
user_data['email'] = order.email
def payment_status_changed_listener(sender, instance, old_status, new_status, **kwargs):
""" React to status changes from getpaid. """
if old_status != 'paid' and new_status == 'paid':
def payment_status_changed_listener(sender, instance, old_status, new_status, **kwargs):
""" React to status changes from getpaid. """
if old_status != 'paid' and new_status == 'paid':
_('Thank you for your support!'),
'funding/email/thanks.txt'
)
_('Thank you for your support!'),
'funding/email/thanks.txt'
)