# HG changeset patch # User durandn # Date 1463655485 -7200 # Node ID 97e57904f11de9d5c19a75a76f85e894fb87db8e # Parent 0abec1f6a66ff36fe8528ad4227cd3f7b82328a9 implemented client-side error handling + translation diff -r 0abec1f6a66f -r 97e57904f11d .settings/org.eclipse.core.resources.prefs --- a/.settings/org.eclipse.core.resources.prefs Fri May 13 13:12:14 2016 +0200 +++ b/.settings/org.eclipse.core.resources.prefs Thu May 19 12:58:05 2016 +0200 @@ -3,4 +3,5 @@ encoding//server/src/metaeducation/migrations/0001_initial.py=utf-8 encoding//server/src/metaeducation/migrations/0002_user_uai.py=utf-8 encoding//server/src/metaeducation/migrations/0003_renkan_permissions.py=utf-8 +encoding//server/src/metaeducation/migrations/0004_auto_20160414_1057.py=utf-8 encoding//server/src/metaeducation/settings/dev.py=utf-8 diff -r 0abec1f6a66f -r 97e57904f11d server/src/metaeducation/locale/fr/LC_MESSAGES/django.po --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/metaeducation/locale/fr/LC_MESSAGES/django.po Thu May 19 12:58:05 2016 +0200 @@ -0,0 +1,78 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-05-19 11:35+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: metaeducation/admin.py:61 +msgid "Personal info" +msgstr "Informations personnelles" + +#: metaeducation/admin.py:62 +msgid "Permissions" +msgstr "Permissions" + +#: metaeducation/admin.py:64 +msgid "Important dates" +msgstr "Dates" + +#: metaeducation/models.py:35 +msgid "first name" +msgstr "Prénom" + +#: metaeducation/models.py:36 +msgid "last name" +msgstr "Nom" + +#: metaeducation/templates/renkan_edit.html:67 +msgid "The Renkan server has reported an error" +msgstr "Le serveur Renkan a rencontré une erreur." + +#: metaeducation/templates/renkan_edit.html:71 +msgid "" +"The Renkan graph you are trying to edit is currently being edited by another " +"user. We advise you to reload the page." +msgstr "Le graphe Renkan que vous tentez d'éditer est actuellement en cours d'édition par un autre " +"utilisateur. Nous vous conseillons de recharger la page." + +#: metaeducation/templates/renkan_edit.html:73 +msgid "" +"There was an error with the graph data sent to the Renkan server. If the " +"problem persists after a page reload, please contact an administrator. Error " +"message was : " +msgstr "Une erreur s'est produite lors de l'envoi des données d'éditions du graphe Renkan. Si le " +"problème persiste après rechargement de la page, merci de contacter un administrateur. Message " +"d'erreur: " + +#: metaeducation/templates/renkan_edit.html:75 +msgid "You don't have the permission to edit this Renkan graph." +msgstr "Vous n'avez pas le droit d'éditer ce graphe Renkan." + +#: metaeducation/templates/renkan_edit.html:77 +msgid "The Renkan graph you are trying to edit or view doesn't exist" +msgstr "Le graphe Renkan que vous cherchez à visualiser ou éditer n'existe pas." + +#: metaeducation/templates/renkan_edit.html:79 +msgid "" +"There was an error with the Renkan server. If the problem persists after a " +"page reload, please contact an administrator. The error message was : " +msgstr "Une erreur s'est produite au niveau du serveur Renkan. Si le problème persiste après " +"rechargement de la page, merci de contacter un administrateur. Message d'erreur: " + +#: metaeducation/templates/renkan_edit.html:83 +msgid "Reload the page" +msgstr "Recharger la page" diff -r 0abec1f6a66f -r 97e57904f11d server/src/metaeducation/settings/__init__.py --- a/server/src/metaeducation/settings/__init__.py Fri May 13 13:12:14 2016 +0200 +++ b/server/src/metaeducation/settings/__init__.py Thu May 19 12:58:05 2016 +0200 @@ -55,7 +55,7 @@ ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticatedOrReadOnly', - 'metaeducation.permissions.MtdcObjectPermissions', + #'rest_framework.permissions.DjangoObjectPermissions', ), 'DEFAULT_PARSER_CLASSES': ( 'rest_framework.parsers.JSONParser', diff -r 0abec1f6a66f -r 97e57904f11d server/src/metaeducation/static/metaeducation/css/style.css --- a/server/src/metaeducation/static/metaeducation/css/style.css Fri May 13 13:12:14 2016 +0200 +++ b/server/src/metaeducation/static/metaeducation/css/style.css Thu May 19 12:58:05 2016 +0200 @@ -61,4 +61,8 @@ #renkanErrorReload { cursor: pointer; +} + +.errorMsg{ + display: none; } \ No newline at end of file diff -r 0abec1f6a66f -r 97e57904f11d server/src/metaeducation/static/metaeducation/js/mtdc-save.js --- a/server/src/metaeducation/static/metaeducation/js/mtdc-save.js Fri May 13 13:12:14 2016 +0200 +++ b/server/src/metaeducation/static/metaeducation/js/mtdc-save.js Thu May 19 12:58:05 2016 +0200 @@ -17,7 +17,6 @@ _proj.set({ saveStatus : 0 }); - console.log(_proj.get("updated")) _proj.on("add:nodes add:edges add:users add:views", function(_model) { _model.on("change remove", function(_model) { _thrSave(); @@ -30,9 +29,8 @@ _thrSave(); } }); - }).fail(function( jqXHR, textStatus ) { - _showErrorModal(jqXHR.responseText); - console.log(textStatus) + }).fail(function(jqXHR, textStatus) { + _showErrorModal(jqXHR); }); }; var _save = function() { @@ -51,12 +49,9 @@ saveStatus : 0, updated : data.updated }); - //_showErrorModal("updated") }, error: function (jqXHR, textStatus, errorThrown) { - _showErrorModal(jqXHR.responseText); - console.log(textStatus) - console.log(errorThrown) + _showErrorModal(jqXHR); } }); } @@ -72,9 +67,30 @@ }); var errorModal = document.getElementById('renkanErrorModal'); - var _showErrorModal = function(message) { + var _showErrorModal = function(jqXHR) { errorModal.style.display = "block"; - Rkns.$(".errorMsg").text(message); + switch(jqXHR.status){ + case 400: + var jsonResp = JSONparse(jqXHR.responseText) + if(jsonResp.hasOwnAttribute('validation_timestamp')){ + document.getElementById('400Error_timestamp').style.display = "block"; + } + else { + Rkns.$("#400Error_other").append(jqXHR.responseText) + document.getElementById('400Error_other').style.display = "block"; + } + break; + case 403: + document.getElementById('403Error').style.display = "block"; + break; + case 404: + document.getElementById('404Error').style.display = "block"; + break; + case 500: + Rkns.$("#500Error").append(jqXHR.responseText) + document.getElementById('500Error').style.display = "block"; + break; + } } _load(); diff -r 0abec1f6a66f -r 97e57904f11d server/src/metaeducation/templates/base.html --- a/server/src/metaeducation/templates/base.html Fri May 13 13:12:14 2016 +0200 +++ b/server/src/metaeducation/templates/base.html Thu May 19 12:58:05 2016 +0200 @@ -1,4 +1,5 @@ {% load staticfiles %} +{% load i18n %} diff -r 0abec1f6a66f -r 97e57904f11d server/src/metaeducation/templates/renkan_edit.html --- a/server/src/metaeducation/templates/renkan_edit.html Fri May 13 13:12:14 2016 +0200 +++ b/server/src/metaeducation/templates/renkan_edit.html Thu May 19 12:58:05 2016 +0200 @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load staticfiles %} +{% load i18n %} {% block js_import %} {{block.super}} @@ -62,15 +63,19 @@
-
-

Le serveur Renkan a renvoyé une erreur.

-
-
-

-
-
-
{% endblock main_content %} \ No newline at end of file diff -r 0abec1f6a66f -r 97e57904f11d server/src/metaeducation/templates/renkan_view.html --- a/server/src/metaeducation/templates/renkan_view.html Fri May 13 13:12:14 2016 +0200 +++ b/server/src/metaeducation/templates/renkan_view.html Thu May 19 12:58:05 2016 +0200 @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load staticfiles %} +{% load i18n %} {% block js_import %} {{block.super}} @@ -62,13 +63,17 @@
-

Le serveur Renkan a renvoyé une erreur.

+

{% trans "The Renkan server has reported an error" %}

-

+

{% trans "The Renkan graph you are trying to edit is currently being edited by another user. We advise you to reload the page." %}

+

{% trans "There was an error with the graph data sent to the Renkan server. If the problem persists after a page reload, please contact an administrator. Error message was : " %}

+

{% trans "You don't have the permission to edit this Renkan graph." %}

+

{% trans "The Renkan graph you are trying to edit or view doesn't exist" %}

+

{% trans "There was an error with the Renkan server. If the problem persists after a page reload, please contact an administrator. The error message was : " %}