def page(self): url = h.url_for().strip("/") c.db_content = DbContent.find_by_url(url, abort_404=False) if c.db_content is not None: if not c.db_content.published and not h.auth.authorized( h.auth.has_organiser_role): c.db_content = None return NotFoundController().view() return self.view(c.db_content.id) return NotFoundController().view()
def view(self, id): c.db_content = DbContent.find_by_id(id) if not c.db_content.published and not h.auth.authorized( h.auth.has_organiser_role): c.db_content = None return NotFoundController().view() elif not c.db_content.published: h.flash( "This content is marked as unpublished and is only viewable by organisers.", 'Warning') if c.db_content.type.name == 'Redirect': redirect_to(c.db_content.body.encode("latin1"), _code=301) c.html_headers, c.html_body, c.menu_contents = self.parse_dbpage( c.db_content.body) return render('/db_content/view.mako')
def view(self, id): c.db_content = DbContent.find_by_id(id) if c.db_content.publish_timestamp > datetime.now( ) and not h.auth.authorized(h.auth.has_organiser_role): c.db_content = None return NotFoundController().view() elif c.db_content.publish_timestamp > datetime.now(): h.flash(( "This content is marked to be published on %s and will not be visiable to public until then." % c.db_content.publish_timestamp), 'Warning') if c.db_content.type.name == 'Redirect': redirect_to(c.db_content.body.encode("latin1"), _code=301) c.html_headers, c.html_body, c.menu_contents = self.parse_dbpage( c.db_content.body) return render('/db_content/view.mako')
def page(self): url = h.url_for().strip("/") c.db_content = DbContent.find_by_url(url, abort_404=False) if c.db_content is not None: return self.view(c.db_content.id) return NotFoundController().view()