From d797b76a10126a8706787983d2c40d549f596576 Mon Sep 17 00:00:00 2001 From: Jon Baldivieso Date: Tue, 9 Jan 2018 10:45:37 -0800 Subject: [PATCH] Rewrite urls to be RESTful & views to be class-based & less cache-heavy Previously, state was extensively persisted in the cache. This large-scale rewrite uses the cache only to persist changes to the catalog file when it is read-only. State is now conveyed through the url structure and through query string arguments. The primary downside to this new approach is that there's no explicit way of purging a cached catalog from memory, or refreshing it from what's on disk. The user is forced (untransparently!) to wait until the cached file falls out of the cache (untransparently!), which is currently 24 hours after the last save (or after if the session ends). Addressing this would require some design considerations, and probably some new text that would require its own translation. --- rosetta/templates/rosetta/admin_index.html | 6 +- rosetta/templates/rosetta/base.html | 2 +- .../{languages.html => file-list.html} | 12 +- .../rosetta/{pofile.html => form.html} | 30 +- rosetta/tests/django.po.test44.template | 170 +++ rosetta/tests/tests.py | 861 ++++++++------ rosetta/urls.py | 48 +- rosetta/views.py | 1017 ++++++++++------- 8 files changed, 1324 insertions(+), 822 deletions(-) rename rosetta/templates/rosetta/{languages.html => file-list.html} (75%) rename rosetta/templates/rosetta/{pofile.html => form.html} (85%) create mode 100644 rosetta/tests/django.po.test44.template diff --git a/rosetta/templates/rosetta/admin_index.html b/rosetta/templates/rosetta/admin_index.html index 2e56f45..3939a86 100644 --- a/rosetta/templates/rosetta/admin_index.html +++ b/rosetta/templates/rosetta/admin_index.html @@ -7,11 +7,11 @@
- - + +
- Rosetta + Rosetta
{% trans "Translations" %}{% trans "Change" %}{% trans "Translations" %}{% trans "Change" %}
diff --git a/rosetta/templates/rosetta/base.html b/rosetta/templates/rosetta/base.html index 4666b5b..20d27b7 100644 --- a/rosetta/templates/rosetta/base.html +++ b/rosetta/templates/rosetta/base.html @@ -24,7 +24,7 @@ diff --git a/rosetta/templates/rosetta/languages.html b/rosetta/templates/rosetta/file-list.html similarity index 75% rename from rosetta/templates/rosetta/languages.html rename to rosetta/templates/rosetta/file-list.html index 085bf24..82f6bef 100644 --- a/rosetta/templates/rosetta/languages.html +++ b/rosetta/templates/rosetta/file-list.html @@ -4,7 +4,7 @@ {% block pagetitle %}{{block.super}} - {% trans "Language selection" %}{% endblock %} {% block breadcumbs %} -
{% trans "Home" %} › {% trans "Language selection" %}
+
{% trans "Home" %} › {% trans "Language selection" %}
{% if do_session_warn %}

{% trans "Couldn't load the specified language file. This usually happens when using the Encrypted Cookies Session Storage backend on Django 1.4 or higher.
Setting ROSETTA_STORAGE_CLASS = 'rosetta.storage.CacheRosettaStorage' in your settings file should fix this." %}

{% endif %} {% endblock %} @@ -12,10 +12,10 @@

 

{% if has_pos %} @@ -40,7 +40,7 @@ {% for app,path,po in pos %} - {{ app|title }} + {{ app|title }} {{po.percent_translated}}% {% with po.untranslated_entries|length as len_untranslated_entries %} {{po.translated_entries|length|add:len_untranslated_entries}} diff --git a/rosetta/templates/rosetta/pofile.html b/rosetta/templates/rosetta/form.html similarity index 85% rename from rosetta/templates/rosetta/pofile.html rename to rosetta/templates/rosetta/form.html index 773fda9..a0c7418 100644 --- a/rosetta/templates/rosetta/pofile.html +++ b/rosetta/templates/rosetta/form.html @@ -5,8 +5,8 @@ {{block.super}}

- {% trans "Pick another file" %} / - {% trans "Download this catalog" %} + {% trans "Pick another file" %} / + {% trans "Download this catalog" %}