Affiche un cadre même si l'image est manquante (évite de cracher une exception du coup).
Modifie l'affichage des détails d'une carte. Affiche les sous-catégories en dessous d'une catégorie dans le menu de navigation. Modifie l'import pour prendre le lien sous-catégorie - catégorie en compte. Ajoute dans le fichier css/custom.css une classe pour aligner les images sur le texte à côté.
This commit is contained in:
parent
68918ab059
commit
85ac7f412a
|
@ -111,11 +111,14 @@ class Command(BaseCommand):
|
|||
i.country = country
|
||||
|
||||
category, created = Category.objects.get_or_create(label=item.category.strip())
|
||||
i.category = category
|
||||
#i.category = category
|
||||
|
||||
subcategory, created = SubCategory.objects.get_or_create(label=item.subcategory.strip())
|
||||
subcategory.category = category
|
||||
i.subcategory = subcategory
|
||||
|
||||
i.subcategory.save()
|
||||
|
||||
i.units = item.units
|
||||
i.label = item.label
|
||||
i.emissionDate = item.emissionDate
|
||||
|
|
|
@ -9,6 +9,7 @@ class Country(models.Model):
|
|||
|
||||
class Meta:
|
||||
verbose_name_plural ='Pays'
|
||||
verbose_name = 'Pays'
|
||||
|
||||
def __unicode__(self):
|
||||
return self.label
|
||||
|
@ -20,6 +21,7 @@ class Category(models.Model):
|
|||
|
||||
class Meta:
|
||||
verbose_name_plural ='Catégories'
|
||||
verbose_name = 'Catégorie'
|
||||
|
||||
def __unicode__(self):
|
||||
return self.label
|
||||
|
@ -28,18 +30,18 @@ class SubCategory(models.Model):
|
|||
label = models.CharField(verbose_name='Thème', unique=True, max_length=50)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
#category = models.ForeignKey(Category, verbose_name='Catégorie')
|
||||
category = models.ForeignKey(Category, verbose_name='Catégorie', null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural ='Thèmes'
|
||||
verbose_name = 'Thème'
|
||||
|
||||
def __unicode__(self):
|
||||
return self.label
|
||||
return self.category.label + ' - ' + self.label
|
||||
|
||||
class Item(models.Model):
|
||||
|
||||
country = models.ForeignKey(Country, verbose_name='Pays')
|
||||
category = models.ForeignKey(Category, verbose_name='Catégorie')
|
||||
subcategory = models.ForeignKey(SubCategory, verbose_name='Thème')
|
||||
label = models.CharField(verbose_name='Titre', max_length=50)
|
||||
image = models.ImageField(upload_to='pictures')
|
||||
|
@ -53,6 +55,7 @@ class Item(models.Model):
|
|||
|
||||
class Meta:
|
||||
verbose_name_plural ='Cartes de téléphone'
|
||||
verbose_name = 'Carte de téléphone'
|
||||
|
||||
def __unicode__(self):
|
||||
return '%s %s %s %s' % (self.country.label, self.category.label, self.subcategory.label, self.label)
|
||||
return '%s %s %s %s' % (self.country.label, self.subcategory.category.label, self.subcategory.label, self.label)
|
||||
|
|
|
@ -26,20 +26,25 @@ def details(request, item_id):
|
|||
def search_by_country(request, country_id, page_number):
|
||||
country = get_object_or_404(Country, pk=country_id)
|
||||
|
||||
context = { 'object' : country }
|
||||
context = { 'cards_list' : country.item_set.all(), 'title' : country.label }
|
||||
|
||||
return render_to_response('cards/list.html', RequestContext(request, context))
|
||||
|
||||
def search_by_category(request, category_id, page_number):
|
||||
country = get_object_or_404(Category, pk=category_id)
|
||||
category = get_object_or_404(Category, pk=category_id)
|
||||
|
||||
context = { 'object' : country }
|
||||
cards_list = list()
|
||||
|
||||
for subcat in category.subcategory_set.all():
|
||||
cards_list.extend(subcat.item_set.all())
|
||||
|
||||
context = { 'cards_list' : cards_list, 'title' : category.label }
|
||||
|
||||
return render_to_response('cards/list.html', RequestContext(request, context))
|
||||
|
||||
def search_by_subcategory(request, subcategory_id, page_number):
|
||||
country = get_object_or_404(SubCategory, pk=subcategory_id)
|
||||
subcategory = get_object_or_404(SubCategory, pk=subcategory_id)
|
||||
|
||||
context = { 'object' : country }
|
||||
context = { 'cards_list' : subcategory.item_set.all(), 'title' : subcategory.label }
|
||||
|
||||
return render_to_response('cards/list.html', RequestContext(request, context))
|
||||
return render_to_response('cards/list.html', RequestContext(request, context))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
body {
|
||||
|
||||
}
|
||||
.img-centered
|
||||
{
|
||||
vertical-align: middle;
|
||||
padding: 5px;
|
||||
}
|
||||
|
|
|
@ -9,14 +9,42 @@
|
|||
<div class="thumbnail">
|
||||
<img src="{{card.image|scale}}" alt="">
|
||||
</div>
|
||||
<table class="table table-bordered">
|
||||
|
||||
<ul>
|
||||
<li>{{card.country}}</li>
|
||||
<li>{{card.category}}</li>
|
||||
<li>{{card.subcategory}}</li>
|
||||
<li>{{card.with_chip}}</li>
|
||||
</ul>
|
||||
|
||||
<tr>
|
||||
<td>Pays</td>
|
||||
<td><a href="{% url list-by-country card.country.id 1 %}">{{card.country}}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Catégorie</td>
|
||||
<td><a href="{% url list-by-category card.subcategory.category.id 1 %}">{{card.subcategory.category.label}}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Thème</td>
|
||||
<td><a href="{% url list-by-subcategory card.subcategory.id 1 %}">{{card.subcategory.label}}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nombre d'unités</td>
|
||||
<td>{{card.units}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tirage</td>
|
||||
<td>{{card.numberOfCopies}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Puce</td>
|
||||
<td>{% if card.with_chip %}Oui{% else %}Non{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date d'émission</td>
|
||||
<td>{{card.emissiondate}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date d'expiration</td>
|
||||
<td>{{card.expirationdate}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Dernière mise-à-jour : {{card.updated_at}}</p>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
{% for card in cards_list %}
|
||||
<li class="span2">
|
||||
<a href="{% url card-details card.id %}" class="thumbnail">
|
||||
<img src="{{card.image|crop}}" />
|
||||
{% if card.image %}
|
||||
<img src="{{card.image|crop}}" />
|
||||
{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
|
@ -4,16 +4,18 @@
|
|||
|
||||
{% block main_container %}
|
||||
|
||||
<h2>{{object.label}}</h2>
|
||||
<h2>{{title}}</h2>
|
||||
|
||||
<ul class="thumbnails">
|
||||
{% for card in object.item_set.all %}
|
||||
{% for card in cards_list %}
|
||||
<li class="span2">
|
||||
<a href="{% url card-details card.id %}" class="thumbnail">
|
||||
{% if card.image %}
|
||||
<img src="{{card.image|crop}}" />
|
||||
{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
<script>
|
||||
|
||||
</script>
|
||||
|
||||
<div class="well" style="padding: 8px 0;">
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">
|
||||
|
@ -10,9 +14,15 @@
|
|||
Catégories
|
||||
</li>
|
||||
{% for cat in categories %}
|
||||
<li><a href="{% url list-by-category cat.id 1 %}">{{cat.label}}</a></li>
|
||||
<li><a href="{% url list-by-category cat.id 1 %}">{{cat.label}}</a>
|
||||
<ul class="nav nav-list">
|
||||
{% for subcat in cat.subcategory_set.all %}
|
||||
<li><a href="{% url list-by-subcategory subcat.id 1 %}">{{subcat.label}}</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li class="divider"></li>
|
||||
<li><a href="#"><i class="icon-book"></i>Recherche avancée</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue