- nofootnotes = forms.BooleanField(required=False, label=_("Don't show footnotes"))
- nothemes = forms.BooleanField(required=False, label=_("Don't disply themes"))
- nowlfont = forms.BooleanField(required=False, label=_("Don't use our custom font"))
- ## pagesize = forms.ChoiceField(PDF_PAGE_SIZES, required=True, label=_("Paper size"))
- leading = forms.ChoiceField(PDF_LEADINGS, required=False, label=_("Leading"))
- fontsize = forms.ChoiceField(PDF_FONT_SIZES, required=True, label=_("Font size"))
+ def __init__(self, book, *args, **kwargs):
+ super(CustomPDFForm, self).__init__(*args, **kwargs)
+ self.book = book
+ for name, label in CUSTOMIZATION_FLAGS:
+ self.fields[name] = forms.BooleanField(required=False, label=label)
+ for name, label, choices in CUSTOMIZATION_OPTIONS:
+ self.fields[name] = forms.ChoiceField(choices, required=False, label=label)
+
+ def clean(self):
+ self.cleaned_data['cust'] = self.customizations
+ self.cleaned_data['path'] = get_customized_pdf_path(self.book,
+ self.cleaned_data['cust'])
+ if not WaitedFile.can_order(self.cleaned_data['path']):
+ raise ValidationError(_('Queue is full. Please try again later.'))
+ return self.cleaned_data