created = models.DateTimeField(auto_now_add=True, null=False, db_index=True) def get_absolute_url(self): return reverse('eggplant:market:order_info', kwargs={'pk': self.pk}) def get_last_payment_status(self): payments = self.payments.all().order_by('-created_on')[:1] if payments: return payments[0].status def __str__(self): return "Payment#{} of {} ({})".format( self.id, self.amount, self.get_last_payment_status(), ) def is_ready_for_payment(self): return bool(self.total) class Meta: app_label = 'market' GetPaidPayment = getpaid.register_to_payment( Payment, unique=False, related_name='payments' )
('P', 'Payment complete') ) @python_2_unicode_compatible class Order(models.Model): """ This is an example Order object. This one is very simple - is only one item, but you can easily create more complicated models with multi-items it does not matter for payment processing. """ name = models.CharField(max_length=100, default="Lock, Stock and Two Smoking Barrels") total = models.DecimalField(decimal_places=2, max_digits=8, default='199.99') currency = models.CharField(max_length=3, default='EUR') status = models.CharField(max_length=1, blank=True, default='W', choices=ORDER_STATUS_CHOICES) def get_absolute_url(self): return reverse('order_detail', kwargs={'pk': self.pk}) def __str__(self): return self.name def clean(self): self.currency = self.currency.upper() Payment = getpaid.register_to_payment(Order, unique=False, related_name='payments')
'site': Site.objects.get_current(), } if extra_context: context.update(extra_context) with override(self.language_code or app_settings.DEFAULT_LANGUAGE): send_mail( subject, render_to_string(template_name, context), settings.CONTACT_EMAIL, [self.email], fail_silently=False) def disable_notifications(self): """Disables all notifications for this e-mail address.""" type(self).objects.filter(email=self.email).update(notifications=False) # Register the Funding model with django-getpaid for payments. getpaid.register_to_payment(Funding, unique=False, related_name='payment') class Spent(models.Model): """ Some of the remaining money spent on a book. """ book = models.ForeignKey(Book) amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10) timestamp = models.DateField(_('when')) class Meta: verbose_name = _('money spent on a book') verbose_name_plural = _('money spent on books') ordering = ['-timestamp'] def __str__(self): return u"Spent: %s" % str(self.book)
but you can easily create more complicated models with multi-items it does not matter for payment processing. """ name = models.CharField(max_length=100, default="Lock, Stock and Two Smoking Barrels") total = models.DecimalField(decimal_places=2, max_digits=8, default='199.99') currency = models.CharField(max_length=3, default='EUR') status = models.CharField(max_length=1, blank=True, default='W', choices=ORDER_STATUS_CHOICES) def get_absolute_url(self): return reverse('order_detail', kwargs={'pk': self.pk}) def __str__(self): return self.name def clean(self): self.currency = self.currency.upper() Payment = getpaid.register_to_payment(Order, unique=False, related_name='payments') #noinspection PyUnresolvedReferences from .listeners import *
} if extra_context: context.update(extra_context) with override(self.language_code or app_settings.DEFAULT_LANGUAGE): send_mail(subject, render_to_string(template_name, context), settings.CONTACT_EMAIL, [self.email], fail_silently=False) def disable_notifications(self): """Disables all notifications for this e-mail address.""" type(self).objects.filter(email=self.email).update(notifications=False) # Register the Funding model with django-getpaid for payments. getpaid.register_to_payment(Funding, unique=False, related_name='payment') class Spent(models.Model): """ Some of the remaining money spent on a book. """ book = models.ForeignKey(Book) amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10) timestamp = models.DateField(_('when')) class Meta: verbose_name = _('money spent on a book') verbose_name_plural = _('money spent on books') ordering = ['-timestamp'] def __unicode__(self): return u"Spent: %s" % unicode(self.book)