Changed content of breadcrumbs in book_detail.html template.
authorMarek Stępniowski <marek@stepniowski.com>
Wed, 10 Sep 2008 15:26:16 +0000 (17:26 +0200)
committerMarek Stępniowski <marek@stepniowski.com>
Wed, 10 Sep 2008 15:26:16 +0000 (17:26 +0200)
Added main_page field to Tag model and used it to filter tags shown on main page.

apps/catalogue/models.py
apps/catalogue/views.py
wolnelektury/templates/catalogue/book_detail.html

index 7bddbbd..db19434 100644 (file)
@@ -38,8 +38,9 @@ class Tag(TagBase):
     sort_key = models.SlugField(_('sort key'), max_length=120, db_index=True)
     category = models.CharField(_('category'), max_length=50, blank=False, null=False, 
         db_index=True, choices=TAG_CATEGORIES)
-    description = models.TextField(blank=True)
-    
+    description = models.TextField(_('description'), blank=True)
+    main_page = models.BooleanField(_('main page'), default=False, db_index=True, help_text=_('Show tag on main page'))
+        
     user = models.ForeignKey(User, blank=True, null=True)
     
     def has_description(self):
index ad9bde7..64d0cde 100644 (file)
@@ -71,9 +71,9 @@ def tags_starting_with(request):
 
 def main_page(request):    
     if request.user.is_authenticated():
-        extra_where = '(NOT catalogue_tag.category = "set" OR catalogue_tag.user_id = %d)' % request.user.id
+        extra_where = '((NOT catalogue_tag.category = "set" AND catalogue_tag.main_page = 1) OR catalogue_tag.user_id = %d)' % request.user.id
     else:
-        extra_where = 'NOT catalogue_tag.category = "set"'
+        extra_where = 'NOT catalogue_tag.category = "set" AND catalogue_tag.main_page = 1'
     tags = models.Tag.objects.usage_for_model(models.Book, counts=True, extra={'where': [extra_where]})
     fragment_tags = models.Tag.objects.usage_for_model(models.Fragment, counts=True,
         extra={'where': ['catalogue_tag.category = "theme"']})
@@ -129,6 +129,7 @@ def book_detail(request, slug):
     tags = list(book.tags.filter(~Q(category='set')))
     categories = split_tags(tags)
     
+    form = forms.SearchForm()
     return render_to_response('catalogue/book_detail.html', locals(),
         context_instance=RequestContext(request))
 
index 332dd33..66a39f5 100644 (file)
 {% block body %}
     <h1>{{ book.title }}, {{ categories.author|join:", " }}</h1>
     <form action="{% url main_page %}" method="get" accept-charset="utf-8" id="search-form">
-        <ol>
-            {# {% for tag in tags %} #}
-            {# <li class="category"><a href="{% catalogue_url tag %}">{{ tag }}</a> | <a href="{% catalogue_url tags -tag %}">x</a></li> #}
-            {# {% endfor %} #}
-            <li class="book-title">{{ book.title }} | <a href="{% url main_page %}">x</a></li>
-        </ol>
+        <p>{{ form.q }} <input type="submit" value="Szukaj" /> <strong>lub</strong> <a href="{% url main_page %}">wróć do strony głównej</a></p>
     </form>
     
     <div id="books-list">