Added main_page field to Tag model and used it to filter tags shown on main page.
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):
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"']})
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))
{% 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">