From 3314477c16f2492b2a6b95b17922e5b6f2b087ca Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 29 Sep 2010 15:39:48 +0200 Subject: [PATCH] fixes #875: detect work on outdated revision --- apps/wiki/locale/pl/LC_MESSAGES/django.mo | Bin 5011 -> 5151 bytes apps/wiki/locale/pl/LC_MESSAGES/django.po | 44 ++++++++++-------- apps/wiki/models.py | 3 ++ .../templates/wiki/document_details_base.html | 1 + apps/wiki/urls.py | 3 ++ apps/wiki/views.py | 11 +++++ redakcja/static/css/master.css | 19 ++++++++ redakcja/static/js/wiki/loader.js | 8 ++++ redakcja/static/js/wiki/wikiapi.js | 17 +++++++ 9 files changed, 86 insertions(+), 20 deletions(-) diff --git a/apps/wiki/locale/pl/LC_MESSAGES/django.mo b/apps/wiki/locale/pl/LC_MESSAGES/django.mo index 0e5d4a7c89b2f695f79f854a99db6cec297ad009..c334eadcf0502cef0d00b7ac8fab72f6624dc746 100644 GIT binary patch delta 1947 zcmYk+S!h&O9LMo9&SWteHICyNV{TeIiMuh2Mq9TS6HQ~{@*t(qj`2n_nz=eNCMf8r z1yKuv#E2r)huVj>Pj%XYTb`OgODUBWT3T=cTMG7}MTiPQ`~6*ynnV8ioO9;h^FPbI zx4-goRrXFKG+-#3iJ8QeF~;=Z{5<|q?&TXZ74Ks)K1KdaUV$;=F^rS36xCmC`!96U)5nP7RLSt&M4I_9AmEaue zzE6-#%@-KLYqmXzi)asHl>BCd%0xPfnbtHcL(RM%wZcZ!1h?4!9mvd$he~u9mEaWW zx-+)_Bh&;w!vtPMQkk-%=lwA(A-`E@J62hnQ4?rK4frl9!Cuq^_oKG@G-~B%Q4_j? zn$T5L;z1;*8Mf^ov7Gj=sQaH_wuQ=nROVs}ck9^GI2{jS1@@x`{0epBE!56@WBY$X zP55`zMEkg;E6t!LauAg;i$?>-oIrGWju?b_Cz*Tq_C*f^m@#YWI{r{pC8X~JE97Zi5lBKeUN-64sR@6$iVie=3fqGGA ze;gUhTtZFwb5z3XsOx?}ZSimR_XntnKSCwell}qZqZXb$O+_~hpb}oT?JrRi8bn<< zj9STU)Yd*g#xxIY`x)|Qf?TBj$*76OP!p&}jnjzAw+UzI{ohVS1NPy1Jc8QNA>02q zIL4+?RM1#XtR3BH>w2^NZPi&f*iL<3-zM}# z&m*P~D~T3DrH0T>y+KqF8;DJWibJd+^p;c;Dys=j&;JH2K$T{K2R3V(s4OJ(I?X3W zmv$Ph#5&tKchrw>Qr9^)5;|`^e4Lzrl$&uqv6zSvdJgIdvnHAJGVx5emvlN(p4XMi zeV5-J40fg5T(l@JFlV=$a-Ht96L*qspPO=e-Bel^dtFXuH~l-k&I3JeGEq{Ss aJ0wUa;!eihQ5mvx7DabTTuyGP}l8t{fAH!IDz}{EHbnW zx&A*GAiw1n3}0A^nJq&NRErvT5o%&fQCq(awc-}kL^@CtIe|)e5gFUMT>Caw(7uPd z{}ndjTl93y6S=z#LpT+asDZYjZrF+1iM_7>2x_98s0mzf-oUxE@1u_J18O2esFnXk zjhn~KY6tx6zgAdAhb9t2C7gksKC>DO)9xXQZg_*b?ma5;CqDE{4504IW0qx*-=bi+;5*7hK|?HOvo*Ejr<$F-U=$3Ni*t#7Ssy%qqfvT?zK~{eGU1uZrA@1HNh9C z#QmsozMv9)#}NKRjTdC_Ral0!J=;MgOvfIK;AzxW^`chr0yXeU)Bx{LJMj^fc)pp6&;#vN@v)r9mi1KXi7=t#*g$BT=MyuDxx^+S zTWVcpdbY#47WEv|{MVnPuKy*KL>)0zo20W*NfC`ioY1+gBQ_GN2|b`uB3txM^E}x? zVnO0xyL9#9u4@aY^SnTq5e~4x@5soHOvHEn$m^(S?rzN9(>A_&! F_YcA0hw1\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 */ -- 2.20.1