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.
This commit is contained in:
parent
602c6585f8
commit
9e2b0574ee
|
@ -8,26 +8,26 @@
|
||||||
<td class="productImage">
|
<td class="productImage">
|
||||||
<a href="{% url buyable_show buyable.id %}"><img src="{% thumbnail buyable.image 64x64 %}"/></a>
|
<a href="{% url buyable_show buyable.id %}"><img src="{% thumbnail buyable.image 64x64 %}"/></a>
|
||||||
</td>
|
</td>
|
||||||
<td class="name"><a href="/store/show/{{ buyable.id }}">{{ buyable.name }}</a></td>
|
<td class="name"><a href="{% url buyable_show buyable.id %}">{{ buyable.name }}</a></td>
|
||||||
<td class="actions" data-image="{% thumbnail buyable.image 48x48 %}" data-name="{{ buyable.name }}" data-id="{{ buyable.id }}">
|
<td class="actions" data-image="{% thumbnail buyable.image 48x48 %}" data-name="{{ buyable.name }}" data-id="{{ buyable.id }}">
|
||||||
{% if buyable.hasDeposit %}
|
{% if buyable.hasDeposit %}
|
||||||
<a class="button buy" href="/store/buy/{{ buyable.id }}"
|
<a class="button buy" href="{% url buyable_buy buyable.id %}"
|
||||||
title="Kaufen (Ohne Pfand)">
|
title="Kaufen (Ohne Pfand)">
|
||||||
<span><span>{{ buyable.price|floatformat:2 }}€</span></span>
|
<span><span>{{ buyable.price|floatformat:2 }}€</span></span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="button buy inclDeposit"
|
<a class="button buy inclDeposit"
|
||||||
href="/store/buy/{{ buyable.id }}/with/deposit" title="Kaufen (Mit Pfand)">
|
href="{% url buyable_buy buyable.id "with/deposit" %}" title="Kaufen (Mit Pfand)">
|
||||||
<span><span>{{ buyable.price|floatformat:2 }}€ / {{ buyable.deposit|floatformat:2 }}€</span></span>
|
<span><span>{{ buyable.price|floatformat:2 }}€ / {{ buyable.deposit|floatformat:2 }}€</span></span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="button buy onlyDeposit"
|
<a class="button buy onlyDeposit"
|
||||||
href="/store/buy/{{ buyable.id }}/only/deposit" title="Kaufen (Nur Pfand)">
|
href="{% url buyable_buy buyable.id "only/deposit" %}" title="Kaufen (Nur Pfand)">
|
||||||
<span><span>{{ buyable.deposit|floatformat:2 }}€</span></span>
|
<span><span>{{ buyable.deposit|floatformat:2 }}€</span></span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="button buy" href="/store/buy/{{ buyable.id }}"
|
<a class="button buy" href="{% url buyable_buy buyable.id %}"
|
||||||
title="Kaufen">
|
title="Kaufen">
|
||||||
<span><span>{{ buyable.price|floatformat:2 }}€</span></span>
|
<span><span>{{ buyable.price|floatformat:2 }}€</span></span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -3,8 +3,9 @@ from django.conf.urls.defaults import *
|
||||||
#/store/
|
#/store/
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^$', 'buyable.views.showItems'),
|
(r'^$', 'buyable.views.showItems'),
|
||||||
(r'^show/(\d+)/$', 'buyable.views.showItem'),
|
url(r'^show/(\d+)/$', 'buyable.views.showItem', name='buyable_show'),
|
||||||
(r'^buy/(\d+)/(|with/deposit|only/deposit)/?$', 'buyable.views.buyItem'),
|
url(r'^buy/(\d+)/$', 'buyable.views.buyItem', name='buyable_buy'),
|
||||||
|
url(r'^buy/(\d+)/(with/deposit|only/deposit)/$', 'buyable.views.buyItem', name='buyable_buy'),
|
||||||
(r'^bought/(\d+)/?$', 'buyable.views.boughtItem'),
|
(r'^bought/(\d+)/?$', 'buyable.views.boughtItem'),
|
||||||
(r'^history/?$', 'buyable.views.history'),
|
(r'^history/?$', 'buyable.views.history'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
{% for buyable in buyables %}
|
{% for buyable in buyables %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="productImage">
|
<td class="productImage">
|
||||||
<a href="/store/show/{{ buyable.id }}"><img src="{% thumbnail buyable.image 64x64 %}" /></a>
|
<a href="{% url buyable_show buyable.id %}"><img src="{% thumbnail buyable.image 64x64 %}" /></a>
|
||||||
</td>
|
</td>
|
||||||
<td class="name"><span>{{ buyable.name }}</span> {% if buyable.num_buys %}({{ buyable.num_buys }} mal gekauft){% endif %}</td>
|
<td class="name"><span>{{ buyable.name }}</span> {% if buyable.num_buys %}({{ buyable.num_buys }} mal gekauft){% endif %}</td>
|
||||||
<td class="actions" data-image="{% thumbnail buyable.image 48x48 %}" data-name="{{ buyable.name }}" data-id="{{ buyable.id }}">
|
<td class="actions" data-image="{% thumbnail buyable.image 48x48 %}" data-name="{{ buyable.name }}" data-id="{{ buyable.id }}">
|
||||||
{% if buyable.deposit > 0 %}
|
{% if buyable.deposit > 0 %}
|
||||||
<a class="button buy" href="/store/buy/{{ buyable.id }}" title="Kaufen (Ohne Pfand)"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
|
<a class="button buy" href="{% url buyable_buy buyable.id %}" title="Kaufen (Ohne Pfand)"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
|
||||||
<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>
|
<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>
|
||||||
{% if includeDeposit %}
|
{% if includeDeposit %}
|
||||||
<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>
|
<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>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="button buy" href="/store/buy/{{ buyable.id }}" title="Kaufen"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
|
<a class="button buy" href="{% url buyable_buy buyable.id %}" title="Kaufen"><span><span>{{ buyable.price|floatformat:2 }}€</span></span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue