URI website

This commit is contained in:
resteve 2014-07-16 11:54:17 +02:00
parent a47515a1b5
commit 8de8574072
2 changed files with 13 additions and 0 deletions

11
cms.py
View file

@ -90,6 +90,7 @@ class Article(ModelSQL, ModelView):
slug = fields.Char('Slug', required=True, translate=True,
help='Cannonical uri.')
slug_langs = fields.Function(fields.Dict(None, 'Slug Langs'), 'get_slug_langs')
uri = fields.Function(fields.Char('Uri'), 'get_uri')
description = fields.Text('Description', required=True, translate=True,
help='You could write wiki markup to create html content. Formats text following '
'the MediaWiki (http://meta.wikimedia.org/wiki/Help:Editing) syntax.')
@ -169,6 +170,16 @@ class Article(ModelSQL, ModelView):
return slugs
def get_uri(self, name):
if self.galatea_website:
locale = Transaction().context.get('language', 'en')
return '%s%s/%s' % (
self.galatea_website.uri,
locale[:2],
self.slug,
)
return ''
class Block(ModelSQL, ModelView):
"Block CMS"

View file

@ -12,6 +12,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="template"/>
<label name="active"/>
<field name="active"/>
<label name="uri"/>
<field name="uri" widget="url"/>
<notebook colspan="4">
<page string="Descriptions" id="descriptions">
<field name="description"/>