Changed URL naming convention
This commit is contained in:
parent
78b642fe5d
commit
a2f0c004a9
|
@ -6,7 +6,9 @@ import os
|
|||
# django
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.utils.text import slugify
|
||||
|
||||
# 3rd party
|
||||
from amazonify import amazonify
|
||||
|
@ -49,7 +51,13 @@ class Collection(models.Model):
|
|||
|
||||
@models.permalink
|
||||
def get_absolute_url(self):
|
||||
return ('amiibo:figures-list', [self.slug])
|
||||
return ('amiibo:figures-list', (slugify(self.name), self.pk))
|
||||
|
||||
def get_absolute_url_figures(self):
|
||||
return reverse('amiibo:figures-list', args=(slugify(self.name), self.pk))
|
||||
|
||||
def get_absolute_url_cards(self):
|
||||
return reverse('amiibo:cards-list', args=(slugify(self.name), self.pk))
|
||||
|
||||
@property
|
||||
def amiibos(self):
|
||||
|
@ -153,7 +161,7 @@ class AmiiboFigure(Amiibo):
|
|||
|
||||
@models.permalink
|
||||
def get_absolute_url(self):
|
||||
return ('amiibo:figure-detail', [self.collection.slug, self.slug])
|
||||
return ('amiibo:figure-detail', [self.collection.slug, slugify(self.name), self.pk])
|
||||
|
||||
@property
|
||||
def image_box(self):
|
||||
|
@ -193,7 +201,8 @@ class AmiiboCard(Amiibo):
|
|||
|
||||
@models.permalink
|
||||
def get_absolute_url(self):
|
||||
return ('amiibo:card-detail', [self.collection.slug, self.slug])
|
||||
return ('amiibo:card-detail',
|
||||
[slugify(self.collection.name), slugify(self.name), self.pk])
|
||||
|
||||
def __unicode__(self):
|
||||
return u"{} {}".format(self.collection_number, self.slug)
|
||||
|
|
|
@ -20,17 +20,17 @@ urlpatterns = patterns(
|
|||
CollectionFigureView.as_view(),
|
||||
name='figures-all'),
|
||||
|
||||
url(_(r'^cards/(?P<collection>[\w\d\-]+)$'),
|
||||
url(_(r'^cards/(?P<dummy>[\w\d\-]+)?\-(?P<collection>\d+)$'),
|
||||
CollectionCardView.as_view(),
|
||||
name='cards-list'),
|
||||
url(_(r'^figures/(?P<collection>[\w\d\-]+)$'),
|
||||
url(_(r'^figures/(?P<dummy>[\w\d\-]+)?\-(?P<collection>\d+)$'),
|
||||
CollectionFigureView.as_view(),
|
||||
name='figures-list'),
|
||||
|
||||
url(_(r'^cards/(?P<collection>[\w\d\-]+)/(?P<amiibo>[\w\d\-]+)$'),
|
||||
url(_(r'^cards/(?P<collection>[\w\d\-]+)?/(?P<dummy>[\w\d\-]+)?-(?P<amiibo>[\w\d\-]+)$'),
|
||||
AmiiboCardView.as_view(),
|
||||
name='card-detail'),
|
||||
url(_(r'^figures/(?P<collection>[\w\d\-]+)/(?P<amiibo>[\w\d\-]+)$'),
|
||||
url(_(r'^figures/(?P<collection>[\w\d\-]+)?/(?P<dummy>[\w\d\-]+)?-(?P<amiibo>[\w\d\-]+)$'),
|
||||
AmiiboFigureView.as_view(),
|
||||
name='figure-detail'),
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ class CollectionView(View):
|
|||
type = Amiibo.FIGURE
|
||||
model = AmiiboFigure
|
||||
|
||||
def get(self, request, collection=None):
|
||||
def get(self, request, collection=None, dummy=None):
|
||||
if collection:
|
||||
collection = get_object_or_404(Collection, slug=collection)
|
||||
collection = get_object_or_404(Collection, pk=collection)
|
||||
if self.type == self.model.FIGURE:
|
||||
amiibo_list = collection.figures
|
||||
elif self.type == self.model.CARD:
|
||||
|
@ -52,10 +52,10 @@ class CollectionCardView(CollectionView):
|
|||
|
||||
|
||||
class AmiiboView(View):
|
||||
def get(self, request, collection=None, amiibo=None):
|
||||
def get(self, request, collection=None, amiibo=None, dummy=None):
|
||||
amiibo_obj = get_object_or_404(self.model,
|
||||
slug=amiibo,
|
||||
collection__slug=collection,
|
||||
pk=amiibo,
|
||||
# collection__slug=collection,
|
||||
type=self.type)
|
||||
|
||||
return render(request, self.template, {
|
||||
|
|
|
@ -7,8 +7,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-09-09 00:06+0200\n"
|
||||
"PO-Revision-Date: 2015-09-09 00:06+0200\n"
|
||||
"POT-Creation-Date: 2015-09-09 23:25+0200\n"
|
||||
"PO-Revision-Date: 2015-09-09 23:26+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: es\n"
|
||||
|
@ -27,20 +27,28 @@ msgid "^figures$"
|
|||
msgstr "^figuras$"
|
||||
|
||||
#: apps/amiibo/urls.py:23
|
||||
msgid "^cards/(?P<collection>[\\w\\d\\-]+)$"
|
||||
msgstr "^tarjetas/(?P<collection>[\\w\\d\\-]+)$"
|
||||
msgid "^cards/(?P<dummy>[\\w\\d\\-]+)?\\-(?P<collection>\\d+)$"
|
||||
msgstr "^tarjetas/(?P<dummy>[\\w\\d\\-]+)?\\-(?P<collection>\\d+)$"
|
||||
|
||||
#: apps/amiibo/urls.py:26
|
||||
msgid "^figures/(?P<collection>[\\w\\d\\-]+)$"
|
||||
msgstr "^figuras/(?P<collection>[\\w\\d\\-]+)/$"
|
||||
msgid "^figures/(?P<dummy>[\\w\\d\\-]+)?\\-(?P<collection>\\d+)$"
|
||||
msgstr "^figuras/(?P<dummy>[\\w\\d\\-]+)?\\-(?P<collection>\\d+)$"
|
||||
|
||||
#: apps/amiibo/urls.py:30
|
||||
msgid "^cards/(?P<collection>[\\w\\d\\-]+)/(?P<amiibo>[\\w\\d\\-]+)$"
|
||||
msgstr "^tarjetas/(?P<collection>[\\w\\d\\-]+)/(?P<amiibo>[\\w\\d\\-]+)$"
|
||||
msgid ""
|
||||
"^cards/(?P<collection>[\\w\\d\\-]+)?/(?P<dummy>[\\w\\d\\-]+)?-(?P<amiibo>[\\w"
|
||||
"\\d\\-]+)$"
|
||||
msgstr ""
|
||||
"^tarjetas/(?P<collection>[\\w\\d\\-]+)?/(?P<dummy>[\\w\\d\\-]+)?-(?"
|
||||
"P<amiibo>[\\w\\d\\-]+)$"
|
||||
|
||||
#: apps/amiibo/urls.py:33
|
||||
msgid "^figures/(?P<collection>[\\w\\d\\-]+)/(?P<amiibo>[\\w\\d\\-]+)$"
|
||||
msgstr "^figuras/(?P<collection>[\\w\\d\\-]+)/(?P<amiibo>[\\w\\d\\-]+)$"
|
||||
msgid ""
|
||||
"^figures/(?P<collection>[\\w\\d\\-]+)?/(?P<dummy>[\\w\\d\\-]+)?-(?"
|
||||
"P<amiibo>[\\w\\d\\-]+)$"
|
||||
msgstr ""
|
||||
"^figuras/(?P<collection>[\\w\\d\\-]+)?/(?P<dummy>[\\w\\d\\-]+)?-(?"
|
||||
"P<amiibo>[\\w\\d\\-]+)$"
|
||||
|
||||
#: apps/amiibo/urls.py:37
|
||||
msgid "^amiibo/(?P<amiibo>\\d+)/(?P<action>[\\w\\+\\-\\=]+)$"
|
||||
|
@ -121,7 +129,11 @@ msgstr "Registrarse"
|
|||
msgid "Select desired currency"
|
||||
msgstr "Seleccionar moneda"
|
||||
|
||||
#: templates/_layout.html:134
|
||||
#: templates/_layout.html:131
|
||||
msgid "No convert"
|
||||
msgstr "Sin conversión"
|
||||
|
||||
#: templates/_layout.html:135
|
||||
msgid "Language"
|
||||
msgstr "Idioma"
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<a class="item" href="{% url 'amiibo:figures-all' %}">{% trans "All" %}</a>
|
||||
<div class="ui divider"></div>
|
||||
{% for col in COLLECTIONS_FIGURES %}
|
||||
<a class="item" href="{{ col.get_absolute_url }}">{{ col.name }}</a>
|
||||
<a class="item" href="{{ col.get_absolute_url_figures }}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
|||
<div class="menu">
|
||||
<a class="item" href="{% url 'amiibo:cards-all' %}">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_CARDS %}
|
||||
<a class="item" href="{% url 'amiibo:cards-list' col.slug %}">{{ col.name }}</a>
|
||||
<a class="item" href="{{ col.get_absolute_url_cards }}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -88,7 +88,7 @@
|
|||
<div class="menu">
|
||||
<a class="item" href="{% url 'amiibo:figures-all' %}">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_FIGURES %}
|
||||
<a class="item" href="{% url 'amiibo:figures-list' col.slug %}">{{ col.name }}</a>
|
||||
<a class="item" href="{{ col.get_absolute_url_figures }}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -97,7 +97,7 @@
|
|||
<div class="menu">
|
||||
<a class="item" href="{% url 'amiibo:cards-all' %}">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_CARDS %}
|
||||
<a class="item" href="{% url 'amiibo:cards-list' col.slug %}">{{ col.name }}</a>
|
||||
<a class="item" href="{{ col.get_absolute_url_cards }}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue