fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Konwersja HTML do XML przed zapisaniem XML na serwer.
[redakcja.git]
/
apps
/
wiki
/
views.py
diff --git
a/apps/wiki/views.py
b/apps/wiki/views.py
index
339bde8
..
9a156a4
100644
(file)
--- a/
apps/wiki/views.py
+++ b/
apps/wiki/views.py
@@
-1,5
+1,6
@@
from django.views.generic.simple import direct_to_template
from django.views.generic.simple import direct_to_template
-from django.http import HttpResponseRedirect
+from django.http import HttpResponse
+from django.utils import simplejson as json
from wiki.models import storage, Document, DocumentNotFound
from wiki.forms import DocumentForm
from wiki.models import storage, Document, DocumentNotFound
from wiki.forms import DocumentForm
@@
-16,12
+17,15
@@
def document_detail(request, name, template_name='wiki/document_details.html'):
document = storage.get(name)
except DocumentNotFound:
document = Document(storage, name=name, text='')
document = storage.get(name)
except DocumentNotFound:
document = Document(storage, name=name, text='')
-
+
+
if request.method == 'POST':
form = DocumentForm(request.POST, instance=document)
if form.is_valid():
if request.method == 'POST':
form = DocumentForm(request.POST, instance=document)
if form.is_valid():
- form.save()
- return HttpResponseRedirect('/')
+ document = form.save()
+ return HttpResponse(json.dumps({'text': document.plain_text(), 'meta': document.meta(), 'revision': document.revision()}))
+ else:
+ return HttpResponse(json.dumps({'errors': form.errors}))
else:
form = DocumentForm(instance=document)
else:
form = DocumentForm(instance=document)