From 45cd953f8d1f0ac1ea9b6cf64c67ac557a289418 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Fri, 12 Jan 2018 05:14:54 +0100 Subject: [PATCH] Fixes in i18n --- paramecio/citoplasma/i18n.py | 16 ++++++++++++++-- .../templates/forms/texthtmlform.phtml | 3 ++- paramecio/cromosoma/extrafields/i18nfield.py | 1 + paramecio/cromosoma/webmodel.py | 11 ++++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/paramecio/citoplasma/i18n.py b/paramecio/citoplasma/i18n.py index a0bcaad..6f4011b 100644 --- a/paramecio/citoplasma/i18n.py +++ b/paramecio/citoplasma/i18n.py @@ -52,9 +52,10 @@ class I18n: return lang @staticmethod - def lang(module, symbol, text_default): + def lang(module, symbol, text_default, lang=None): - lang=I18n.get_default_lang() + if not lang: + lang=I18n.get_default_lang() I18n.l[lang]=I18n.l.get(lang, {}) @@ -81,3 +82,14 @@ class I18n: def get_browser_lang(): return request.headers.get('Accept-Language') + + @staticmethod + def lang_json(module, symbol, text_default): + + arr_final={} + + for l in I18n.dict_i18n: + arr_final[l]=I18n.lang(module, symbol, text_default, l) + + return json.dumps(arr_final) + diff --git a/paramecio/citoplasma/templates/forms/texthtmlform.phtml b/paramecio/citoplasma/templates/forms/texthtmlform.phtml index 9114dcd..d567bc0 100644 --- a/paramecio/citoplasma/templates/forms/texthtmlform.phtml +++ b/paramecio/citoplasma/templates/forms/texthtmlform.phtml @@ -9,7 +9,8 @@ tinymce.init({ height: 500, menubar: true, plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern', - toolbar: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat', + toolbar: 'formatselect | fontsizeselect bold italic underline strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat', + fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt 48pt 64pt 100pt 120pt", content_css: '//www.tinymce.com/css/codepen.min.css', setup: function (editor) { editor.on('change', function () { diff --git a/paramecio/cromosoma/extrafields/i18nfield.py b/paramecio/cromosoma/extrafields/i18nfield.py index 12dd286..455b4db 100644 --- a/paramecio/cromosoma/extrafields/i18nfield.py +++ b/paramecio/cromosoma/extrafields/i18nfield.py @@ -20,6 +20,7 @@ class I18nField(PhangoField): self.name_form=I18nForm self.extra_parameters=[form] + self.show_formatted_value=True def check_value(self, value): diff --git a/paramecio/cromosoma/webmodel.py b/paramecio/cromosoma/webmodel.py index c445ab7..eb3e722 100644 --- a/paramecio/cromosoma/webmodel.py +++ b/paramecio/cromosoma/webmodel.py @@ -101,6 +101,10 @@ class PhangoField: # Error by default self.error_default='Error: field required' + + # Show this value formatted + + self.show_formatted_value=False # This method is used for describe the new field in a sql language format. @@ -749,7 +753,8 @@ class WebModel: if self.show_formatted and row: for k, col in row.items(): - row[k]=self.fields[k].show_formatted(col) + if self.fields[k].show_formatted_value: + row[k]=self.fields[k].show_formatted(col) results.append(row) @@ -786,6 +791,10 @@ class WebModel: with self.select(fields_selected, raw_query) as cursor: for row in cursor: + + if self.show_formatted and row: + for k, col in row.items(): + row[k]=self.fields[k].show_formatted(col) results[row[self.name_field_id]]=row