Commits

Anonymous committed d2442f2

pull only published and public news, restrict all_news access, change label on form

Comments (0)

Files changed (2)

c5t/news/controllers.py

 from c5t.news.model import News
 from datetime import datetime
 from pymongo.objectid import ObjectId, InvalidId
+from c5t.core.lib.authn import HasAnyRole
 
 from c5t.core.controllers.page import PagesController
 
     @with_trailing_slash
     @expose('c5t.news.templates.index')
     def get_all(self):
-        news_list = News.query.find({'parent_id':tmpl_context.parent_id, 'expires_datetime': {'$gt': datetime.today()}})
+        query_dict = dict({'parent_id':tmpl_context.parent_id, 'created_datetime': {'$lt': datetime.today()},'expires_datetime':{'$gte': datetime.today()}, '$or' : [ { 'status' : 'published' } , { 'status' : 'public' } ]})
+        news_list = News.query.find(query_dict)
         page = tmpl_context.current_page
         page = Page.query.get(slug='news_content')
         if page and page.template != 'c5t.core.templates.page.default':
         d = dict(page=news) # , action='Add'
         return render(news.template, d)
 
+    @require(HasAnyRole('admin', 'writer', 'editor'))
     @with_trailing_slash
     @expose('c5t.news.templates.all_news')
     def get_all_news(self):

c5t/news/forms.py

     title = twf.TextField(validator=fv.String(not_empty=True))
     slug = twf.TextField(validator=fv.String(not_empty=True))
     tags = TagsField()
-    created_datetime = twf.CalendarDateTimePicker(label='Created')
+    created_datetime = twf.CalendarDateTimePicker(label='Publication Date')
     expires_datetime = twf.CalendarDateTimePicker(label='Expires',not_empty=False,default='')
     template = TemplateField()
     text = elrte.elRTEWidget(id='text', name='text', rows=20, cols=70)
     title = twf.TextField(validator=fv.String(not_empty=True))
     slug = twf.TextField(validator=fv.String(not_empty=True))
     tags = TagsField()
-    created_datetime = twf.CalendarDateTimePicker(label='Created')
+    created_datetime = twf.CalendarDateTimePicker(label='Publication Date')
     expires_datetime = twf.CalendarDateTimePicker(label='Expires',not_empty=False,default='')
     template = TemplateField()
     text = elrte.elRTEWidget(id='text', name='text', rows=20, cols=70)