def start_default_listening(): """Add required default listeners""" collect_urls.connect(add_download_urls, sender=product) product_signals.subtype_order_success.connect(create_download_link, sender=None) signals.order_success.connect(ship_downloadable_order, sender=None) log.debug('Added downnloadable product listeners')
choices=settings.LANGUAGES) name = models.CharField(_('title'), max_length=100, blank=False) short_description = models.CharField(_('Short Description'), blank=True, max_length=200) description = models.TextField(_('Description'), blank=True) picture = ImageWithThumbnailField( verbose_name=_('Picture'), upload_to="__DYNAMIC__", name_field="_filename", null=True, blank=True, max_length=200) #Media root is automatically prepended def _get_filename(self): if self.brandcategory: return '%s-%s' % (self.brandcategory.brand.slug, self.id) else: return 'default' _filename = property(_get_filename) class Meta: ordering = ('languagecode', ) verbose_name_plural = _('Brand Category Translations') #import config from urls import add_brand_urls collect_urls.connect(add_brand_urls, sender=product)
from satchmo_utils.signals import collect_urls from satchmo_store import shop from urls import add_feed_urls collect_urls.connect(add_feed_urls, sender=shop)
from django.contrib.comments.models import Comment from django.db import models from django.utils.translation import ugettext, ugettext_lazy as _ from satchmo_utils.signals import collect_urls import product import satchmo_store class ProductRating(models.Model): """A rating attached to a comment""" comment = models.OneToOneField(Comment, verbose_name="Rating", primary_key=True) rating = models.IntegerField(_("Rating")) import config from urls import add_product_urls, add_comment_urls collect_urls.connect(add_product_urls, sender=product) collect_urls.connect(add_comment_urls, sender=satchmo_store)
verbose_name = _('Brand Category Product') verbose_name_plural = _('Brand Category Products') class BrandCategoryTranslation(models.Model): brandcategory = models.ForeignKey(BrandCategory, related_name="translations") languagecode = models.CharField(_('language'), max_length=10, choices=settings.LANGUAGES) name = models.CharField(_('title'), max_length=100, blank=False) short_description = models.CharField(_('Short Description'), blank=True, max_length=200) description = models.TextField(_('Description'), blank=True) picture = ImageWithThumbnailField(verbose_name=_('Picture'), upload_to="__DYNAMIC__", name_field="_filename", null=True, blank=True, max_length=200) #Media root is automatically prepended def _get_filename(self): if self.brandcategory: return '%s-%s' % (self.brandcategory.brand.slug, self.id) else: return 'default' _filename = property(_get_filename) class Meta: ordering=('languagecode', ) verbose_name_plural = _('Brand Category Translations') #import config from urls import add_brand_urls collect_urls.connect(add_brand_urls, sender=product)
def set_details(self, raw): """Set the details from a raw list""" if raw: self._details = simplejson.dumps(raw) def get_details(self): """Convert the pickled details into a list""" if self._details: return simplejson.loads(self._details) else: return [] details = property(fget=get_details, fset=set_details) def save(self, force_insert=False, force_update=False): """Ensure we have a create_date before saving the first time.""" if not self.pk: self.create_date = datetime.date.today() super(ProductWish, self).save(force_insert=force_insert, force_update=force_update) class Meta: verbose_name = _('Product Wish') verbose_name_plural = _('Product Wishes') cart_add_view.connect(wishlist_cart_add_listener) import config from urls import add_wishlist_urls collect_urls.connect(add_wishlist_urls, sender=shop)
def start_listening(): from urls import add_newsletter_urls from satchmo_store import shop form_postsave.connect(contact_form_listener, sender=ContactInfoForm) collect_urls.connect(add_newsletter_urls, sender=shop)
def set_details(self, raw): """Set the details from a raw list""" if raw: self._details = simplejson.dumps(raw) def get_details(self): """Convert the pickled details into a list""" if self._details: return simplejson.loads(self._details) else: return [] details = property(fget=get_details, fset=set_details) def save(self, **kwargs): """Ensure we have a create_date before saving the first time.""" if not self.pk: self.create_date = datetime.date.today() super(ProductWish, self).save(**kwargs) class Meta: verbose_name = _('Product Wish') verbose_name_plural = _('Product Wishes') cart_add_view.connect(wishlist_cart_add_listener) import config from urls import add_wishlist_urls collect_urls.connect(add_wishlist_urls, sender=shop)
att = self.attributes.get(name=name) att.value = value except SubscriptionAttribute.DoesNotExist: att = SubscriptionAttribute(subscription=self, name=name, value=value) att.save() return att def update_attributes(self, attributes): """Update `SubscriptionAttribute` objects from a dictionary of name val mappings.""" return [self.update_attribute(name, value) for name, value in attributes.items()] class SubscriptionAttribute(models.Model): """ Allows arbitrary name/value pairs (as strings) to be attached to a subscription. """ subscription = models.ForeignKey(Subscription, related_name="attributes") name = models.SlugField(_("Attribute Name"), max_length=100, ) value = models.CharField(_("Value"), max_length=255) class Meta: verbose_name = _("Subscription Attribute") verbose_name_plural = _("Subscription Attributes") import config from listeners import contact_form_listener from urls import add_newsletter_urls form_save.connect(contact_form_listener, sender=ContactInfoForm) collect_urls.connect(add_newsletter_urls, sender=shop)