Added cards collections to main menu
This commit is contained in:
parent
c5b7faacf6
commit
fadd1f8329
|
@ -1,13 +1,16 @@
|
|||
# coding: utf-8
|
||||
|
||||
# amiibo
|
||||
from .models import Collection, AmiiboPrice
|
||||
from .models import Collection, AmiiboPrice, AmiiboCard
|
||||
|
||||
|
||||
def collections(request):
|
||||
return {
|
||||
'COLLECTIONS_FIGURES': Collection.objects.all().order_by('name_eu'),
|
||||
#: Collection.objects.filter(cards
|
||||
'COLLECTIONS_CARDS': Collection.objects.filter(pk__in=
|
||||
AmiiboCard.objects.all().distinct('collection').order_by('collection')\
|
||||
.values_list('collection__id', flat=True)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,11 +50,11 @@ class Collection(models.Model):
|
|||
|
||||
@property
|
||||
def figures(self):
|
||||
return self.amiibos_qs.all(type=Amiibo.FIGURE)
|
||||
return self.amiibos_qs.filter(type=Amiibo.FIGURE)
|
||||
|
||||
@property
|
||||
def cards(self):
|
||||
return self.amiibos_qs.all(type=Amiibo.FIGURE)
|
||||
return self.amiibos_qs.filter(type=Amiibo.CARD)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
# home
|
||||
from .views import (
|
||||
AmiiboView, AmiiboCardView, AmiiboFigureView,
|
||||
CollectionView
|
||||
CollectionView, CollectionCardView, CollectionFigureView
|
||||
)
|
||||
|
||||
urlpatterns = patterns(
|
||||
|
@ -16,10 +16,10 @@ urlpatterns = patterns(
|
|||
CollectionView.as_view(),
|
||||
name='collection'),
|
||||
url(_(r'^cards/(?P<collection>[\w\d\-]+)$'),
|
||||
CollectionView.as_view(),
|
||||
CollectionCardView.as_view(),
|
||||
name='cards-list'),
|
||||
url(_(r'^figures/(?P<collection>[\w\d\-]+)$'),
|
||||
CollectionView.as_view(),
|
||||
CollectionFigureView.as_view(),
|
||||
name='figures-list'),
|
||||
|
||||
url(_(r'^(?P<collection>[\w\d\-]+)/(?P<amiibo>[\w\d\-]+)$'),
|
||||
|
|
|
@ -21,7 +21,12 @@ class CollectionView(View):
|
|||
def get(self, request, collection='all'):
|
||||
if collection != _('all'):
|
||||
collection = get_object_or_404(Collection, slug=collection)
|
||||
amiibo_list = collection.amiibos
|
||||
if self.type == Amiibo.FIGURE:
|
||||
amiibo_list = collection.figures
|
||||
elif self.type == Amiibo.CARD:
|
||||
amiibo_list = collection.cards
|
||||
else:
|
||||
amiibo_list = collection.amiibo
|
||||
else:
|
||||
collection = None
|
||||
amiibo_list = Amiibo.objects.all().order_by('name_eu')
|
||||
|
@ -33,11 +38,11 @@ class CollectionView(View):
|
|||
})
|
||||
|
||||
|
||||
class FigureCollectionView(CollectionView):
|
||||
class CollectionFigureView(CollectionView):
|
||||
type = Amiibo.FIGURE
|
||||
|
||||
|
||||
class CardCollectionView(CollectionView):
|
||||
class CollectionCardView(CollectionView):
|
||||
type = Amiibo.CARD
|
||||
|
||||
|
||||
|
|
|
@ -42,19 +42,17 @@
|
|||
<a class="item" href="{{ col.get_absolute_url }}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% comment %}
|
||||
<div class="ui dropdown item">
|
||||
|
||||
</div>
|
||||
<div class="ui dropdown item">
|
||||
{% trans "Cards" %}
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="#">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_CARDS %}
|
||||
<a class="item" href="{{ col.get_absolute_url }}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
<a class="item" href="{% url 'amiibo:cards-list' all_word %}">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_CARDS %}
|
||||
<a class="item" href="{% url 'amiibo:cards-list' col.slug %}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="right menu"></div>
|
||||
{% endcomment %}
|
||||
</div>
|
||||
<div class="right menu">
|
||||
{% if user.is_authenticated %}
|
||||
|
@ -92,25 +90,20 @@
|
|||
<div class="ui item">
|
||||
<div class="text">{% trans 'Figures' %}</div>
|
||||
<div class="menu">
|
||||
<a class="item" href="{% url 'amiibo:collection' all_word %}">{% trans "All" %}</a>
|
||||
<div class="ui divider"></div>
|
||||
<a class="item" href="{% url 'amiibo:figures-list' all_word %}">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_FIGURES %}
|
||||
<a class="item" href="{{ col.get_absolute_url }}">{{ col.name }}</a>
|
||||
<a class="item" href="{% url 'amiibo:figures-list' col.slug %}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% comment %}
|
||||
<div class="ui dropdown item">
|
||||
{% trans "Cards" %}
|
||||
<i class="dropdown icon"></i>
|
||||
</div>
|
||||
<div class="ui item">
|
||||
<div class="text">{% trans "Cards" %}</div>
|
||||
<div class="menu">
|
||||
<a class="item" href="#">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_CARDS %}
|
||||
<a class="item" href="{{ col.get_absolute_url }}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
<a class="item" href="{% url 'amiibo:cards-list' all_word %}">{% trans "All" %}</a>
|
||||
{% for col in COLLECTIONS_CARDS %}
|
||||
<a class="item" href="{% url 'amiibo:cards-list' col.slug %}">{{ col.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="right menu"></div>
|
||||
{% endcomment %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue