Tworzenie domyślnych katalogów current i previous w setup w fabfile.py.
[redakcja.git] / apps / api / forms.py
1 # -*- encoding: utf-8 -*-
2
3 __author__= "Łukasz Rekucki"
4 __date__ = "$2009-09-20 21:34:52$"
5 __doc__ = "Micro-forms for the API."
6
7
8 from django import forms
9
10
11 class MergeRequestForm(forms.Form):
12     # should the target document revision be updated or shared
13     type = forms.ChoiceField(choices=(('update', 'Update'), ('share', 'Share')) )
14
15     # which revision to update/share
16     target_revision = forms.RegexField('[0-9a-f]{40}')
17
18     # any additional comments that user wants to add to the change
19     message = forms.CharField(required=False)
20
21 class DocumentUploadForm(forms.Form):
22     ocr_file = forms.FileField(label='Source OCR file', required=False)
23     ocr_data = forms.CharField(widget=forms.HiddenInput(), required=False)
24     
25     bookname = forms.RegexField(regex=r'[0-9\.\w_-]+',  \
26         label='Publication name', help_text='Example: słowacki__beniowski__pieśń_1')
27     
28     generate_dc = forms.BooleanField(required=False, \
29         initial=True, label=u"Generate DublinCore template")
30
31
32     def clean(self):
33         clean_data = self.cleaned_data
34
35         ocr_file = clean_data['ocr_file']
36         ocr_data = clean_data['ocr_data']
37
38         if not ocr_file and not ocr_data:
39             raise forms.ValidationError(
40                 "You must either provide file descriptor or raw data." )
41
42         return clean_data