Commits

funkybob  committed 1d24351

Added slug field and get_absolute_url to Catalogue model
Added ordering to Product

  • Participants
  • Parent commits e6b938e

Comments (0)

Files changed (1)

File gnocchi/store/models.py

 
 class Catalogue(models.Model):
     name = models.CharField(max_length=250)
+    slug = models.SlugField()
     sites = models.ManyToManyField('sites.Site', blank=True, null=True)
     def __unicode__(self):
         return self.name
 
+    @models.permalink
+    def get_absolute_url(self):
+        return ('catalogue-detail', (), {'slug': self.slug})
+
 class Product(models.Model):
     catalogue = models.ForeignKey('Catalogue')
     sku = models.CharField(max_length=64, unique=True, verbose_name='SKU')
     name = models.CharField(max_length=1024)
+    order = models.IntegerField(default=0)
     short_description = models.CharField(max_length=1024, blank=True)
     description = models.TextField(blank=True)
     price = models.DecimalField(decimal_places=2, max_digits=12)
 
     tags = TaggableManager(blank=True)
 
+    class Meta:
+        ordering = ('-order',)
+
     @models.permalink
     def get_absolute_url(self):
         return ('product-detail', (), {'pk': self.pk})