Commits

Roman Ruban  committed 20ec129

fixed brand urls doesn't apply

  • Participants
  • Parent commits 171a6f1

Comments (0)

Files changed (2)

File satchmo/apps/satchmo_ext/brand/models.py

 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 from l10n.mixins import TranslatedObjectMixin
-import product
+from satchmo_store import shop
 from product.models import Product
 from satchmo_utils.thumbnail.field import ImageWithThumbnailField
 from sorl.thumbnail import ImageField
         max_length=200) #Media root is automatically prepended
     ordering = models.IntegerField(_("Ordering"))
     active = models.BooleanField(default=True)
-    
+
     objects = BrandManager()
-    
+
     def _active_categories(self):
         return [cat for cat in self.categories.all() if cat.has_content()]
-    
+
     active_categories = property(fget=_active_categories)
-    
+
     def _translation(self):
         return self._find_translation()
     translation = property(fget=_translation)
 
     def _get_absolute_url(self):
         return ('satchmo_brand_view', None, {'brandname' : self.slug})
-        
+
     get_absolute_url = models.permalink(_get_absolute_url)
-        
+
     def active_products(self):
-        return self.products.filter(site=self.site, active=True)        
+        return self.products.filter(site=self.site, active=True)
 
     def has_categories(self):
         return self.active_categories().count() > 0
 
     def has_products(self):
         return self.active_products().count() > 0
-            
+
     def _get_filename(self):
         return '%s-%s' % (self.slug, self.id)
     _filename = property(_get_filename)
 
     def __unicode__(self):
         return u"%s" % self.slug
-            
+
     class Meta:
         ordering=('ordering', 'slug')
         verbose_name = _('Brand')
 class BrandProduct(models.Model):
     brand = models.ForeignKey(Brand)
     product = models.ForeignKey(Product)
-    
+
     class Meta:
         verbose_name=_("Brand Product")
         verbose_name_plural=_("Brand Products")
     _filename = property(_get_filename)
 
     class Meta:
-        ordering=('languagecode', )      
+        ordering=('languagecode', )
         verbose_name = _('Brand Translation')
-        verbose_name_plural = _('Brand Translations')  
+        verbose_name_plural = _('Brand Translations')
 
 class BrandCategoryManager(models.Manager):
     def by_slug(self, brandname, slug):
 
     def _get_absolute_url(self):
         return ('satchmo_brand_category_view', None, {'brandname' : self.brand.slug, 'catname' : self.slug})
-    
+
     get_absolute_url = models.permalink(_get_absolute_url)
-        
+
     def active_products(self):
-        return self.products.filter(site=self.brand.site).filter(active=True)                
-        
+        return self.products.filter(site=self.brand.site).filter(active=True)
+
     def has_categories(self):
-        return False    
-    
+        return False
+
     def has_content(self):
         return self.active_products()
 
 class BrandCategoryProduct(models.Model):
     brandcategory = models.ForeignKey(BrandCategory)
     product = models.ForeignKey(Product)
-    
+
     class Meta:
         verbose_name = _('Brand Category Product')
         verbose_name_plural = _('Brand Category Products')
 
 #import config        
 from urls import add_brand_urls
-collect_urls.connect(add_brand_urls, sender=product)
+collect_urls.connect(add_brand_urls, sender=shop)

File satchmo/apps/satchmo_ext/brand/urls.py

     (r'^(?P<brandname>.*)/(?P<catname>.*)/$', 'brand_category_page', {}, 'satchmo_brand_category_view'),
     (r'^(?P<brandname>.*)/$', 'brand_page', {}, 'satchmo_brand_view'),
 )
+patterns_fn = patterns
 
-brandbase = r'^' + get_satchmo_setting('BRAND_SLUG') + '/'
 
-prodbase = r'^' + get_satchmo_setting('PRODUCT_SLUG') + '/'
-brandpatterns = patterns('',
-    (brandbase, include('satchmo_ext.brand.urls'))
-)
 
-def add_brand_urls(sender, patterns=(), section="", **kwargs):
-    log.debug('brand section: %s', section)
-    if section=="__init__":
-        log.debug('adding brand urls at %s', brandbase)
-        patterns += brandpatterns
+
+def add_brand_urls(sender, patterns=(), **kwargs):
+    brandbase = r'^' + get_satchmo_setting('BRAND_SLUG') + '/'
+    log.debug('adding brand urls at %s', brandbase)
+    brandpatterns = patterns_fn('',
+        (brandbase, include('satchmo_ext.brand.urls'))
+    )
+    patterns += brandpatterns