class EmailLeadMagnetCampaign(TimestampedModel): objects = EmailLeadCampaignQuerySet.as_manager() # type: EmailLeadCampaignQuerySet name = models.CharField(_('Name'), max_length=32) slug = models.SlugField(unique=True) template_id = models.CharField(_('Letter template id'), max_length=255, help_text=_('Will be sent upon lead registration')) success_message = models.CharField(_('Success Message'), max_length=255, help_text=_('Will be shown under tilda form')) class Meta: verbose_name = _('Email Lead Magnet Campaign') verbose_name_plural = _('Email Lead Magnet Campaigns') def execute(self, user: User): send_mail.delay( to=user.email, template_id=self.template_id, ctx={ 'campaign_name': self.name, 'firstname': user.first_name, 'lastname': user.last_name, }, disable_antispam=True, )
class Shippable(TimestampedModel): """Add this to every shippable item""" name = models.CharField(max_length=255) name_receipt = models.CharField( _('Name for receipts'), max_length=255, help_text= '«посещение мастер-класса по TDD» или «Доступ к записи курсов кройки и шитья»' ) full_name = models.CharField( _('Full name for letters'), max_length=255, help_text= 'Билет на мастер-класс о TDD или «запись курсов кройки и шитья»', ) slug = models.SlugField() price = models.DecimalField(max_digits=8, decimal_places=2) old_price = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True) tinkoff_credit_promo_code = models.CharField( _('Fixed promo code for tinkoff credit'), max_length=64, blank=True, help_text=_('Used in tinkoff credit only')) class Meta: abstract = True def get_price_display(self): return format_price(self.price) def get_old_price_display(self): return format_price(self.old_price) def get_formatted_price_display(self): return format_old_price(self.old_price, self.price) def ship(self, to: User, order: Optional[Order] = None): return ShippingFactory.ship(self, to=to, order=order) def get_price(self, promocode=None) -> Decimal: promocode = apps.get_model('orders.PromoCode').objects.get_or_nothing( name=promocode) if promocode is not None: return promocode.apply(self.price) return self.price def get_template_id(self): """Get custom per-item template_id""" if not hasattr(self, 'template_id'): return if self.template_id is not None and len(self.template_id): return self.template_id
class Shippable(TimestampedModel): """Add this to every shippable item""" name = models.CharField(max_length=255) name_receipt = models.CharField( _('Name for receipts'), max_length=255, help_text= '«посещение мастер-класса по TDD» или «Доступ к записи курсов кройки и шитья»' ) full_name = models.CharField( _('Full name for letters'), max_length=255, help_text= 'Билет на мастер-класс о TDD или «запись курсов кройки и шитья»', ) slug = models.SlugField() price = models.DecimalField(max_digits=8, decimal_places=2) old_price = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True) class Meta: abstract = True def get_price_display(self): return format_price(self.price) def get_old_price_display(self): return format_price(self.old_price) def get_formatted_price_display(self): return format_old_price(self.old_price, self.price) def ship(self, to): return ShippingFactory.ship(self, to=to) def get_template_id(self): """Get custom per-item template_id""" if not hasattr(self, 'template_id'): return if self.template_id is not None and len(self.template_id): return self.template_id