From 4cfeb9a16a5869ca99bcec2eae9b322f98341f65 Mon Sep 17 00:00:00 2001 From: resteve Date: Mon, 15 Dec 2014 15:04:02 +0100 Subject: [PATCH] Galatea User --- locale/ca_ES.po | 12 ++++++++---- locale/es_ES.po | 6 +++++- tutorial.py | 23 +++++++++++++++++++---- view/tutorial_form.xml | 2 ++ view/tutorial_tree.xml | 1 + 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/locale/ca_ES.po b/locale/ca_ES.po index 5e6cf65..bfe043d 100644 --- a/locale/ca_ES.po +++ b/locale/ca_ES.po @@ -78,6 +78,10 @@ msgctxt "field:galatea.tutorial,slug_langs:" msgid "Slug Langs" msgstr "Slug idiomes" +msgctxt "field:galatea.tutorial,user:" +msgid "User" +msgstr "Usuari" + msgctxt "field:galatea.tutorial,websites:" msgid "Websites" msgstr "Llocs web" @@ -213,7 +217,7 @@ msgid "" "Almost all search engines recommend it to be shorter than 155 characters of " "plain text" msgstr "" -"La majoría dels cercadors recomanen un text de 155 caràcters de text pla." +"La majoria dels cercadors recomanen un text de 155 caràcters de text pla." msgctxt "help:galatea.tutorial,metakeywords:" msgid "Separated by comma" @@ -270,7 +274,7 @@ msgstr "Comentaris" msgctxt "model:ir.action,name:act_tutorial_form" msgid "Tutorials" -msgstr "Tutoriales" +msgstr "Tutorials" msgctxt "model:ir.ui.menu,name:menu_galatea_tutorial" msgid "Tutorial" @@ -282,7 +286,7 @@ msgstr "Comentaris" msgctxt "model:ir.ui.menu,name:menu_tutorial_form" msgid "Tutorials" -msgstr "Tutoriales" +msgstr "Tutorials" msgctxt "model:res.group,name:group_galatea_tutorial" msgid "Galatea Tutorial" @@ -322,7 +326,7 @@ msgstr "Tutorial" msgctxt "view:galatea.tutorial:" msgid "Tutorials" -msgstr "Tutoriales" +msgstr "Tutorials" msgctxt "view:galatea.tutorial:" msgid "Websites" diff --git a/locale/es_ES.po b/locale/es_ES.po index c4b61ea..f333727 100644 --- a/locale/es_ES.po +++ b/locale/es_ES.po @@ -78,6 +78,10 @@ msgctxt "field:galatea.tutorial,slug_langs:" msgid "Slug Langs" msgstr "Slug idiomas" +msgctxt "field:galatea.tutorial,user:" +msgid "User" +msgstr "Usuario" + msgctxt "field:galatea.tutorial,websites:" msgid "Websites" msgstr "Sitios web" @@ -243,7 +247,7 @@ msgstr "" msgctxt "help:galatea.website,tutorial_anonymous:" msgid "Active user anonymous to publish comments." -msgstr "Activar usuarios anónimos en publicar comentaios." +msgstr "Activar usuarios anónimos en publicar comentarios." msgctxt "help:galatea.website,tutorial_comment:" msgid "Active tutorial comments." diff --git a/tutorial.py b/tutorial.py index 4b66ba9..0466653 100644 --- a/tutorial.py +++ b/tutorial.py @@ -31,6 +31,7 @@ class GalateaTutorial(ModelSQL, ModelView): metatitle = fields.Char('Meta Title', translate=True) active = fields.Boolean('Active', help='Dissable to not show content tutorial.') + user = fields.Many2One('galatea.user', 'User', required=True) websites = fields.Many2Many('galatea.tutorial-galatea.website', 'tutorial', 'website', 'Websites', help='Tutorial will be available in those websites') @@ -53,6 +54,17 @@ class GalateaTutorial(ModelSQL, ModelView): def default_comment(): return True + @classmethod + def default_user(cls): + Website = Pool().get('galatea.website') + websites = Website.search([('active', '=', True)], limit=1) + if not websites: + return None + website, = websites + if website.tutorial_anonymous_user: + return website.tutorial_anonymous_user.id + return None + @classmethod def __setup__(cls): super(GalateaTutorial, cls).__setup__() @@ -139,10 +151,13 @@ class GalateaTutorialComment(ModelSQL, ModelView): @classmethod def default_user(cls): Website = Pool().get('galatea.website') - websites = Website.search([('active', '=', True)]) - if len(websites) == 1: - if websites[0].tutorial_anonymous_user: - return websites[0].tutorial_anonymous_user.id + websites = Website.search([('active', '=', True)], limit=1) + if not websites: + return None + website, = websites + if website.tutorial_anonymous_user: + return website.tutorial_anonymous_user.id + return None @classmethod def get_comment_create_date(cls, records, name): diff --git a/view/tutorial_form.xml b/view/tutorial_form.xml index f54e0ba..24ca067 100644 --- a/view/tutorial_form.xml +++ b/view/tutorial_form.xml @@ -8,6 +8,8 @@ this repository contains the full copyright notices and license terms. -->