From: Łukasz Rekucki Date: Tue, 13 Apr 2010 17:52:43 +0000 (+0200) Subject: Some changes that somehow got lost on my file system. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/00a90d6175599e055f5a84697c8388d81ac1b007 Some changes that somehow got lost on my file system. --- diff --git a/.gitignore b/.gitignore index 38cbc213..a926b1ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ localsettings.py dev.sqlite requirements.pybundle +*~ # Python garbage *.pyc diff --git a/apps/wiki/constants.py b/apps/wiki/constants.py index 562421a1..472bbb60 100644 --- a/apps/wiki/constants.py +++ b/apps/wiki/constants.py @@ -2,23 +2,23 @@ from django.utils.translation import ugettext_lazy as _ DOCUMENT_TAGS = ( - ("source", _("Tekst źródłowy")), - ("first_correction", _("Po autokorekcie")), - ("tagged", _("Tekst otagowany")), - ("second_correction", _("Po korekcie")), - ("source_annotations", _("Sprawdzone przypisy źródła")), - ("language_updates", _("Uwspółcześnienia")), - ("ready_to_publish", _("Tekst do publikacji")), + ("source", _(u"Tekst źródłowy")), + ("first_correction", _(u"Po autokorekcie")), + ("tagged", _(u"Tekst otagowany")), + ("second_correction", _(u"Po korekcie")), + ("source_annotations", _(u"Sprawdzone przypisy źródła")), + ("language_updates", _(u"Uwspółcześnienia")), + ("ready_to_publish", _(u"Tekst do publikacji")), ) DOCUMENT_TAGS_DICT = dict(DOCUMENT_TAGS) DOCUMENT_STAGES = ( - ("first_correction", _("Autokorekta")), - ("tagged", _("Tagowanie")), - ("second_correction", _("Korekta")), - ("source_annotations", _("Przypisy źródła")), - ("language_updates", _("Uwspółcześnienia")), + ("first_correction", _(u"Autokorekta")), + ("tagged", _(u"Tagowanie")), + ("second_correction", _(u"Korekta")), + ("source_annotations", _(u"Przypisy źródła")), + ("language_updates", _(u"Uwspółcześnienia")), ) DOCUMENT_STAGES_DICT = dict(DOCUMENT_STAGES) diff --git a/apps/wiki/forms.py b/apps/wiki/forms.py index 64dac29c..f6e6f40e 100644 --- a/apps/wiki/forms.py +++ b/apps/wiki/forms.py @@ -43,7 +43,7 @@ class DocumentCreateForm(forms.Form): class DocumentTextSaveForm(forms.Form): - """if + """ Form for saving document's text: * name - document's storage identifier. diff --git a/apps/wiki/helpers.py b/apps/wiki/helpers.py index 9b326d54..bc4b7602 100644 --- a/apps/wiki/helpers.py +++ b/apps/wiki/helpers.py @@ -25,7 +25,6 @@ class JSONResponse(http.HttpResponse): kwargs.pop('mimetype', None) data = json.dumps(data, cls=ExtendedEncoder) - print data super(JSONResponse, self).__init__(data, mimetype="application/json", **kwargs) diff --git a/apps/wiki/models.py b/apps/wiki/models.py index ad15c5ee..f35c3073 100644 --- a/apps/wiki/models.py +++ b/apps/wiki/models.py @@ -24,7 +24,7 @@ class DocumentStorage(object): return Document(self, name=name, text=text, revision=rev) def get_by_tag(self, name, tag): - text, rev = self.vstorage.page_text(name, tag) + text, rev = self.vstorage.page_text_by_tag(name, tag) return Document(self, name=name, text=text, revision=rev) def get_or_404(self, *args, **kwargs): diff --git a/apps/wiki/nice_diff.py b/apps/wiki/nice_diff.py index 355600b5..b228fad9 100755 --- a/apps/wiki/nice_diff.py +++ b/apps/wiki/nice_diff.py @@ -17,12 +17,15 @@ NAMES = {'+': 'added', '-': 'removed', '^': 'changed'} def diff_replace(match): return """""" % NAMES[match.group(1)] + def filter_line(line): return DIFF_RE.sub(diff_replace, html_escape(line)).replace('\x01', '') + def format_changeset(a, b, change): return (a[0], filter_line(a[1]), b[0], filter_line(b[1]), change) + def html_diff_table(la, lb, context=None): all_changes = difflib._mdiff(la, lb) diff --git a/apps/wiki/templates/wiki/base.html b/apps/wiki/templates/wiki/base.html index 5680e0df..b6cfe60c 100644 --- a/apps/wiki/templates/wiki/base.html +++ b/apps/wiki/templates/wiki/base.html @@ -18,7 +18,7 @@ {% endblock leftcolumn %}
- {% block rightcolumn %} + {% block rightcolumn %} {% endblock rightcolumn %}
{% endblock maincontent %} \ No newline at end of file diff --git a/apps/wiki/templates/wiki/document_create_missing.html b/apps/wiki/templates/wiki/document_create_missing.html index a230133e..0dcf3780 100644 --- a/apps/wiki/templates/wiki/document_create_missing.html +++ b/apps/wiki/templates/wiki/document_create_missing.html @@ -3,11 +3,11 @@ {% block leftcolumn %}
{{ form.as_p }} - +

{% endblock leftcolumn %} -{% block rightcolumn %} +{% block rightcolumn %} {% endblock rightcolumn %} \ No newline at end of file diff --git a/apps/wiki/templates/wiki/history_view.html b/apps/wiki/templates/wiki/history_view.html index 66271713..58b54156 100644 --- a/apps/wiki/templates/wiki/history_view.html +++ b/apps/wiki/templates/wiki/history_view.html @@ -1,26 +1,26 @@
- + - + - + - -

,
+
+
diff --git a/apps/wiki/templates/wiki/save_dialog.html b/apps/wiki/templates/wiki/save_dialog.html index aba61cca..7155964e 100644 --- a/apps/wiki/templates/wiki/save_dialog.html +++ b/apps/wiki/templates/wiki/save_dialog.html @@ -6,35 +6,35 @@

{{forms.text_save.comment }} - - - + + + {% if request.user.is_anonymous %}

- {{ forms.text_save.author.label }}: + {{ forms.text_save.author.label }}: {{ forms.text_save.author }} {{ forms.text_save.author.help_text }}

{% else %}

- {{ forms.text_save.stage_completed.label }}: + {{ forms.text_save.stage_completed.label }}: {{ forms.text_save.stage_completed }} {{ forms.text_save.stage_completed.help_text }}

{% endif %} - - + + {% for f in forms.text_save.hidden_fields %} {{ f }} {% endfor %} - +

- +

-

- +

+ diff --git a/apps/wiki/templates/wiki/summary_view.html b/apps/wiki/templates/wiki/summary_view.html index 5e1f82a1..9835e632 100644 --- a/apps/wiki/templates/wiki/summary_view.html +++ b/apps/wiki/templates/wiki/summary_view.html @@ -3,7 +3,7 @@ -->
- +

{{ document_meta.gallery}}

- -

+ +

\ No newline at end of file diff --git a/apps/wiki/templates/wiki/tag_dialog.html b/apps/wiki/templates/wiki/tag_dialog.html index 7212e36b..66b488cd 100644 --- a/apps/wiki/templates/wiki/tag_dialog.html +++ b/apps/wiki/templates/wiki/tag_dialog.html @@ -1,19 +1,18 @@
{% for field in forms.add_tag.visible_fields %} -

{{ field.label_tag }} {{ field }}

-

{{ field.help_text }}

+

{{ field.label_tag }} {{ field }}

+

{{ field.help_text }}

{% endfor %} - - - {% for f in forms.text_save.hidden_fields %} + + {% for f in forms.add_tag.hidden_fields %} {{ f }} {% endfor %} -

- +

+

-

+

diff --git a/apps/wiki/urls.py b/apps/wiki/urls.py index d649ba5a..dd0a0df1 100644 --- a/apps/wiki/urls.py +++ b/apps/wiki/urls.py @@ -18,8 +18,7 @@ urlpatterns = patterns('wiki.views', 'document_diff', name="wiki_diff"), url(r'^(?P[^/]+)/tags$', 'document_add_tag', name="wiki_add_tag"), - url(r'^(?P[^/]+)/tags$', - 'document_publish'), + url(r'^(?P[^/]+)/publish$', 'document_publish'), url(r'^(?P[^/]+)$', 'document_detail', name="wiki_details"), ) diff --git a/apps/wiki/views.py b/apps/wiki/views.py index e466d6a2..82693393 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -64,7 +64,7 @@ def document_detail(request, name, template_name='wiki/document_details.html'): 'document_meta': document.meta, 'forms': { "text_save": DocumentTextSaveForm(prefix="textsave"), - "add_tag": DocumentTagForm(prefix="addtag") + "add_tag": DocumentTagForm(prefix="addtag"), }, }) diff --git a/lib/vstorage.py b/lib/vstorage.py index 4cfd59aa..f3480744 100644 --- a/lib/vstorage.py +++ b/lib/vstorage.py @@ -266,19 +266,6 @@ class VersionedStorage(object): self.repo.remove([repo_file]) self._commit([repo_file], text, user) -# @with_working_copy_locked -# def _open_page(self, title): -# if title not in self: -# raise DocumentNotFound() -# -# path = self._title_to_file(title) -# logger.debug("Opening page %s", path) -# try: -# return self.repo.wfile(path, 'rb') -# except IOError: -# logger.exception("Failed to open page %s", title) -# raise DocumentNotFound() - def page_text(self, title, revision=None): """Read unicode text of a page.""" ctx = self._find_filectx(title, revision) @@ -286,14 +273,14 @@ class VersionedStorage(object): def page_text_by_tag(self, title, tag): """Read unicode text of a taged page.""" - tag = u"{title}#{tag}".format(**locals()).encode('utf-8') fname = self._title_to_file(title) + tag = u"{fname}#{tag}".format(**locals()).encode('utf-8') try: ctx = self.repo[tag][fname] return ctx.data().decode(self.charset, 'replace'), ctx.filerev() except IndexError: - raise DocumentNotFound() + raise DocumentNotFound(fname) @with_working_copy_locked def page_file_meta(self, title): @@ -309,11 +296,11 @@ class VersionedStorage(object): def page_meta(self, title): """Get page's revision, date, last editor and his edit comment.""" if not title in self: - raise DocumentNotFound() + raise DocumentNotFound(title) filectx_tip = self._find_filectx(title) if filectx_tip is None: - raise DocumentNotFound() + raise DocumentNotFound(title) rev = filectx_tip.filerev() filectx = filectx_tip.filectx(rev) date = datetime.datetime.fromtimestamp(filectx.date()[0]) @@ -336,9 +323,7 @@ class VersionedStorage(object): def _find_filectx(self, title, rev=None): """Find the last revision in which the file existed.""" - repo_file = self._title_to_file(title) - changectx = self._changectx() # start with tip stack = [changectx] @@ -360,7 +345,7 @@ class VersionedStorage(object): return fctx except (IndexError, LookupError) as e: - raise DocumentNotFound() + raise DocumentNotFound(title) def page_history(self, title): """Iterate over the page's history.""" @@ -386,10 +371,12 @@ class VersionedStorage(object): @with_working_copy_locked def add_page_tag(self, title, rev, tag, user, doctag=True): + ctitle = self._title_to_file(title) + if doctag: - tag = u"{title}#{tag}".format(**locals()).encode('utf-8') + tag = u"{ctitle}#{tag}".format(**locals()).encode('utf-8') - message = u"Assigned tag {tag!r} to version {rev!r} of {title!r}".format(**locals()).encode('utf-8') + message = u"Assigned tag {tag!r} to version {rev!r} of {ctitle!r}".format(**locals()).encode('utf-8') fctx = self._find_filectx(title, rev) self.repo.tag( diff --git a/lib/wlapi.py b/lib/wlapi.py index 0a674c8c..3284211a 100644 --- a/lib/wlapi.py +++ b/lib/wlapi.py @@ -38,7 +38,7 @@ def api_call(path, format="json"): # prepare request rq = urllib2.Request(self.base_url + path + ".json") - # will send POST when there is data, GET otherwise + # will send POST when there is data, GET otherwise if data is not None: rq.add_data(json.dumps(data)) rq.add_header("Content-Type", "application/json") diff --git a/platforma/compress_settings.py b/platforma/compress_settings.py index a2870014..ab72329f 100644 --- a/platforma/compress_settings.py +++ b/platforma/compress_settings.py @@ -41,6 +41,7 @@ COMPRESS_JS = { # dialogs 'js/wiki/dialog_save.js', + 'js/wiki/dialog_addtag.js', # views 'js/wiki/view_history.js', diff --git a/platforma/context_processors.py b/platforma/context_processors.py index db6c98b4..4492af70 100644 --- a/platforma/context_processors.py +++ b/platforma/context_processors.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 - def settings(request): from django.conf import settings - return {'MEDIA_URL': settings.MEDIA_URL, - 'STATIC_URL': settings.STATIC_URL, - 'REDMINE_URL': settings.REDMINE_URL} + return { + 'MEDIA_URL': settings.MEDIA_URL, + 'STATIC_URL': settings.STATIC_URL, + } diff --git a/platforma/settings.py b/platforma/settings.py index 4ec680fb..1f9d5d00 100644 --- a/platforma/settings.py +++ b/platforma/settings.py @@ -60,6 +60,7 @@ ADMIN_MEDIA_PREFIX = '/admin-media/' # Make this unique, and don't share it with anybody. SECRET_KEY = 'ife@x^_lak+x84=lxtr!-ur$5g$+s6xt85gbbm@e_fk6q3r8=+' +SESSION_COOKIE_NAME = "redakcja_sessionid" # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -156,7 +157,7 @@ IMAGE_DIR = 'images' WL_API_CONFIG = { "URL": "http://localhost:7000/api/", - "AUTH_REALM": "wlapi", + "AUTH_REALM": "WL API", "AUTH_USER": "platforma", "AUTH_PASSWD": "platforma", } diff --git a/platforma/static/js/wiki/dialog_addtag.js b/platforma/static/js/wiki/dialog_addtag.js index 42a81483..1a90ccf6 100644 --- a/platforma/static/js/wiki/dialog_addtag.js +++ b/platforma/static/js/wiki/dialog_addtag.js @@ -14,8 +14,8 @@ /* fill out hidden fields */ this.$form = $('form', element); - $("input[name='id']", this.$form).val(CurrentDocument.id); - $("input[name='revision']", this.$form).val(options.revision); + $("input[name='addtag-id']", this.$form).val(CurrentDocument.id); + $("input[name='addtag-revision']", this.$form).val(options.revision); $.wiki.cls.GenericDialog.call(this, element); }; diff --git a/platforma/static/js/wiki/dialog_save.js b/platforma/static/js/wiki/dialog_save.js index 12f131fd..916f3260 100644 --- a/platforma/static/js/wiki/dialog_save.js +++ b/platforma/static/js/wiki/dialog_save.js @@ -11,8 +11,8 @@ /* fill out hidden fields */ this.$form = $('form', element); - $("input[name='id']", this.$form).val(CurrentDocument.id); - $("input[name='parent_revision']", this.$form).val(CurrentDocument.revision); + $("input[name='textsave-id']", this.$form).val(CurrentDocument.id); + $("input[name='textsave-parent_revision']", this.$form).val(CurrentDocument.revision); $.wiki.cls.GenericDialog.call(this, element); }; diff --git a/platforma/static/js/wiki/view_history.js b/platforma/static/js/wiki/view_history.js index b2fe0b00..5a3e8131 100644 --- a/platforma/static/js/wiki/view_history.js +++ b/platforma/static/js/wiki/view_history.js @@ -71,7 +71,7 @@ var $stub = $('#history-view .row-stub'); changes_list.html(''); - var tags = $('select#id_addtag_tag option'); + var tags = $('select#id_addtag-tag option'); $.each(data, function(){ $.wiki.renderStub({ diff --git a/platforma/static/js/wiki/view_summary.js b/platforma/static/js/wiki/view_summary.js index 736f4e33..811096dd 100644 --- a/platforma/static/js/wiki/view_summary.js +++ b/platforma/static/js/wiki/view_summary.js @@ -9,7 +9,7 @@ $.blockUI({message: "Oczekiwanie na odpowiedź serwera..."}); self.doc.publish({ success: function(doc, data) { - $.blockUI({message: "Udało się", timeout: 2000}); + $.blockUI({message: "Udało się.", timeout: 2000}); }, failure: function(doc, message) { $.blockUI({ @@ -17,10 +17,10 @@ timeout: 5000 }); } - + }); }); - + old_callback.call(this); }; diff --git a/platforma/static/js/wiki/wikiapi.js b/platforma/static/js/wiki/wikiapi.js index a2883979..d0ac5dce 100644 --- a/platforma/static/js/wiki/wikiapi.js +++ b/platforma/static/js/wiki/wikiapi.js @@ -16,39 +16,39 @@ function reverse() { var vname = arguments[0]; var base_path = "/documents"; - + if (vname == "ajax_document_text") { var path = "/" + arguments[1] + "/text"; - - if (arguments[2] !== undefined) + + if (arguments[2] !== undefined) path += "/" + arguments[2]; - + return base_path + path; } - + if (vname == "ajax_document_history") { - + return base_path + "/" + arguments[1] + "/history"; } - + if (vname == "ajax_document_gallery") { - + return base_path + "/gallery/" + arguments[1]; } - - if (vname == "ajax_document_diff") + + if (vname == "ajax_document_diff") return base_path + "/" + arguments[1] + "/diff"; - + if (vname == "ajax_document_addtag") return base_path + "/" + arguments[1] + "/tags"; - + if (vname == "ajax_publish") return base_path + "/" + arguments[1] + "/publish"; - - console.log("Couldn't reverse match:", vname); + + console.log("Couldn't reverse match:", vname); return "/404.html"; }; - + /* * Document Abstraction */ @@ -64,7 +64,7 @@ this._context_lock = -1; this._lock_count = 0; }; - + WikiDocument.prototype.triggerDocumentChanged = function() { $(document).trigger('wlapi_document_changed', this); }; @@ -80,15 +80,15 @@ dataType: 'json', success: function(data) { var changed = false; - -if (self.text === null || self.revision !== data.revision) { + + if (self.text === null || self.revision !== data.revision) { self.text = data.text; self.revision = data.revision; self.gallery = data.gallery; changed = true; self.triggerDocumentChanged(); }; - + self.has_local_changes = false; params['success'](self, changed); }, @@ -188,23 +188,24 @@ if (self.text === null || self.revision !== data.revision) { WikiDocument.prototype.save = function(params) { params = $.extend({}, noops, params); var self = this; - + if (!self.has_local_changes) { - console.log("Abort: no changes."); + console.log("Abort: no changes."); return params['success'](self, false, "Nie ma zmian do zapisania."); }; - + // Serialize form to dictionary var data = {}; $.each(params['form'].serializeArray(), function() { data[this.name] = this.value; }); + var metaComment = '\n' - + data['textsave-text'] = metaComment + self.text; - + $.ajax({ url: reverse("ajax_document_text", self.id), type: "POST", @@ -212,7 +213,7 @@ if (self.text === null || self.revision !== data.revision) { data: data, success: function(data) { var changed = false; - + if (data.text) { self.text = data.text; self.revision = data.revision; @@ -220,19 +221,19 @@ if (self.text === null || self.revision !== data.revision) { changed = true; self.triggerDocumentChanged(); }; - + params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna")); }, error: function(xhr) { try { params['failure'](self, $.parseJSON(xhr.responseText)); - } + } catch (e) { params['failure'](self, { "__message": "

Nie udało się zapisać - błąd serwera.

" }); }; - + } }); }; /* end of save() */ @@ -253,12 +254,12 @@ if (self.text === null || self.revision !== data.revision) { else { try { params.failure(self, xhr.responseText); - } + } catch (e) { - params.failure(self, "Nie udało się - błąd serwera."); - }; + params.failure(self, "Nie udało się - błąd serwera."); + }; }; - + } }); }; @@ -266,12 +267,14 @@ if (self.text === null || self.revision !== data.revision) { params = $.extend({}, noops, params); var self = this; var data = { - "id": self.id, + "addtag-id": self.id, }; + /* unpack form */ $.each(params.form.serializeArray(), function() { data[this.name] = this.value; }); + $.ajax({ url: reverse("ajax_document_addtag", self.id), type: "POST", @@ -280,7 +283,7 @@ if (self.text === null || self.revision !== data.revision) { success: function(data) { params.success(self, data.message); }, - error: function(xhr) { + error: function(xhr) { if (xhr.status == 403 || xhr.status == 401) { params.failure(self, { "__all__": ["Nie masz uprawnień lub nie jesteś zalogowany."] @@ -289,15 +292,15 @@ if (self.text === null || self.revision !== data.revision) { else { try { params.failure(self, $.parseJSON(xhr.responseText)); - } + } catch (e) { params.failure(self, { "__all__": ["Nie udało się - błąd serwera."] }); }; - + }; - + } }); }; diff --git a/platforma/urls.py b/platforma/urls.py index 3c2b6c8a..904ad447 100644 --- a/platforma/urls.py +++ b/platforma/urls.py @@ -24,6 +24,6 @@ urlpatterns = patterns('', url(r'^%s(?P.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, 'show_indexes': True}), - url(r'^$', 'redirect_to', {'url': '/documents/'}), + url(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/documents/'}), url(r'^documents/', include('wiki.urls')), )