X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/b2d72160e2a68991c66ea6017b871d7f42c0b29d..39f73cadff6a44915f4c59985076be1acda652ed:/apps/api/forms.py?ds=inline diff --git a/apps/api/forms.py b/apps/api/forms.py index 2b09e178..d55e6291 100644 --- a/apps/api/forms.py +++ b/apps/api/forms.py @@ -7,14 +7,36 @@ __doc__ = "Micro-forms for the API." from django import forms -class DocumentGetForm(forms.Form): - autocabinet = forms.BooleanField(required=False) +class MergeRequestForm(forms.Form): + # should the target document revision be updated or shared + type = forms.ChoiceField(choices=(('update', 'Update'), ('share', 'Share')) ) + + # which revision to update/share + target_revision = forms.RegexField('[0-9a-f]{40}') + + # any additional comments that user wants to add to the change + message = forms.CharField(required=False) class DocumentUploadForm(forms.Form): - ocr = forms.FileField(label='Source OCR file') + ocr_file = forms.FileField(label='Source OCR file', required=False) + ocr_data = forms.CharField(widget=forms.HiddenInput(), required=False) + bookname = forms.RegexField(regex=r'[0-9\.\w_-]+', \ - label='Publication name', help_text='Example: slowacki-beniowski') + label='Publication name', help_text='Example: słowacki__beniowski__pieśń_1') - generate_dc = forms.BooleanField(required=False, initial=True, label=u"Generate DublinCore template") + generate_dc = forms.BooleanField(required=False, \ + initial=True, label=u"Generate DublinCore template") + + + def clean(self): + clean_data = self.cleaned_data + + ocr_file = clean_data['ocr_file'] + ocr_data = clean_data['ocr_data'] + + if not ocr_file and not ocr_data: + raise forms.ValidationError( + "You must either provide file descriptor or raw data." ) + return clean_data \ No newline at end of file