Example #1
0
 def rss_news(self):
     news_id = DbContentType.find_by_name("News")
     c.db_content_collection = []
     if news_id is not None: 
         c.db_content_collection = meta.Session.query(DbContent).filter_by(type_id=news_id.id).filter(DbContent.publish_timestamp <= datetime.now()).order_by(DbContent.publish_timestamp.desc()).limit(20).all()
     response.headers['Content-type'] = 'application/rss+xml; charset=utf-8'
     return render('/db_content/rss_news.mako')
Example #2
0
 def new(self):
     if len(c.db_content_types) is 0:
         h.flash("Configuration Error: Please make sure at least one content type exists.", 'error')
     if DbContentType.find_by_name("News") is None:
         h.flash("Configuration Error: Please make sure the 'News' content type exists for full functionality.", 'error')
     if DbContentType.find_by_name("In the press") is None:
         h.flash("Configuration Error: Please make sure the 'In the press' content type exists for full functionality.", 'error')
     c.db_content = DbContent()
     defaults = h.object_to_defaults(c.db_content, 'db_content')
     if request.GET.has_key('url'):
         defaults['db_content.type'] = 1 # This is bad... we're assuming we have #1 as new page
         if request.GET['url'].startswith('/'):
             defaults['db_content.url'] = str(request.GET['url'])[1:]
         else:
             defaults['db_content.url'] = request.GET['url']
     form = render('/db_content/new.mako')
     return htmlfill.render(form, defaults)
Example #3
0
 def rss_news(self):
     news_id = DbContentType.find_by_name("News")
     c.db_content_collection = []
     if news_id is not None:
         c.db_content_collection = meta.Session.query(DbContent).filter_by(
             type_id=news_id.id).filter(
                 DbContent.publish_timestamp <= datetime.now()).order_by(
                     DbContent.publish_timestamp.desc()).limit(20).all()
     response.headers['Content-type'] = 'application/rss+xml; charset=utf-8'
     return render('/db_content/rss_news.mako')
Example #4
0
 def new(self):
     if len(c.db_content_types) is 0:
         h.flash(
             "Configuration Error: Please make sure at least one content type exists.",
             'error')
     if DbContentType.find_by_name("News", abort_404=False) is None:
         h.flash(
             "Configuration Error: Please make sure the 'News' content type exists for full functionality.",
             'error')
     if DbContentType.find_by_name("In the press", abort_404=False) is None:
         h.flash(
             "Configuration Error: Please make sure the 'In the press' content type exists for full functionality.",
             'error')
     c.db_content = DbContent()
     defaults = h.object_to_defaults(c.db_content, 'db_content')
     if request.GET.has_key('url'):
         defaults['db_content.type'] = find_by_name('Page', abort_404=False)
         if request.GET['url'].startswith('/'):
             defaults['db_content.url'] = str(request.GET['url'])[1:]
         else:
             defaults['db_content.url'] = request.GET['url']
     form = render('/db_content/new.mako')
     return htmlfill.render(form, defaults)
Example #5
0
 def _to_python(self, value, state):
     return DbContentType.find_by_id(value)
Example #6
0
 def __before__(self, **kwargs):
     c.db_content_types = DbContentType.find_all()
Example #7
0
 def _to_python(self, value, state):
     return DbContentType.find_by_id(value)
Example #8
0
 def __before__(self, **kwargs):
     c.db_content_types = DbContentType.find_all()