From: Radek Czajka Date: Fri, 28 Jan 2011 12:15:29 +0000 (+0100) Subject: use proper commit id X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/5ef8e304790026b27417d8ff3c76c18858ba708f use proper commit id --- diff --git a/apps/wiki_img/forms.py b/apps/wiki_img/forms.py index 25f94138..bc9e2d6a 100644 --- a/apps/wiki_img/forms.py +++ b/apps/wiki_img/forms.py @@ -74,7 +74,7 @@ class DocumentTextSaveForm(forms.Form): """ id = forms.CharField(widget=forms.HiddenInput) - parent_revision = forms.IntegerField(widget=forms.HiddenInput) + parent_commit = forms.IntegerField(widget=forms.HiddenInput) text = forms.CharField(widget=forms.HiddenInput) author_name = forms.CharField( diff --git a/apps/wiki_img/views.py b/apps/wiki_img/views.py index c11549ab..c4d32b78 100644 --- a/apps/wiki_img/views.py +++ b/apps/wiki_img/views.py @@ -38,7 +38,7 @@ def text(request, slug): form = DocumentTextSaveForm(request.POST, prefix="textsave") if form.is_valid(): document = get_object_or_404(ImageDocument, slug=slug) - revision = form.cleaned_data['parent_revision'] + commit = form.cleaned_data['parent_commit'] comment = form.cleaned_data['comment'] @@ -48,7 +48,7 @@ def text(request, slug): user = None document.doc.commit( - parent=revision, + parent=commit, text=form.cleaned_data['text'], author=user, description=comment @@ -61,9 +61,10 @@ def text(request, slug): else: return JSONFormInvalid(form) else: - doc = get_object_or_404(ImageDocument, slug=slug) + doc = get_object_or_404(ImageDocument, slug=slug).doc return JSONResponse({ - 'text': doc.doc.materialize(), - 'revision': doc.doc.change_set.count() + 'text': doc.materialize(), + 'revision': doc.change_set.count(), + 'commit': doc.head.id, }) diff --git a/redakcja/static/js/wiki_img/dialog_save.js b/redakcja/static/js/wiki_img/dialog_save.js index aa9258d5..84f012c4 100644 --- a/redakcja/static/js/wiki_img/dialog_save.js +++ b/redakcja/static/js/wiki_img/dialog_save.js @@ -12,7 +12,7 @@ this.$form = $('form', element); $("input[name='textsave-id']", this.$form).val(CurrentDocument.id); - $("input[name='textsave-parent_revision']", this.$form).val(CurrentDocument.revision); + $("input[name='textsave-parent_commit']", this.$form).val(CurrentDocument.commit); $.wiki.cls.GenericDialog.call(this, element); }; diff --git a/redakcja/static/js/wiki_img/wikiapi.js b/redakcja/static/js/wiki_img/wikiapi.js index 2e4682c4..0990e604 100644 --- a/redakcja/static/js/wiki_img/wikiapi.js +++ b/redakcja/static/js/wiki_img/wikiapi.js @@ -60,6 +60,7 @@ this.id = meta.attr('data-document-name'); this.revision = $("*[data-key='revision']", meta).text(); + this.commit = $("*[data-key='commit']", meta).text(); this.readonly = !!$("*[data-key='readonly']", meta).text(); this.galleryLink = $("*[data-key='gallery']", meta).text(); @@ -83,17 +84,18 @@ $.ajax({ method: "GET", url: reverse("ajax_document_text", self.id), - data: {"revision": self.revision}, + data: {"commit": self.commit}, dataType: 'json', success: function(data) { var changed = false; - if (self.text === null || self.revision !== data.revision) { + if (self.text === null || self.commit !== data.commit) { self.text = data.text; if (self.text === '') { self.text = ''; } self.revision = data.revision; + self.commit = data.commit; changed = true; self.triggerDocumentChanged(); }; @@ -148,6 +150,7 @@ if (data.text) { self.text = data.text; self.revision = data.revision; + self.commit = data.commit; changed = true; self.triggerDocumentChanged(); };