from catalogue import models
from catalogue import forms
from catalogue.utils import split_tags
from catalogue import models
from catalogue import forms
from catalogue.utils import split_tags
related_tags = models.Tag.objects.related_for_model(tags, model, counts=True, extra={'where': [extra_where]})
categories = split_tags(related_tags)
related_tags = models.Tag.objects.related_for_model(tags, model, counts=True, extra={'where': [extra_where]})
categories = split_tags(related_tags)
def book_sets(request, slug):
book = get_object_or_404(models.Book, slug=slug)
user_sets = models.Tag.objects.filter(category='set', user=request.user)
book_sets = book.tags.filter(category='set', user=request.user)
def book_sets(request, slug):
book = get_object_or_404(models.Book, slug=slug)
user_sets = models.Tag.objects.filter(category='set', user=request.user)
book_sets = book.tags.filter(category='set', user=request.user)
if form.is_valid():
book.tags = ([models.Tag.objects.get(pk=id) for id in form.cleaned_data['set_ids']] +
list(book.tags.filter(~Q(category='set') | ~Q(user=request.user))))
if request.is_ajax():
if form.is_valid():
book.tags = ([models.Tag.objects.get(pk=id) for id in form.cleaned_data['set_ids']] +
list(book.tags.filter(~Q(category='set') | ~Q(user=request.user))))
if request.is_ajax():
new_set_form = forms.NewSetForm()
return render_to_response('catalogue/book_sets.html', locals(),
new_set_form = forms.NewSetForm()
return render_to_response('catalogue/book_sets.html', locals(),