Renamed BookSetsForm to ObjectSetsForm.
authorMarek Stępniowski <marek@stepniowski.com>
Fri, 5 Sep 2008 09:02:38 +0000 (11:02 +0200)
committerMarek Stępniowski <marek@stepniowski.com>
Fri, 5 Sep 2008 09:02:38 +0000 (11:02 +0200)
catalogue/forms.py
catalogue/views.py

index 583c9ae..279ec71 100644 (file)
@@ -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
         )
         
index de41e15..02e77c2 100644 (file)
@@ -174,7 +174,7 @@ def book_sets(request, slug):
         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))))
@@ -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(),