From: Łukasz Rekucki
Date: Thu, 15 Oct 2009 17:55:09 +0000 (+0200)
Subject: Naprawiony Merge/Update i zmienione nazwy na Push/Pull co bardziej odpowiada działania.
X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/020ad779bc86249cd11cb8aa4970420b16789f55
Naprawiony Merge/Update i zmienione nazwy na Push/Pull co bardziej odpowiada działania.
---
diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py
index be504e90..2b1edb21 100644
--- a/apps/api/handlers/library_handlers.py
+++ b/apps/api/handlers/library_handlers.py
@@ -261,8 +261,8 @@ class DocumentHandler(BaseHandler):
# 'dc_url': reverse('docdc_view', args=[doc.id]),
'gallery_url': reverse('docgallery_view', args=[doc.id]),
'merge_url': reverse('docmerge_view', args=[doc.id]),
- 'user_revision': doc.revision,
- 'user_timestamp': doc.revision.timestamp,
+ 'revision': doc.revision,
+ 'timestamp': doc.revision.timestamp,
# 'public_revision': doc.revision,
# 'public_timestamp': doc.revision.timestamp,
}
@@ -691,9 +691,16 @@ class MergeHandler(BaseHandler):
return response.SuccessAllOk().django_response({
"name": user_doc_new.id,
"user": user_doc_new.owner,
- "parent_revision": user_doc_new.revision,
- "parent_shared_revision": doc.revision,
+
"revision": user_doc_new.revision,
- "shared_revision": doc_new.revision,
'timestamp': user_doc_new.revision.timestamp,
+
+ "parent_revision": user_doc_new.revision,
+ "parent_timestamp": user_doc_new.revision.timestamp,
+
+ "shared_revision": doc_new.revision,
+ "shared_timestamp": doc_new.revision.timestamp,
+
+ "shared_parent_revision": doc.revision,
+ "shared_parent_timestamp": doc.revision.timestamp,
})
\ No newline at end of file
diff --git a/apps/explorer/admin.py b/apps/explorer/admin.py
index 1c91b963..10c3e79a 100644
--- a/apps/explorer/admin.py
+++ b/apps/explorer/admin.py
@@ -1,5 +1,4 @@
from django.contrib import admin
-from django.utils.translation import ugettext_lazy as _
import explorer.models
diff --git a/platforma/static/js/models.js b/platforma/static/js/models.js
index 6399c037..fe42e895 100644
--- a/platforma/static/js/models.js
+++ b/platforma/static/js/models.js
@@ -393,7 +393,7 @@ Editor.ImageGalleryModel = Editor.Model.extend({
Editor.DocumentModel = Editor.Model.extend({
_className: 'Editor.DocumentModel',
- data: null, // name, text_url, user_revision, latest_shared_rev, parts_url, dc_url, size, merge_url
+ data: null, // name, text_url, revision, latest_shared_rev, parts_url, dc_url, size, merge_url
contentModels: {},
state: 'empty',
errors: '',
@@ -423,7 +423,7 @@ Editor.DocumentModel = Editor.Model.extend({
this.set('data', data);
this.set('state', 'synced');
- this.set('revision', data.user_revision);
+ this.set('revision', data.revision);
this.set('user', data.user);
this.contentModels = {
@@ -464,12 +464,13 @@ Editor.DocumentModel = Editor.Model.extend({
for (key in this.contentModels) {
if (this.contentModels[key].guid() == contentModel.guid()) {
this.contentModels[key].set('state', 'synced');
- this.data.user_revision = this.contentModels[key].get('revision');
+ this.revision = this.contentModels[key].get('revision');
+
}
}
for (key in this.contentModels) {
if (this.contentModels[key].guid() != contentModel.guid()) {
- this.contentModels[key].set('revision', this.data.user_revision);
+ this.contentModels[key].set('revision', this.revision);
this.contentModels[key].set('state', 'empty');
}
}
@@ -487,60 +488,76 @@ Editor.DocumentModel = Editor.Model.extend({
update: function() {
this.set('state', 'loading');
- messageCenter.addMessage('info', 'Uaktualniam dokument...');
+
+ messageCenter.addMessage('info', 'doc_update',
+ 'Uaktualniam dokument...');
+
$.ajax({
url: this.data.merge_url,
dataType: 'json',
type: 'post',
data: {
type: 'update',
- revision: this.revision,
- user: this.user
+ revision: this.get('revision'),
+ user: this.get('user')
},
complete: this.updateCompleted.bind(this),
success: function(data) {
this.set('updateData', data);
+ console.log("new data:", data)
}.bind(this)
});
},
updateCompleted: function(xhr, textStatus) {
console.log(xhr.status, textStatus);
- if (xhr.status == 200) { // Sukces
- this.data = this.get('updateData');
- this.revision = this.data.user_revision;
- this.user = this.data.user;
-
- messageCenter.addMessage('info', null, 'Uaktualnienie dokumentu do wersji ' + this.get('updateData').revision,
- 'Uaktualnienie dokumentu do wersji ' + this.get('updateData').revision);
- for (var key in this.contentModels) {
- this.contentModels[key].set('revision', this.data.user_revision);
- this.contentModels[key].set('state', 'empty');
+
+ if (xhr.status == 200)
+ {
+ var udata = this.get('updateData');
+ if(udata.timestamp == udata.parent_timestamp)
+ {
+ // no change
+ messageCenter.addMessage('info', 'doc_update',
+ 'Nic siÄ nie zmieniÅo od ostatniej aktualizacji. Po co mam uaktualniaÄ?');
+
}
- messageCenter.addMessage('success', null, 'UaktualniÅem dokument do najnowszej wersji :-)');
- } else if (xhr.status == 202) { // Wygenerowano PullRequest (tutaj?)
- } else if (xhr.status == 204) { // Nic nie zmieniono
- messageCenter.addMessage('info', null, 'Nic siÄ nie zmieniÅo od ostatniej aktualizacji. Po co mam uaktualniaÄ?');
+ else {
+ this.set('revision', udata.revision);
+ this.set('user', udata.user);
+ messageCenter.addMessage('info', 'doc_update',
+ 'Uaktualnienie dokumentu do wersji ' + udata.revision);
+
+ for (var key in this.contentModels) {
+ this.contentModels[key].set('revision', this.get('revision') );
+ this.contentModels[key].set('state', 'empty');
+ }
+ }
} else if (xhr.status == 409) { // Konflikt podczas operacji
- messageCenter.addMessage('error', null, 'WystÄ
piÅ konflikt podczas aktualizacji. PÄdź po programistów! :-(');
- } else if (xhr.status == 500) {
- messageCenter.addMessage('critical', null, 'BÅÄ
d serwera. PÄdź po programistów! :-(');
+ messageCenter.addMessage('error', 'doc_update',
+ 'WystÄ
piÅ konflikt podczas aktualizacji. PÄdź po programistów! :-(');
+ } else {
+ messageCenter.addMessage('critical', 'doc_update',
+ 'Nieoczekiwany bÅÄ
d. PÄdź po programistów! :-(');
}
+
this.set('state', 'synced');
this.set('updateData', null);
},
merge: function(message) {
this.set('state', 'loading');
- messageCenter.addMessage('info', null, 'Scalam dokument z gÅównym repozytorium...');
+ messageCenter.addMessage('info', null,
+ 'Scalam dokument z gÅównym repozytorium...');
+
$.ajax({
url: this.data.merge_url,
type: 'post',
dataType: 'json',
data: {
type: 'share',
- revision: this.revision,
- user: this.user,
+ revision: this.get('revision'),
+ user: this.get('user'),
message: message
},
complete: this.mergeCompleted.bind(this),
@@ -553,12 +570,11 @@ Editor.DocumentModel = Editor.Model.extend({
mergeCompleted: function(xhr, textStatus) {
console.log(xhr.status, textStatus);
if (xhr.status == 200) { // Sukces
- this.data = this.get('updateData');
- this.revision = this.data.user_revision;
- this.user = this.data.user;
+ this.set('revision', this.get('updateData').revision);
+ this.set('user', this.get('updateData').user);
for (var key in this.contentModels) {
- this.contentModels[key].set('revision', this.revision);
+ this.contentModels[key].set('revision', this.get('revision'));
this.contentModels[key].set('state', 'empty');
}
diff --git a/platforma/templates/explorer/editor.html b/platforma/templates/explorer/editor.html
index daa1b9e8..f55f4ecd 100644
--- a/platforma/templates/explorer/editor.html
+++ b/platforma/templates/explorer/editor.html
@@ -1,4 +1,5 @@
{% extends "base.html" %}
+{% load i18n %}
{% block extrahead %}
@@ -49,7 +50,7 @@
<% for (panel in panels) { %>
<% }; %>
-
+
@@ -63,7 +64,7 @@