mirror of
https://github.com/NaN-tic/trytond-galatea_cms.git
synced 2023-12-14 04:32:53 +01:00
Add ir.message and use UserWarning/UserError
This commit is contained in:
parent
5cae81a3cb
commit
7155935883
6 changed files with 39 additions and 24 deletions
12
cms.py
12
cms.py
|
@ -5,10 +5,11 @@ from trytond.model import ModelSQL, ModelView, fields
|
|||
from trytond.pool import Pool
|
||||
from trytond.pyson import Bool, Equal, Eval, In, Not
|
||||
from trytond import backend
|
||||
|
||||
from trytond.i18n import gettext
|
||||
from trytond.modules.galatea.resource import GalateaVisiblePage
|
||||
from trytond.modules.galatea.tools import slugify
|
||||
from trytond.transaction import Transaction
|
||||
from .exceptions import DeleteWarning
|
||||
|
||||
__all__ = ['Menu', 'Article', 'ArticleBlock', 'ArticleWebsite', 'Block',
|
||||
'Carousel', 'CarouselItem']
|
||||
|
@ -203,12 +204,6 @@ class Article(GalateaVisiblePage):
|
|||
if domain_clause not in cls.template.domain:
|
||||
cls.template.domain.append(domain_clause)
|
||||
|
||||
cls._error_messages.update({
|
||||
'delete_articles': ('You can not delete '
|
||||
'articles because you will get error 404 NOT Found. '
|
||||
'Dissable active field.'),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
|
@ -239,7 +234,8 @@ class Article(GalateaVisiblePage):
|
|||
|
||||
@classmethod
|
||||
def delete(cls, articles):
|
||||
cls.raise_user_warning('delete_articles', 'delete_articles')
|
||||
raise DeleteWarning('delete_articles',
|
||||
gettext('galatea_cms.msg_delete_articles'))
|
||||
super(Article, cls).delete(articles)
|
||||
|
||||
@property
|
||||
|
|
8
exceptions.py
Normal file
8
exceptions.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.exceptions import UserWarning
|
||||
|
||||
|
||||
class DeleteWarning(UserWarning):
|
||||
pass
|
16
locale/ca.po
16
locale/ca.po
|
@ -2,14 +2,6 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:galatea.cms.article:"
|
||||
msgid ""
|
||||
"You can not delete articles because you will get error 404 NOT Found. "
|
||||
"Dissable active field."
|
||||
msgstr ""
|
||||
"No pot eliminar els articles perquè obtindria una error 404 NOT Found. "
|
||||
"Desactiva'l."
|
||||
|
||||
msgctxt "field:galatea.cms.article,active:"
|
||||
msgid "Active"
|
||||
msgstr "Actiu"
|
||||
|
@ -573,6 +565,14 @@ msgctxt "model:ir.action,name:act_cms_menu_tree"
|
|||
msgid "Menus"
|
||||
msgstr "Menús"
|
||||
|
||||
msgctxt "model:ir.message,text:msg_delete_articles"
|
||||
msgid ""
|
||||
"You can not delete articles because you will get error 404 NOT Found. "
|
||||
"Dissable active field."
|
||||
msgstr ""
|
||||
"No pot eliminar els articles perquè obtindria una error 404 NOT Found. "
|
||||
"Desactiva'l."
|
||||
|
||||
msgctxt "model:ir.ui.menu,name:menu_cms_article_form"
|
||||
msgid "Articles"
|
||||
msgstr "Articles"
|
||||
|
|
16
locale/es.po
16
locale/es.po
|
@ -2,14 +2,6 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:galatea.cms.article:"
|
||||
msgid ""
|
||||
"You can not delete articles because you will get error 404 NOT Found. "
|
||||
"Dissable active field."
|
||||
msgstr ""
|
||||
"No puede eliminar este artículo para evitar el error 404 NOT Fount. "
|
||||
"Desactívalo."
|
||||
|
||||
msgctxt "field:galatea.cms.article,active:"
|
||||
msgid "Active"
|
||||
msgstr "Activo"
|
||||
|
@ -573,6 +565,14 @@ msgctxt "model:ir.action,name:act_cms_menu_tree"
|
|||
msgid "Menus"
|
||||
msgstr "Menus"
|
||||
|
||||
msgctxt "model:ir.message,text:msg_delete_articles"
|
||||
msgid ""
|
||||
"You can not delete articles because you will get error 404 NOT Found. "
|
||||
"Dissable active field."
|
||||
msgstr ""
|
||||
"No puede eliminar este artículo para evitar el error 404 NOT Fount. "
|
||||
"Desactívalo."
|
||||
|
||||
msgctxt "model:ir.ui.menu,name:menu_cms_article_form"
|
||||
msgid "Articles"
|
||||
msgstr "Artículos"
|
||||
|
|
10
message.xml
Normal file
10
message.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data group="1">
|
||||
<record model="ir.message" id="msg_delete_articles">
|
||||
<field name="text">You can not delete articles because you will get error 404 NOT Found. Dissable active field.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -5,3 +5,4 @@ depends:
|
|||
galatea
|
||||
xml:
|
||||
cms.xml
|
||||
message.xml
|
||||
|
|
Loading…
Reference in a new issue