)
-class BookSetsForm(forms.Form):
- def __init__(self, book, user, *args, **kwargs):
- super(BookSetsForm, self).__init__(*args, **kwargs)
+class ObjectSetsForm(forms.Form):
+ def __init__(self, obj, user, *args, **kwargs):
+ super(ObjectSetsForm, self).__init__(*args, **kwargs)
self.fields['set_ids'] = forms.MultipleChoiceField(
label=u'Półki',
required=False,
choices=[(tag.id, tag.name) for tag in Tag.objects.filter(category='set', user=user)],
- initial=[tag.id for tag in book.tags.filter(category='set', user=user)],
+ initial=[tag.id for tag in obj.tags.filter(category='set', user=user)],
widget=forms.CheckboxSelectMultiple
)
return HttpResponse('<p>Aby zarządzać swoimi półkami, musisz się zalogować.</p>')
if request.method == 'POST':
- form = forms.BookSetsForm(book, request.user, request.POST)
+ form = forms.ObjectSetsForm(book, request.user, request.POST)
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))))
else:
return HttpResponseRedirect('/')
else:
- form = forms.BookSetsForm(book, request.user)
+ form = forms.ObjectSetsForm(book, request.user)
new_set_form = forms.NewSetForm()
return render_to_response('catalogue/book_sets.html', locals(),