1
0
Fork 0

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.
master
MasterofJOKers 13 anos atrás
commit 9e2b0574ee

@ -8,26 +8,26 @@
<td class="productImage">
<a href="{% url buyable_show buyable.id %}"><img src="{% thumbnail buyable.image 64x64 %}"/></a>
</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 }}">
{% 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)">
<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)">
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>
<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>
</a>
{% else %}
<a class="button buy" href="/store/buy/{{ buyable.id }}"
<a class="button buy" href="{% url buyable_buy buyable.id %}"
title="Kaufen">
<span><span>{{ buyable.price|floatformat:2 }}€</span></span>
</a>

@ -3,8 +3,9 @@ from django.conf.urls.defaults import *
#/store/
urlpatterns = patterns('',
(r'^$', 'buyable.views.showItems'),
(r'^show/(\d+)/$', 'buyable.views.showItem'),
(r'^buy/(\d+)/(|with/deposit|only/deposit)/?$', 'buyable.views.buyItem'),
url(r'^show/(\d+)/$', 'buyable.views.showItem', name='buyable_show'),
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'^history/?$', 'buyable.views.history'),
)

@ -6,18 +6,18 @@
{% for buyable in buyables %}
<tr>
<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 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 }}">
{% 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 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" 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="{% 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 %}
<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 %}
{% 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 %}
</td>
</tr>

Carregando…
Cancelar
Salvar