1. Federico Hlawaczek
  2. django-estudio42-toolbox

Commits

Federico Hlawaczek  committed f5df383

Added product, category and manufacturer order.

  • Participants
  • Parent commits 5df59d1
  • Branches default

Comments (0)

Files changed (2)

File simple_catalog/admin.py

View file
     # Change list settings
     # 
     actions = None
-    list_display = ('name', 'published', )
+    list_display = ('name', 'published', 'order', )
     list_filter = ('published', )    
     search_fields = ('name', )
+    list_editable = ('order', )
     # 
     # Change Form settings
     # 
     # Change list settings
     # 
     actions = None
-    list_display = ('name', 'published', )
+    list_display = ('name', 'published', 'order', )
     list_filter = ('published', )    
     search_fields = ('name', )
+    list_editable = ('order', )
     # 
     # Change Form settings
     # 
     # Change list settings
     # 
     actions = None
-    list_display = ('name', 'sku', 'published', 'category', 'manufacturer', )
+    list_display = ('name', 'sku', 'published', 'category', 'manufacturer', 'order', )
     list_filter = ('published', 'category', 'manufacturer', )    
     search_fields = ('name', 'sku', )
+    list_editable = ('order', )
     # 
     # Change Form settings
     # 

File simple_catalog/models.py

View file
     # Model ############################
     objects = CategoryManager()
     objects_published = CategoryManagerPublished()
+    order = models.PositiveIntegerField(_(u"Orden"), default=0)
     name = models.CharField(_(u"Nombre"), max_length=30, unique=True)
     description = HTMLTextField(_(u"Descripción"), blank=True)
     published = models.BooleanField(_(u"Publicado"), default=True)
     
     class Meta:
-        ordering = ('name', )
+        ordering = ('order', 'name', )
         verbose_name = _(u"Categoría")
         verbose_name_plural = _(u"Categorías")
     
     # Model ############################
     objects = ManufacturerManager()
     objects_published = ManufacturerManagerPublished()
+    order = models.PositiveIntegerField(_(u"Orden"), default=0)
     name = models.CharField(_(u"Nombre"), max_length=64, unique=True)
     description = HTMLTextField(_(u"Descripción"), blank=True)
     logo = models.ImageField(_(u"Logotipo"), blank=True, null=True, 
                           )
     
     class Meta:
-        ordering = ('name', )
+        ordering = ('order', 'name', )
         verbose_name = _(u"Fabricante")
         verbose_name_plural = _(u"Fabricantes")
     
     # Model ############################
     objects = ProductManager()
     objects_published = ProductManagerPublished()
+    order = models.PositiveIntegerField(_(u"Orden"), default=0)
     category = models.ForeignKey(Category, verbose_name=_(u"Categoría"))
     manufacturer = models.ForeignKey(Manufacturer, verbose_name=_(u"Fabricante"))
     name = models.CharField(_(u"Nombre"), max_length=64, unique=True)
                           )
     
     class Meta:
-        ordering = ('name', )
+        ordering = ('order', 'name', )
         verbose_name = _(u"Producto")
         verbose_name_plural = _(u"Producto")