Delete categories and themes from display and from admin

This commit is contained in:
Fred Pauchet 2012-09-03 17:11:59 +02:00
parent 172b7fbaad
commit dd74b6b87f
7 changed files with 22 additions and 31 deletions

View File

@ -1,8 +1,10 @@
from cards.models import *
from django.contrib import admin
admin.site.register(Category)
admin.site.register(SubCategory)
admin.site.register(Country)
admin.site.register(Tag)
admin.site.register(Card)
class CardAdmin(admin.ModelAdmin):
exclude = ['subcategory']
admin.site.register(Card, CardAdmin)

View File

@ -4,7 +4,6 @@ from django.core.management.base import BaseCommand, CommandError
from django.core.files import File
from xcards.cards.models import *
import os
from lxml import etree
class Command(BaseCommand):
help = 'Import data from an xml file generated by gc-star'

View File

@ -5,8 +5,7 @@ from cards.models import Country, Category
register = template.Library()
def nav_menu():
categories = Category.objects.all().order_by('label')
countries = Country.objects.all().order_by('label')
return { 'countries' : countries, 'categories' : categories }
return { 'countries' : countries }
register.inclusion_tag('nav_menu.html')(nav_menu)
register.inclusion_tag('nav_menu.html')(nav_menu)

View File

@ -6,7 +6,7 @@ from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django import forms
from cards.models import Card, Country, Category, SubCategory
from cards.models import Card, Country, Tag
from django.core.context_processors import csrf
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
@ -119,6 +119,17 @@ def search_by_country(request, country_id):
return render_to_response('cards/list.html', RequestContext(request, context))
def search_by_tag(request, tag_id):
tag = get_object_or_404(Tag, pk=tag_id)
cards_list = tag.card_set.all()
cards = pagination(cards_list, request)
context = { 'cards' : cards, 'title' : tag.label }
return render_to_response('cards/list.html', RequestContext(request, context))
def search_by_category(request, category_id):
category = get_object_or_404(Category, pk=category_id)

View File

@ -17,14 +17,6 @@
<td>Pays</td>
<td><a href="{% url list-by-country card.country.id %}">{{card.country}}</a></td>
</tr>
<tr>
<td>Catégorie</td>
<td><a href="{% url list-by-category card.subcategory.category.id %}">{{card.subcategory.category.label}}</a></td>
</tr>
<tr>
<td>Thème</td>
<td><a href="{% url list-by-subcategory card.subcategory.id %}">{{card.subcategory.label}}</a></td>
</tr>
<tr>
<td>Nombre d'unités</td>
<td>{{card.units}}</td>
@ -48,9 +40,9 @@
<tr>
<td>Tags</td>
<td>
<ul>
<ul>
{% for tag in card.tags.all %}
<li>{{tag.label}}</li>
<li><a href="{% url list-by-tag tag.id %}">{{ tag.label }}</a></li>
{% endfor %}
</ul>
</td>

View File

@ -19,18 +19,5 @@
{% for country in countries %}
<li><a href="{% url list-by-country country.id %}">{{country.label}}</a>
{% endfor %}
<li class="nav-header">
Catégories
</li>
{% for cat in categories %}
<li><a href="{% url list-by-category cat.id %}">{{cat.label}}</a>
<ul class="nav nav-list">
{% for subcat in cat.subcategory_set.all %}
<li><a href="{% url list-by-subcategory subcat.id %}">{{subcat.label}}</a>
{% endfor %}
</ul>
</li>
{% endfor %}
<li class="divider"></li>
</ul>
</div>

View File

@ -16,6 +16,7 @@ urlpatterns = patterns('',
url(r'^list/country/(?P<country_id>\d+)/$', 'cards.views.search_by_country', name='list-by-country'),
url(r'^list/category/(?P<category_id>\d+)/$', 'cards.views.search_by_category', name='list-by-category'),
url(r'^list/subcategory/(?P<subcategory_id>\d+)/$', 'cards.views.search_by_subcategory', name='list-by-subcategory'),
url(r'^list/tag/(?P<tag_id>\d+)/$', 'cards.views.search_by_tag', name='list-by-tag'),
url(r'^map/$', 'osm.views.map', name='map'),