Add post published date field

This commit is contained in:
Raimon Esteve 2017-07-06 17:21:11 +02:00
parent f40b58768f
commit e80144b790
4 changed files with 24 additions and 5 deletions

View File

@ -30,7 +30,7 @@ class Post(ModelSQL, ModelView):
long_description = fields.Text('Long Description', 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.')
metadescription = fields.Char('Meta Description', translate=True,
metadescription = fields.Char('Meta Description', translate=True,
help='Almost all search engines recommend it to be shorter ' \
'than 155 characters of plain text')
metakeywords = fields.Char('Meta Keywords', translate=True,
@ -48,6 +48,7 @@ class Post(ModelSQL, ModelView):
domain=[('active', '=', True)], required=True)
post_create_date = fields.DateTime('Create Date', readonly=True)
post_write_date = fields.DateTime('Write Date', readonly=True)
post_published_date = fields.DateTime('Published Date', required=True)
user = fields.Many2One('galatea.user', 'User', required=True)
gallery = fields.Boolean('Gallery', help='Active gallery attachments.')
comment = fields.Boolean('Comment', help='Active comments.')
@ -104,10 +105,14 @@ class Post(ModelSQL, ModelView):
def default_post_create_date():
return datetime.now()
@staticmethod
def default_post_published_date():
return datetime.now()
@classmethod
def __setup__(cls):
super(Post, cls).__setup__()
cls._order.insert(0, ('post_create_date', 'DESC'))
cls._order.insert(0, ('post_published_date', 'DESC'))
cls._order.insert(1, ('name', 'ASC'))
cls._error_messages.update({
'delete_posts': ('You can not delete '

View File

@ -1,4 +1,4 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
@ -129,6 +129,14 @@ msgctxt "field:galatea.blog.post,post_create_date:"
msgid "Create Date"
msgstr "Fecha creación"
msgctxt "field:galatea.blog.post,post_published_date:"
msgid "Published Date"
msgstr "Data publicació"
msgctxt "field:galatea.blog.post,post_published_date:"
msgid "Published Date"
msgstr "Fecha publicación"
msgctxt "field:galatea.blog.post,post_write_date:"
msgid "Write Date"
msgstr "Fecha modificación"

View File

@ -26,9 +26,14 @@ this repository contains the full copyright notices and license terms. -->
</page>
<page string="Info" id="info">
<label name="post_create_date"/>
<field name="post_create_date"/>
<field name="post_create_date" widget="date"/>
<field name="post_create_date" widget="time"/>
<label name="post_write_date"/>
<field name="post_write_date"/>
<field name="post_write_date" widget="date"/>
<field name="post_write_date" widget="time"/>
<label name="post_published_date"/>
<field name="post_published_date" widget="date"/>
<field name="post_published_date" widget="time"/>
</page>
<page string="Extra" id="extra">
<label name="user"/>

View File

@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. -->
<tree string="Posts">
<field name="name"/>
<field name="post_create_date" widget="date"/>
<field name="post_published_date" widget="date"/>
<field name="user"/>
<field name="visibility"/>
<field name="galatea_website"/>