use proper commit id
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 28 Jan 2011 12:15:29 +0000 (13:15 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 28 Jan 2011 12:15:29 +0000 (13:15 +0100)
apps/wiki_img/forms.py
apps/wiki_img/views.py
redakcja/static/js/wiki_img/dialog_save.js
redakcja/static/js/wiki_img/wikiapi.js

index 25f9413..bc9e2d6 100644 (file)
@@ -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(
index c11549a..c4d32b7 100644 (file)
@@ -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,
         })
 
index aa9258d..84f012c 100644 (file)
@@ -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);
        };
index 2e4682c..0990e60 100644 (file)
@@ -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();
                $.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 = '<obraz></obraz>';
                                        }
                                        self.revision = data.revision;
+                    self.commit = data.commit;
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
                                if (data.text) {
                                        self.text = data.text;
                                        self.revision = data.revision;
+                    self.commit = data.commit;
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };