Skip to content
This repository
Browse code

Merge pull request #164 from elbaschid/master

changed reviews page for product (#57347) & minor fixes
  • Loading branch information...
commit 820c627368c753f3c6997f789dd79051b5bc4162 2 parents 4fcf7a2 + bb0202d
David Winterbottom authored May 03, 2012
30  oscar/templates/catalogue/detail.html
@@ -2,7 +2,6 @@
2 2
 
3 3
 {% load currency_filters %}
4 4
 {% load history_tags %}
5  
-{% load basket_tags %}
6 5
 
7 6
 {% block title %}
8 7
 {{ product.title }} | {{ block.super }}
@@ -29,11 +28,13 @@
29 28
 
30 29
 {% block content %}
31 30
 <article class="product_page"><!-- Start of product page -->
  31
+    {% if user.is_authenticated %}
32 32
     <div class="row-fluid">
33 33
         <div class="well">
34 34
             <a href="{% url dashboard:catalogue-product product.id %}"><button class="btn btn-success" value='Edit this product'>Edit this product</button></a>
35 35
         </div>
36 36
     </div>
  37
+    {% endif %}
37 38
     <div class="row-fluid">
38 39
         <div class="span6">
39 40
             {% include "catalogue/partials/gallery.html" %}
@@ -41,16 +42,7 @@
41 42
         <div class="span6">
42 43
             <h1>{{ product.get_title }}</h1>
43 44
             
44  
-            {% if product.is_group %}
45  
-                <h2 class="price_color">From {{ product.min_variant_price_incl_tax|currency }}</h2>
46  
-            {% else %}
47  
-                {% if product.has_stockrecord %} 
48  
-                    <h2 class="price_color">{{ product.stockrecord.price_incl_tax|currency }}</h2>
49  
-                    <p class="app-ico {{ product.stockrecord.availability_code }} avaliability ">{{ product.stockrecord.availability|truncatewords:2 }}</p>
50  
-                {% else %}
51  
-                    <p class="app-ico avaliability outofstock">Not available</p>
52  
-                {% endif %}
53  
-            {% endif %}
  45
+            {% include "catalogue/partials/stock_record.html" %}
54 46
             
55 47
             {% with product.reviews.all as reviews %}
56 48
                 {% if reviews %}
@@ -70,18 +62,8 @@ <h2 class="price_color">{{ product.stockrecord.price_incl_tax|currency }}</h2>
70 62
             <ul>
71 63
                 <li><a href="#product_description">Read the full description</a></li>
72 64
             </ul>
73  
-             
74  
-            {% if product.stockrecord and product.stockrecord.is_available_to_buy %}
75  
-            {% basket_form basket product as basket_form %}
76  
-            <form action="{% url basket:add %}" method="post" class="form-stacked">
77  
-                {% csrf_token %}
78  
-                {% include "partials/form_fields.html" with form=basket_form %}
79  
-            	
80  
-                <div class="form-actions">
81  
-                    <button type="submit" class="btn btn-large btn-primary" value="Add to basket">Add to basket</button>
82  
-                </div>
83  
-            </form>
84  
-            {% endif %}
  65
+
  66
+            {% include "catalogue/partials/add_to_basket_form.html" %}
85 67
         </div><!-- /span6 -->
86 68
     </div><!-- /row-fluid -->
87 69
               
@@ -235,8 +217,8 @@ <h3 class="star"><a href="{{ review.get_absolute_url }}">{{ review.title }} <spa
235 217
             </div>
236 218
         </div>
237 219
         {% endif %}
238  
-    </div>
239 220
     {% recently_viewed_products %}
  221
+    </div>
240 222
 </article><!-- End of product page -->
241 223
 {% endblock content %}
242 224
 
12  oscar/templates/catalogue/partials/add_to_basket_form.html
... ...
@@ -0,0 +1,12 @@
  1
+{% load basket_tags %}
  2
+{% if product.stockrecord and product.stockrecord.is_available_to_buy %}
  3
+    {% basket_form basket product as basket_form %}
  4
+    <form action="{% url basket:add %}" method="post" class="form-stacked">
  5
+        {% csrf_token %}
  6
+        {% include "partials/form_fields.html" with form=basket_form %}
  7
+
  8
+        <div class="form-actions">
  9
+            <button type="submit" class="btn btn-large btn-primary" value="Add to basket">Add to basket</button>
  10
+        </div>
  11
+    </form>
  12
+{% endif %}
101  oscar/templates/catalogue/partials/gallery.html
... ...
@@ -1,51 +1,54 @@
12  oscar/templates/catalogue/partials/stock_record.html
... ...
@@ -0,0 +1,12 @@
  1
+{% load currency_filters %}
  2
+
  3
+{% if product.is_group %}
  4
+    <h2 class="price_color">From {{ product.min_variant_price_incl_tax|currency }}</h2>
  5
+{% else %}
  6
+    {% if product.has_stockrecord %} 
  7
+        <h2 class="price_color">{{ product.stockrecord.price_incl_tax|currency }}</h2>
  8
+        <p class="app-ico {{ product.stockrecord.availability_code }} avaliability ">{{ product.stockrecord.availability|truncatewords:2 }}</p>
  9
+    {% else %}
  10
+        <p class="app-ico avaliability outofstock">Not available</p>
  11
+    {% endif %}
  12
+{% endif %}
165  oscar/templates/reviews/reviews.html
... ...
@@ -1,58 +1,113 @@
1  
-{% extends "catalogue/detail.html" %}
2  
-
3  
-{% block product_review %}
4  
-
5  
-<h3>All Reviews of {{ product.title }}</h3>
6  
-<p>Read customer reviews on this product. If you have read this book, why not post your own review?</p>
7  
-<p><a href="{% url catalogue:reviews-add product.slug product.id %}" class="btn btn-primary">Add a review</a></p>
8  
-
9  
-{% if reviews %}
10  
-	<h4> Sort by: </h4>
11  
-	<form action="." method="get">
12  
-        <select name="sort_by">
13  
-        	<option value="score">Score</option>
14  
-        	<option value="recency">Recency</option>
15  
-        </select>
16  
-        <input type="submit" value="Go" />             
17  
-    </form>
18  
-    
19  
-	{% for review in reviews %}
20  
-        <div class="review">
21  
-            <h4>{{ review.title }} ({{ review.score }}/5)</h4>
22  
-            <h5>Reviewed by {{ review.get_reviewer_name }}</h5>
23  
-            <p>{{ review.date_created }}<p>
24  
-            <p>{{ review.body|linebreaks }}</p>
25  
-            <p><a href="{{ review.get_absolute_url }}">Permalink</a>
26  
-            
27  
-			{% include 'reviews/_vote_bit.html' %}
28  
-	
29  
-            {% if review.has_votes %}
30  
-                <p>{{ review.num_up_votes }} customers agreed.</p>
  1
+{% extends "layout.html" %}
  2
+
  3
+{% load currency_filters %}
  4
+{% load history_tags %}
  5
+
  6
+{% block title %}
  7
+Reviews for {{ product.title }} | {{ block.super }}
  8
+{% endblock %}
  9
+
  10
+{% block breadcrumbs %}
  11
+<ul class="breadcrumb">
  12
+    <li>
  13
+        <a href="{% url promotions:home %}">Home</a>
  14
+        <span class="divider">/</span>
  15
+    </li>
  16
+    <li>
  17
+        {% with category=product.categories.all.0 %}
  18
+        <a href="{{ category.get_absolute_url }}">{{ category.name }}</a>
  19
+        <span class="divider">/</span>
  20
+        {% endwith %}
  21
+    </li>
  22
+    <li class="active"><a href=".">Reviews of {{ product.get_title }}</a></li>
  23
+</ul>
  24
+{% endblock %}
  25
+
  26
+{% block header %}
  27
+{% endblock header %}
  28
+
  29
+{% block content %}
  30
+
  31
+<article>
  32
+    <h1>All Reviews of {{ product.title }}</h1>
  33
+
  34
+    <div class="row-fluid">
  35
+        <div class='span9'>
  36
+            <div class="well">
  37
+                <p>Read customer reviews on this product. If you have read this book, why not post your own review?</p>
  38
+                <p><a href="{% url catalogue:reviews-add product.slug product.id %}" class="btn btn-primary">Add a review</a></p>
  39
+            </div>
  40
+            {% if reviews %}
  41
+            <h4> Sort by: </h4>
  42
+            <form action="." method="get">
  43
+                <select name="sort_by">
  44
+                        <option value="score">Score</option>
  45
+                        <option value="recency">Recency</option>
  46
+                </select>
  47
+                <input type="submit" value="Go" />
  48
+            </form>
  49
+
  50
+                {% for review in reviews %}
  51
+                <div class="review">
  52
+                    <h4>{{ review.title }} ({{ review.score }}/5)</h4>
  53
+                    <h5>Reviewed by {{ review.get_reviewer_name }}</h5>
  54
+                    <p>{{ review.date_created }}<p>
  55
+                    <p>{{ review.body|linebreaks }}</p>
  56
+                    <p><a href="{{ review.get_absolute_url }}">Permalink</a>
  57
+
  58
+                                {% include 'reviews/_vote_bit.html' %}
  59
+
  60
+                    {% if review.has_votes %}
  61
+                        <p>{{ review.num_up_votes }} customers agreed.</p>
  62
+                    {% endif %}
  63
+                </div>
  64
+                {% endfor %}
  65
+
  66
+            {% if page_obj %}
  67
+            <div class="pagination">
  68
+                <span class="step-links">
  69
+                    {% if page_obj.has_previous %}
  70
+                        <a href="?page={{ page_obj.previous_page_number }}">Previous</a>
  71
+                    {% endif %}
  72
+                    {% if paginator.num_pages > 1 %}
  73
+                    <span class="current">
  74
+                        Page {{ page_obj.number }} of {{ paginator.num_pages }}.
  75
+                    </span>
  76
+                    {% endif %}
  77
+                    {% if page_obj.has_next %}
  78
+                        <a href="?page={{ page_obj.next_page_number }}">Next</a>
  79
+                    {% endif %}
  80
+                </span>
  81
+            </div>
31 82
             {% endif %}
  83
+
  84
+        {% else %}
  85
+
  86
+        <p>This product does not have any reviews yet.</p>
  87
+
  88
+        {% endif %}
32 89
         </div>
33  
-    {% endfor %}
34  
-	
35  
-    {% if page_obj %}
36  
-    <div class="pagination">
37  
-        <span class="step-links">
38  
-            {% if page_obj.has_previous %}
39  
-                <a href="?page={{ page_obj.previous_page_number }}">Previous</a>
40  
-            {% endif %}
41  
-            {% if paginator.num_pages > 1 %}    
42  
-            <span class="current">
43  
-                Page {{ page_obj.number }} of {{ paginator.num_pages }}.
44  
-            </span>
45  
-            {% endif %}
46  
-            {% if page_obj.has_next %}
47  
-                <a href="?page={{ page_obj.next_page_number }}">Next</a>
48  
-            {% endif %}
49  
-        </span>
  90
+
  91
+        <div class="span3" style="text-align: center">
  92
+            <div class="thumbnail">
  93
+                {% with product.images.all.0 as image %}
  94
+                    {% if image %}
  95
+                        <a href="{{ image.original.url }}" rel="lightbox">
  96
+                            <img src="{{ image.original.url }}" data-large="{{ image.original.url }}" alt="image02" data-description="{% if image.caption %}{{ image.caption }}{% endif %}" />
  97
+                            </a>
  98
+                        {% else %}
  99
+                        <img src="/static/oscar/img/image_not_found.jpg" alt="No image found"/>
  100
+                    {% endif %}
  101
+                {% endwith %}
  102
+            </div>
  103
+            <div>
  104
+                <h2><a href="{{ product.get_absolute_url }}">{{ product.get_title }}</a></h2>
  105
+                {% include "catalogue/partials/stock_record.html" %}
  106
+                {% include "catalogue/partials/add_to_basket_form.html" %}
  107
+            </div>
  108
+        </div>
  109
+
  110
+        {% recently_viewed_products %}
50 111
     </div>
51  
-    {% endif %}
52  
-		
53  
-{% else %}
54  
-
55  
-<p>This product does not have any reviews yet.</p>        
56  
-        					
57  
-{% endif %}
58  
-{% endblock %}
  112
+</article>
  113
+{% endblock %}
11  oscar/templatetags/history_tags.py
@@ -13,9 +13,16 @@ def recently_viewed_products(context):
13 13
     """
14 14
     request = context['request']
15 15
     product_ids = history_helpers.get_recently_viewed_product_ids(request)
  16
+
  17
+    try:
  18
+        current_product = context.get('product', None)
  19
+        product_ids.remove(current_product.id)
  20
+    except (ValueError, AttributeError):
  21
+        pass
  22
+
16 23
     product_dict = product_models.Product.browsable.in_bulk(product_ids)
17  
-    
  24
+
18 25
     # Reordering as the id order gets messed up in the query
19 26
     product_ids.reverse()
20 27
     products = [product_dict[id] for id in product_ids if id in product_dict]
21  
-    return {'products': products}
  28
+    return {'products': products}
2  testing-reqs.txt
@@ -3,7 +3,7 @@ Werkzeug==0.6.2
3 3
 coverage==3.5.1
4 4
 django-debug-toolbar==0.9.4
5 5
 django-dynamic-fixture==1.4.2
6  
-django-extensions==0.5
  6
+django-extensions==0.8
7 7
 docutils==0.8.1
8 8
 flake8==0.8
9 9
 ipdb==0.2

0 notes on commit 820c627

Please sign in to comment.
Something went wrong with that request. Please try again.