From: Marek Stępniowski Date: Fri, 5 Sep 2008 09:02:38 +0000 (+0200) Subject: Renamed BookSetsForm to ObjectSetsForm. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/5761df5a5d4d40ba7c82e1b1277af30cedeb8306?ds=sidebyside;hp=77effa3964014b07dbdf73a9e67eb0b20749d50b Renamed BookSetsForm to ObjectSetsForm. --- diff --git a/catalogue/forms.py b/catalogue/forms.py index 583c9aed7..279ec7193 100644 --- a/catalogue/forms.py +++ b/catalogue/forms.py @@ -25,14 +25,14 @@ class UserSetsForm(forms.Form): ) -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 ) diff --git a/catalogue/views.py b/catalogue/views.py index de41e1518..02e77c2d4 100644 --- a/catalogue/views.py +++ b/catalogue/views.py @@ -174,7 +174,7 @@ def book_sets(request, slug): return HttpResponse('

Aby zarządzać swoimi półkami, musisz się zalogować.

') 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)))) @@ -183,7 +183,7 @@ def book_sets(request, slug): 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(),