1 # -*- encoding: utf-8 -*-
3 __author__= "Ćukasz Rekucki"
4 __date__ = "$2009-09-20 21:34:52$"
5 __doc__ = "Micro-forms for the API."
8 from django import forms
10 class DocumentEntryRequest(forms.Form):
11 revision = forms.RegexField(regex='latest|[0-9a-f]{40}')
13 class DocumentUploadForm(forms.Form):
14 ocr_file = forms.FileField(label='Source OCR file', required=False)
15 ocr_data = forms.CharField(widget=forms.HiddenInput(), required=False)
17 bookname = forms.RegexField(regex=r'[0-9\.\w_-]+', \
18 label='Publication name', help_text='Example: slowacki-beniowski')
20 generate_dc = forms.BooleanField(required=False, \
21 initial=True, label=u"Generate DublinCore template")
25 clean_data = self.cleaned_data
27 ocr_file = clean_data['ocr_file']
28 ocr_data = clean_data['ocr_data']
30 if not ocr_file and not ocr_data:
31 raise forms.ValidationError(
32 "You must either provide file descriptor or raw data." )