1 from django import forms
4 from librarian import dcparser
7 from explorer import models
10 class BookForm(forms.Form):
11 content = forms.CharField(widget=forms.Textarea)
12 commit_message = forms.CharField(required=False)
14 class BookUploadForm(forms.Form):
15 file = forms.FileField()
17 class ImageFoldersForm(forms.Form):
18 folders = forms.ChoiceField(required=False)
20 def __init__(self, *args, **kwargs):
21 super(ImageFoldersForm, self).__init__(*args, **kwargs)
22 self.fields['folders'].choices = [('', '-- Wybierz folder z obrazkami --')] + [(fn, fn) for fn in models.get_image_folders()]
25 class DublinCoreForm(forms.Form):
26 wiki_url = forms.URLField(verify_exists=False)
27 author = forms.CharField()
28 title = forms.CharField()
29 epoch = forms.CharField()
30 kind = forms.CharField()
31 genre = forms.CharField()
32 created_at = forms.DateField()
33 released_to_public_domain_at = forms.DateField()
34 translator = forms.CharField(required=False)
35 technical_editor = forms.CharField(required=False)
36 publisher = forms.CharField()
37 source_name = forms.CharField(widget=forms.Textarea)
38 source_url = forms.URLField(verify_exists=False)
39 url = forms.URLField(verify_exists=False)
40 parts = forms.CharField(widget=forms.Textarea, required=False)
41 license = forms.CharField(required=False)
42 license_description = forms.CharField(widget=forms.Textarea, required=False)
44 commit_message = forms.CharField(required=False)
46 def __init__(self, *args, **kwargs):
49 text = kwargs.pop('text')
51 super(DublinCoreForm, self).__init__(*args, **kwargs)
54 book_info = dcparser.BookInfo.from_string(text)
55 for name, value in book_info.to_dict().items():
56 self.fields[name].initial = value