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
 
  11 class MergeRequestForm(forms.Form):
 
  12     # should the target document revision be updated or shared
 
  13     type = forms.ChoiceField(choices=(('update', 'Update'), ('share', 'Share')) )
 
  15     # which revision to update/share
 
  16     target_revision = forms.RegexField('[0-9a-f]{40}')
 
  18     # any additional comments that user wants to add to the change
 
  19     comment = forms.CharField(required=False)
 
  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)
 
  25     bookname = forms.RegexField(regex=r'[0-9\.\w_-]+',  \
 
  26         label='Publication name', help_text='Example: slowacki-beniowski')
 
  28     generate_dc = forms.BooleanField(required=False, \
 
  29         initial=True, label=u"Generate DublinCore template")
 
  33         clean_data = self.cleaned_data
 
  35         ocr_file = clean_data['ocr_file']
 
  36         ocr_data = clean_data['ocr_data']
 
  38         if not ocr_file and not ocr_data:
 
  39             raise forms.ValidationError(
 
  40                 "You must either provide file descriptor or raw data." )