X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/f734261e68dc171da98aabe700e170c3ede3b6a5..0fd55a38c4873d5916a3553d7510b9308f4eee6d:/apps/wiki/forms.py diff --git a/apps/wiki/forms.py b/apps/wiki/forms.py index 836d8f0d..db5998de 100644 --- a/apps/wiki/forms.py +++ b/apps/wiki/forms.py @@ -1,12 +1,11 @@ from django import forms -from wiki.models import Document, storage +from wiki.models import Document, getstorage class DocumentForm(forms.Form): name = forms.CharField(widget=forms.HiddenInput) text = forms.CharField(widget=forms.Textarea) revision = forms.IntegerField(widget=forms.HiddenInput) - author = forms.CharField() comment = forms.CharField() def __init__(self, *args, **kwargs): @@ -16,13 +15,16 @@ class DocumentForm(forms.Form): self.fields['name'].initial = document.name self.fields['text'].initial = document.text self.fields['revision'].initial = document.revision() - - def get_storage(self): - return storage - - def save(self): - document = Document(self.get_storage(), name=self.cleaned_data['name'], text=self.cleaned_data['text']) - storage.put(document, self.cleaned_data['author'], self.cleaned_data['comment'], - self.cleaned_data['revision']) + + def save(self, document_author = 'anonymous'): + storage = getstorage() + + document = Document(storage, name=self.cleaned_data['name'], text=self.cleaned_data['text']) + + storage.put(document, + author = document_author, + comment = self.cleaned_data['comment'], + parent =self.cleaned_data['revision'] ) + return storage.get(self.cleaned_data['name'])