From: Radek Czajka Date: Wed, 29 Sep 2010 13:39:48 +0000 (+0200) Subject: fixes #875: detect work on outdated revision X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/3314477c16f2492b2a6b95b17922e5b6f2b087ca?ds=sidebyside fixes #875: detect work on outdated revision --- diff --git a/apps/wiki/locale/pl/LC_MESSAGES/django.mo b/apps/wiki/locale/pl/LC_MESSAGES/django.mo index 0e5d4a7c..c334eadc 100644 Binary files a/apps/wiki/locale/pl/LC_MESSAGES/django.mo and b/apps/wiki/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/wiki/locale/pl/LC_MESSAGES/django.po b/apps/wiki/locale/pl/LC_MESSAGES/django.po index 4eb2c76e..568e8441 100644 --- a/apps/wiki/locale/pl/LC_MESSAGES/django.po +++ b/apps/wiki/locale/pl/LC_MESSAGES/django.po @@ -7,11 +7,10 @@ msgid "" msgstr "" "Project-Id-Version: Platforma Redakcyjna\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-08-23 11:22+0200\n" -"PO-Revision-Date: 2010-08-16 16:24+0100\n" +"POT-Creation-Date: 2010-09-29 15:34+0200\n" +"PO-Revision-Date: 2010-09-29 15:36+0100\n" "Last-Translator: Radek Czajka \n" -"Language-Team: Fundacja Nowoczesna Polska \n" +"Language-Team: Fundacja Nowoczesna Polska \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -37,6 +36,7 @@ msgid "Modernisation" msgstr "Uwspółcześnienie" #: constants.py:11 +#: templates/wiki/tabs/annotations_view_item.html:3 msgid "Annotations" msgstr "Przypisy" @@ -97,32 +97,32 @@ msgstr "Jeśli został ukończony etap prac, wskaż go." msgid "Finished stage: %s" msgstr "Ukończony etap: %s" -#: models.py:149 +#: models.py:152 msgid "name" msgstr "nazwa" -#: models.py:153 +#: models.py:156 msgid "theme" msgstr "motyw" -#: models.py:154 +#: models.py:157 msgid "themes" msgstr "motywy" -#: views.py:165 +#: views.py:167 #, python-format msgid "Title already used for %s" msgstr "Nazwa taka sama jak dla pliku %s" -#: views.py:167 +#: views.py:169 msgid "Title already used in repository." msgstr "Plik o tej nazwie już istnieje w repozytorium." -#: views.py:173 +#: views.py:175 msgid "File should be UTF-8 encoded." msgstr "Plik powinien mieć kodowanie UTF-8." -#: views.py:344 +#: views.py:358 msgid "Tag added" msgstr "Dodano tag" @@ -142,7 +142,7 @@ msgstr "Nowa wersja" msgid "Create document" msgstr "Utwórz dokument" -#: templates/wiki/document_details.html:31 +#: templates/wiki/document_details.html:32 msgid "Click to open/close gallery" msgstr "Kliknij, aby (ro)zwinąć galerię" @@ -167,6 +167,10 @@ msgstr "Zapisz" msgid "Save attempt in progress" msgstr "Trwa zapisywanie" +#: templates/wiki/document_details_base.html:42 +msgid "There is a newer version of this document!" +msgstr "Istnieje nowsza wersja tego dokumentu!" + #: templates/wiki/document_list.html:30 msgid "Clear filter" msgstr "Wyczyść filtr" @@ -180,20 +184,15 @@ msgid "Bulk documents upload" msgstr "Hurtowe dodawanie dokumentów" #: templates/wiki/document_upload.html:12 -msgid "" -"Please submit a ZIP with UTF-8 encoded XML files. Files not ending with " -".xml will be ignored." -msgstr "" -"Proszę wskazać archiwum ZIP z plikami XML w kodowaniu UTF-8. Pliki nie kończące się na ." -"xml zostaną zignorowane." +msgid "Please submit a ZIP with UTF-8 encoded XML files. Files not ending with .xml will be ignored." +msgstr "Proszę wskazać archiwum ZIP z plikami XML w kodowaniu UTF-8. Pliki nie kończące się na .xml zostaną zignorowane." #: templates/wiki/document_upload.html:17 msgid "Upload" msgstr "Dodaj" #: templates/wiki/document_upload.html:24 -msgid "" -"There have been some errors. No files have been added to the repository." +msgid "There have been some errors. No files have been added to the repository." msgstr "Wystąpiły błędy. Żadne pliki nie zostały dodane do repozytorium." #: templates/wiki/document_upload.html:25 @@ -224,6 +223,10 @@ msgstr "Pliki pominięte z powodu braku rozszerzenia .xml." msgid "Cancel" msgstr "Anuluj" +#: templates/wiki/tabs/annotations_view.html:5 +msgid "Refresh" +msgstr "Odśwież" + #: templates/wiki/tabs/gallery_view.html:7 msgid "Previous" msgstr "Poprzednie" @@ -340,3 +343,4 @@ msgstr "Wstaw znak specjalny" #: templates/wiki/tabs/wysiwyg_editor_item.html:3 msgid "Visual editor" msgstr "Edytor wizualny" + diff --git a/apps/wiki/models.py b/apps/wiki/models.py index da8681aa..b1b14cfd 100644 --- a/apps/wiki/models.py +++ b/apps/wiki/models.py @@ -96,6 +96,9 @@ class DocumentStorage(object): changeset['description'] = STAGE_TAGS_RE.sub(stage_desc, changeset['description']) yield changeset + def doc_meta(self, title, revision=None): + return self.vstorage.page_meta(title, revision) + class Document(object): diff --git a/apps/wiki/templates/wiki/document_details_base.html b/apps/wiki/templates/wiki/document_details_base.html index e9ff8a4c..03231330 100644 --- a/apps/wiki/templates/wiki/document_details_base.html +++ b/apps/wiki/templates/wiki/document_details_base.html @@ -39,6 +39,7 @@ {% if not readonly %} | {% trans "Save attempt in progress" %} + {% trans "There is a newer version of this document!" %} {% endif %}
    diff --git a/apps/wiki/urls.py b/apps/wiki/urls.py index f4da5f37..a84330a4 100644 --- a/apps/wiki/urls.py +++ b/apps/wiki/urls.py @@ -32,6 +32,9 @@ urlpatterns = patterns('wiki.views', url(r'^(?P[^/]+)/history$', 'history', name="wiki_history"), + url(r'^(?P[^/]+)/rev$', + 'revision', name="wiki_revision"), + url(r'^(?P[^/]+)/text$', 'text', name="wiki_text"), diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 4348cb85..7d60341c 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -321,6 +321,17 @@ def diff(request, name): docB.plain_text.splitlines(), context=3)) +@never_cache +@normalized_name +def revision(request, name): + storage = getstorage() + + try: + return http.HttpResponse(str(storage.doc_meta(name)['revision'])) + except DocumentNotFound: + raise http.Http404 + + @never_cache @normalized_name def history(request, name): diff --git a/redakcja/static/css/master.css b/redakcja/static/css/master.css index 31277d32..075f59d8 100644 --- a/redakcja/static/css/master.css +++ b/redakcja/static/css/master.css @@ -101,6 +101,7 @@ body { font-weight: bold; } + #header.saving { background-color: #E1C1C1; } @@ -113,7 +114,25 @@ body { } .saving #save-attempt-info { display: inline; + font-weight: normal; +} + + +#header.out-of-date { + background-color: #E1C1C1; } +#header.out-of-date #save-button { + display: none; +} +#out-of-date-info { + color: #801000; + display: none; +} +.out-of-date #out-of-date-info { + display: inline; +} + + #header h1, #header h1 a { margin: 0; diff --git a/redakcja/static/js/wiki/loader.js b/redakcja/static/js/wiki/loader.js index 7e03c396..9530fc3f 100644 --- a/redakcja/static/js/wiki/loader.js +++ b/redakcja/static/js/wiki/loader.js @@ -110,6 +110,14 @@ $(function() console.log("Initial tab is:", active_tab) $.wiki.switchToTab(active_tab); + + /* every 5 minutes check for a newer version */ + var revTimer = setInterval(function() { + CurrentDocument.checkRevision({error: function(){ + $('#header').addClass('out-of-date'); + clearInterval(revTimer); + }}); + }, 300000); }, failure: function() { $('#loading-overlay').fadeOut(); diff --git a/redakcja/static/js/wiki/wikiapi.js b/redakcja/static/js/wiki/wikiapi.js index 4b36ae9e..bce1f897 100644 --- a/redakcja/static/js/wiki/wikiapi.js +++ b/redakcja/static/js/wiki/wikiapi.js @@ -39,6 +39,9 @@ if (vname == "ajax_document_diff") return base_path + "/" + arguments[1] + "/diff"; + if (vname == "ajax_document_rev") + return base_path + "/" + arguments[1] + "/rev"; + if (vname == "ajax_document_addtag") return base_path + "/" + arguments[1] + "/tags"; @@ -152,6 +155,20 @@ }); }; + WikiDocument.prototype.checkRevision = function(params) { + /* this doesn't modify anything, so no locks */ + var self = this; + $.ajax({ + method: "GET", + url: reverse("ajax_document_rev", self.id), + dataType: 'text', + success: function(data) { + if (data != self.revision) + params.error(); + } + }); + }; + /* * Fetch gallery */