Esempio n. 1
0
    def _delete(self, id):
        c.db_content = DbContent.find_by_id(id)
        meta.Session.delete(c.db_content)
        meta.Session.commit()

        h.flash("Content Deleted.")
        redirect_to('index')
Esempio n. 2
0
    def _delete(self, id):
        c.db_content = DbContent.find_by_id(id)
        meta.Session.delete(c.db_content)
        meta.Session.commit()

        h.flash("Content Deleted.")
        redirect_to('index')
Esempio n. 3
0
    def _new(self):
        results = self.form_result['db_content']
        c.db_content = DbContent(**results)
        meta.Session.add(c.db_content)
        meta.Session.commit()

        h.flash("New Page Created.")
        redirect_to(action='view', id=c.db_content.id)
Esempio n. 4
0
 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()
Esempio n. 5
0
    def edit(self, id):
        c.db_content = DbContent.find_by_id(id)

        defaults = h.object_to_defaults(c.db_content, 'db_content')
        # This is horrible, don't know a better way to do it
        if c.db_content.type:
            defaults['db_content.type'] = defaults['db_content.type_id']

        form = render('/db_content/edit.mako')
        return htmlfill.render(form, defaults)
Esempio n. 6
0
    def _edit(self, id):
        c.db_content = DbContent.find_by_id(id)

        for key in self.form_result['db_content']:
            setattr(c.db_content, key, self.form_result['db_content'][key])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("Page updated.")
        redirect_to(action='view', id=id)
Esempio n. 7
0
    def edit(self, id):
        c.db_content = DbContent.find_by_id(id)

        defaults = h.object_to_defaults(c.db_content, 'db_content')
        # This is horrible, don't know a better way to do it
        if c.db_content.type:
            defaults['db_content.type'] = defaults['db_content.type_id']
        
        form = render('/db_content/edit.mako')
        return htmlfill.render(form, defaults)
Esempio n. 8
0
    def _edit(self, id):
        c.db_content = DbContent.find_by_id(id)

        for key in self.form_result['db_content']:
            setattr(c.db_content, key, self.form_result['db_content'][key])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("Page updated.")
        redirect_to(action='view', id=id)
Esempio n. 9
0
 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()
Esempio n. 10
0
 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")
Esempio n. 11
0
    def list_press(self):
        if c.db_content_types:
            page = 1
            if request.GET.has_key('page'):
                page = request.GET['page']
            pagination = paginate.Page(DbContent.find_all_by_type("In the press"), page = page, items_per_page = 10)

            c.db_content_pages = pagination
            c.db_content_collection = pagination.items
            c.result = True
        else:
            c.result = False
        return render('/db_content/list_press.mako')
Esempio n. 12
0
    def list_news(self):
        if c.db_content_types:
            page = 1
            if request.GET.has_key("page"):
                page = request.GET["page"]
            pagination = paginate.Page(DbContent.find_all_by_type("News"), page=page, items_per_page=10)

            c.db_content_pages = pagination
            c.db_content_collection = pagination.items
            c.result = True
        else:
            c.result = False
        return render("/db_content/list_news.mako")
Esempio n. 13
0
 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')
Esempio n. 14
0
    def list_news(self):
        if c.db_content_types:
            page = 1
            if request.GET.has_key('page'):
                page = request.GET['page']
            pagination = paginate.Page(DbContent.find_all_by_type("News"),
                                       page=page,
                                       items_per_page=10)

            c.db_content_pages = pagination
            c.db_content_collection = pagination.items
            c.result = True
        else:
            c.result = False
        return render('/db_content/list_news.mako')
Esempio n. 15
0
 def delete(self, id):
     c.db_content = DbContent.find_by_id(id)
     return render('/db_content/confirm_delete.mako')
Esempio n. 16
0
 def index(self):
     c.db_content_collection = DbContent.find_all()
     return render('/db_content/list.mako')
Esempio n. 17
0
 def index(self):
     c.db_content_collection = DbContent.find_all()
     return render('/db_content/list.mako')
Esempio n. 18
0
 def delete(self, id):
     c.db_content = DbContent.find_by_id(id)
     return render('/db_content/confirm_delete.mako')