[Oi-commits] r1543 - in trunk/shop: . product product/templatetags templates

oi-commits at pardus.org.tr oi-commits at pardus.org.tr
Tue Jul 15 20:33:44 EEST 2008


Author: erenturkay
Date: Tue Jul 15 20:33:44 2008
New Revision: 1543

Modified:
   trunk/shop/TODO
   trunk/shop/product/models.py
   trunk/shop/product/templatetags/shop_library.py
   trunk/shop/templates/shop_base.html
   trunk/shop/templates/shop_main.html
Log:
* add ProductImage class
* make category_tree show how many products a category have, e.g: Thirts (2)

Modified: trunk/shop/TODO
=================================================================
--- trunk/shop/TODO	(original)
+++ trunk/shop/TODO	Tue Jul 15 20:33:44 2008
@@ -8,14 +8,18 @@
 / In progress
 + Completed
 
+
+- Specific thumbnail field for image adding. (ImageWithThumbnail)
+
 [*] Category
-    / Image with thumbnail support for each category
-    - Show how many products a category have in the category tree. E.g: T-shirts (14)
+    + Image for each category
+    + Show how many products a category have in the category tree. E.g: T-shirts (14)
+    - Product listing for each category
 
 
 [*] Product
-    - Create Product class, damn?!
-    - Make sure that product can have more than 1 picture. Also, these should be with thumbnail support
+    + Create Product class, damn?!
+    + Make sure that product can have more than 1 picture.
 
 [*] User
     - Don't forget to control user's bill information as bill class doesn't have any check.

Modified: trunk/shop/product/models.py
=================================================================
--- trunk/shop/product/models.py	(original)
+++ trunk/shop/product/models.py	Tue Jul 15 20:33:44 2008
@@ -151,6 +151,37 @@
         list_display = ("title", "percentage",)
         search_fields = ['title']
 
+######################################################
+#                                                    #
+# Image class for all Products.                      #
+# There is a code repeat but I can't think better :P #
+#                                                    #
+######################################################
+
+class ProductImages(models.Model):
+    """ This class has no Meta and Admin class because it's edited inline on related object's page """
+    product = models.ForeignKey("Product", blank=True, null=True, edit_inline=models.TABULAR, num_in_admin=3, max_num_in_admin=3, related_name="images")
+    picture = models.ImageField(verbose_name="Ürün Resmi", upload_to="upload/image/")
+    keep = models.BooleanField(default=True, editable=False, core=True)
+    # we use remove since we don't have admin interface for editing CategoryImage.
+    # It's edited inline on the related model page, when remove is checked, we will just delete the entry.
+    remove = models.BooleanField(default=False)
+
+    def __unicode__(self):
+        return u'"%s" ürün resmi' % self.product.name
+
+    def save(self):
+        # Picture value is always set. When you add new Category without images,
+        # it just saves as blank. So prevent adding useless images.
+
+        # new entry.
+        if not self.id and not self.picture:
+            return
+        if self.remove:
+            self.delete()
+        else:
+            super(CategoryImages, self).save()
+
 ############################################################
 #                                                          #
 # Main product class, it can have a child product model    #

Modified: trunk/shop/product/templatetags/shop_library.py
=================================================================
--- trunk/shop/product/templatetags/shop_library.py	(original)
+++ trunk/shop/product/templatetags/shop_library.py	Tue Jul 15 20:33:44 2008
@@ -24,7 +24,7 @@
         if current_node == active_cat:
             attrs["class"] = "current"
         link = SubElement(temp_parent, 'a', attrs)
-        link.text = current_node.name
+        link.text = "%s (%s)" % (current_node.name, current_node.product_set.count())
 
         if child_count > 0:
             new_parent = SubElement(temp_parent, 'ul')

Modified: trunk/shop/templates/shop_base.html
=================================================================
--- trunk/shop/templates/shop_base.html	(original)
+++ trunk/shop/templates/shop_base.html	Tue Jul 15 20:33:44 2008
@@ -2,7 +2,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<title>{% block title %}{% endblock %}Özgürlük için...</title>
+<title>{% block title %}{% endblock %} - Özgürlük için...</title>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <meta http-equiv="imagetoolbar" content="no" />
 <link rel="shortcut icon" href="/media/img/fav.png" />

Modified: trunk/shop/templates/shop_main.html
=================================================================
--- trunk/shop/templates/shop_main.html	(original)
+++ trunk/shop/templates/shop_main.html	Tue Jul 15 20:33:44 2008
@@ -1,6 +1,6 @@
 {% extends "shop_base.html" %}
 
-{% block title %}Dükkan - {% endblock %}
+{% block title %}Dükkan{% endblock %}
 
 {% block header_menu %}
     {% include "header.html" %}


More information about the Oi-commits mailing list