X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/25880e3bcf289743113655c7ec2fff4fd1587c2f..20bd2492d8bd211816c5120595b19a0a828b9f0c:/apps/explorer/forms.py?ds=sidebyside diff --git a/apps/explorer/forms.py b/apps/explorer/forms.py index e648aa5f..aa6b48a6 100644 --- a/apps/explorer/forms.py +++ b/apps/explorer/forms.py @@ -5,11 +5,12 @@ from librarian import dcparser from explorer import models - class BookForm(forms.Form): - text = forms.CharField(widget=forms.Textarea) - commit_message = forms.CharField() - user = forms.CharField() + content = forms.CharField(widget=forms.Textarea) + commit_message = forms.CharField(required=False) + +class BookUploadForm(forms.Form): + file = forms.FileField() class ImageFoldersForm(forms.Form): folders = forms.ChoiceField(required=False) @@ -51,7 +52,7 @@ class DublinCoreForm(forms.Form): self.fields[name].initial = value def save(self, repository, path): - file_contents = repository.get_file(path).data() + file_contents = repository.get_file(path) doc = etree.fromstring(file_contents) book_info = dcparser.BookInfo() @@ -63,5 +64,5 @@ class DublinCoreForm(forms.Form): old_rdf = doc.getroottree().find('//{http://www.w3.org/1999/02/22-rdf-syntax-ns#}RDF') old_rdf.getparent().remove(old_rdf) doc.insert(0, rdf) - repository.add_file(path, unicode(etree.tostring(doc), 'utf-8')) + repository.add_file(path, etree.tostring(doc, pretty_print=True, encoding=unicode))