Browse Source

make some buyable urls accessible by name

Gives the advantage of only having to change the urls.py instead
of every link that has been set somewhere. This also verifies that
all parameters needed by the URL are given.
MasterofJOKers 10 years ago
parent
commit
9e2b0574ee

+ 5
- 5
k4ever/buyable/templates/buyables/product_list.html View File

@@ -8,26 +8,26 @@
8 8
 				<td class="productImage">
9 9
 					<a href="{% url buyable_show buyable.id %}"><img src="{% thumbnail buyable.image 64x64 %}"/></a>
10 10
 				</td>
11
-				<td class="name"><a href="/store/show/{{ buyable.id }}">{{ buyable.name }}</a></td>
11
+				<td class="name"><a href="{% url buyable_show buyable.id %}">{{ buyable.name }}</a></td>
12 12
 				<td class="actions" data-image="{% thumbnail buyable.image 48x48 %}" data-name="{{ buyable.name }}" data-id="{{ buyable.id }}">
13 13
 					{% if buyable.hasDeposit %}
14
-						<a class="button buy" href="/store/buy/{{ buyable.id }}"
14
+						<a class="button buy" href="{% url buyable_buy  buyable.id %}"
15 15
 							title="Kaufen (Ohne Pfand)">
16 16
 							<span><span>{{ buyable.price|floatformat:2 }}€</span></span>
17 17
 						</a>
18 18
 
19 19
 						<a class="button buy inclDeposit"
20
-							href="/store/buy/{{ buyable.id }}/with/deposit"	title="Kaufen (Mit Pfand)">
20
+							href="{% url buyable_buy buyable.id "with/deposit" %}"	title="Kaufen (Mit Pfand)">
21 21
 							<span><span>{{ buyable.price|floatformat:2 }}€ / {{ buyable.deposit|floatformat:2 }}€</span></span>
22 22
 						</a>
23 23
 
24 24
 						<a class="button buy onlyDeposit"
25
-							href="/store/buy/{{ buyable.id }}/only/deposit"	title="Kaufen (Nur Pfand)">
25
+							href="{% url buyable_buy buyable.id "only/deposit" %}"	title="Kaufen (Nur Pfand)">
26 26
 							<span><span>{{ buyable.deposit|floatformat:2 }}€</span></span>
27 27
 						</a>
28 28
 
29 29
 					{% else %}
30
-						<a class="button buy" href="/store/buy/{{ buyable.id }}"
30
+						<a class="button buy" href="{% url buyable_buy buyable.id %}"
31 31
 							title="Kaufen">
32 32
 							<span><span>{{ buyable.price|floatformat:2 }}€</span></span>
33 33
 						</a>

+ 3
- 2
k4ever/buyable/urls.py View File

@@ -3,8 +3,9 @@ from django.conf.urls.defaults import *
3 3
 #/store/
4 4
 urlpatterns = patterns('',
5 5
 	(r'^$', 'buyable.views.showItems'),
6
-	(r'^show/(\d+)/$', 'buyable.views.showItem'),
7
-	(r'^buy/(\d+)/(|with/deposit|only/deposit)/?$', 'buyable.views.buyItem'),
6
+	url(r'^show/(\d+)/$', 'buyable.views.showItem', name='buyable_show'),
7
+	url(r'^buy/(\d+)/$', 'buyable.views.buyItem', name='buyable_buy'),
8
+	url(r'^buy/(\d+)/(with/deposit|only/deposit)/$', 'buyable.views.buyItem', name='buyable_buy'),
8 9
 	(r'^bought/(\d+)/?$', 'buyable.views.boughtItem'),
9 10
 	(r'^history/?$', 'buyable.views.history'),
10 11
 )

+ 5
- 5
k4ever/main/templates/main/product_list.html View File

@@ -6,18 +6,18 @@
6 6
 		{% for buyable in buyables %}
7 7
 			<tr>
8 8
 				<td class="productImage">
9
-					<a href="/store/show/{{ buyable.id }}"><img src="{% thumbnail buyable.image 64x64 %}" /></a>
9
+					<a href="{% url buyable_show buyable.id %}"><img src="{% thumbnail buyable.image 64x64 %}" /></a>
10 10
 				</td>
11 11
 				<td class="name"><span>{{ buyable.name }}</span> {% if buyable.num_buys %}({{ buyable.num_buys }} mal gekauft){% endif %}</td>
12 12
 				<td class="actions" data-image="{% thumbnail buyable.image 48x48 %}" data-name="{{ buyable.name }}" data-id="{{ buyable.id }}">
13 13
 					{% if buyable.deposit > 0 %}
14
-						<a class="button buy" href="/store/buy/{{ buyable.id }}" title="Kaufen (Ohne Pfand)"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
15
-						<a class="button buy inclDeposit" href="/store/buy/{{ buyable.id }}/with/deposit" title="Kaufen (Mit Pfand)"><span><span>{{ buyable.price|floatformat:2 }}€ / {{ buyable.deposit|floatformat:2 }}€</span></span></a>
14
+						<a class="button buy" href="{% url buyable_buy buyable.id %}" title="Kaufen (Ohne Pfand)"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
15
+						<a class="button buy inclDeposit" href="{% url buyable_buy buyable.id "with/deposit" %}" title="Kaufen (Mit Pfand)"><span><span>{{ buyable.price|floatformat:2 }}€ / {{ buyable.deposit|floatformat:2 }}€</span></span></a>
16 16
 						{% if includeDeposit %}
17
-							<a class="button buy onlyDeposit" href="/store/buy/{{ buyable.id }}/only/deposit" title="Kaufen (Nur Pfand)"><span><span>{{ buyable.deposit|floatformat:2 }}€</span></span></a>
17
+							<a class="button buy onlyDeposit" href="{% url buyable_buy buyable.id "only/deposit" %}" title="Kaufen (Nur Pfand)"><span><span>{{ buyable.deposit|floatformat:2 }}€</span></span></a>
18 18
 						{% endif %}
19 19
 					{% else %}
20
-						<a class="button buy" href="/store/buy/{{ buyable.id }}" title="Kaufen"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
20
+						<a class="button buy" href="{% url buyable_buy buyable.id %}" title="Kaufen"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
21 21
 					{% endif %}
22 22
 				</td>
23 23
 			</tr>

Loading…
Cancel
Save