From: Marek Stępniowski Date: Wed, 10 Sep 2008 15:26:16 +0000 (+0200) Subject: Changed content of breadcrumbs in book_detail.html template. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/dbe845386fa136ccb8571e50dadb3c882661a59b Changed content of breadcrumbs in book_detail.html template. Added main_page field to Tag model and used it to filter tags shown on main page. --- diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 7bddbbd01..db194347e 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -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): diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index ad9bde747..64d0cde16 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -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)) diff --git a/wolnelektury/templates/catalogue/book_detail.html b/wolnelektury/templates/catalogue/book_detail.html index 332dd337e..66a39f548 100644 --- a/wolnelektury/templates/catalogue/book_detail.html +++ b/wolnelektury/templates/catalogue/book_detail.html @@ -27,12 +27,7 @@ {% block body %}

{{ book.title }}, {{ categories.author|join:", " }}

-
    - {# {% for tag in tags %} #} - {#
  1. {{ tag }} | x
  2. #} - {# {% endfor %} #} -
  3. {{ book.title }} | x
  4. -
+

{{ form.q }} lub wróć do strony głównej