trimming buttons on toolbar
[redakcja.git] / apps / catalogue / forms.py
index 33ccbe6..8cd00c2 100644 (file)
@@ -44,6 +44,8 @@ class DocumentsUploadForm(forms.Form):
         Form used for uploading new documents.
     """
     file = forms.FileField(required=True, label=_('ZIP file'))
         Form used for uploading new documents.
     """
     file = forms.FileField(required=True, label=_('ZIP file'))
+    dirs = forms.BooleanField(label=_('Directories are documents in chunks'),
+            widget = forms.CheckboxInput(attrs={'disabled':'disabled'}))
 
     def clean(self):
         file = self.cleaned_data['file']
 
     def clean(self):
         file = self.cleaned_data['file']
@@ -65,13 +67,19 @@ class ChunkForm(forms.ModelForm):
     """
     user = forms.ModelChoiceField(queryset=
         User.objects.annotate(count=Count('chunk')).
     """
     user = forms.ModelChoiceField(queryset=
         User.objects.annotate(count=Count('chunk')).
-        order_by('-count', 'last_name', 'first_name'))
-
+        order_by('-count', 'last_name', 'first_name'), required=False,
+        label=_('Assigned to')) 
 
     class Meta:
         model = Chunk
 
     class Meta:
         model = Chunk
+        fields = ['title', 'slug', 'user', 'stage']
         exclude = ['number']
 
         exclude = ['number']
 
+    def __init__(self, *args, **kwargs):
+        super(ChunkForm, self).__init__(*args, **kwargs)
+        self.fields['slug'].widget.attrs={'class': 'autoslug'}
+        self.fields['title'].widget.attrs={'class': 'autoslug-source'}
+
     def clean_slug(self):
         slug = self.cleaned_data['slug']
         try:
     def clean_slug(self):
         slug = self.cleaned_data['slug']
         try:
@@ -102,19 +110,37 @@ class BookAppendForm(forms.Form):
         Form for appending a book to another book.
         It means moving all chunks from book A to book B and deleting A.
     """
         Form for appending a book to another book.
         It means moving all chunks from book A to book B and deleting A.
     """
-
     append_to = forms.ModelChoiceField(queryset=Book.objects.all(),
     append_to = forms.ModelChoiceField(queryset=Book.objects.all(),
-        label=_("Append to"))
+            label=_("Append to"))
+
+    def __init__(self, book, *args, **kwargs):
+        ret =  super(BookAppendForm, self).__init__(*args, **kwargs)
+        self.fields['append_to'].queryset = Book.objects.exclude(pk=book.pk)
+        return ret
 
 
 class BookForm(forms.ModelForm):
 
 
 class BookForm(forms.ModelForm):
-    """
-        Form used for editing a Book.
-    """
+    """Form used for editing a Book."""
 
     class Meta:
         model = Book
 
 
     class Meta:
         model = Book
 
+    def __init__(self, *args, **kwargs):
+        ret = super(BookForm, self).__init__(*args, **kwargs)
+        self.fields['slug'].widget.attrs.update({"class": "autoslug"})
+        self.fields['title'].widget.attrs.update({"class": "autoslug-source"})
+        return ret
+
+
+class ReadonlyBookForm(BookForm):
+    """Form used for not editing a Book."""
+
+    def __init__(self, *args, **kwargs):
+        ret = super(ReadonlyBookForm, self).__init__(*args, **kwargs)
+        for field in self.fields.values():
+            field.widget.attrs.update({"readonly": True})
+        return ret
+
 
 class ChooseMasterForm(forms.Form):
     """
 
 class ChooseMasterForm(forms.Form):
     """