Pastebin

Paste #3380: No description

< previous paste - next paste>

Pasted by Anonymous Coward

Download View as text

class AdminPageForm(Form):
    content_type_choices = [
            ("text", "Text"),
            ("markdown", "Markdown"),
            ("raw",  "Raw")
            ]
    pages = []
    parent_pages = []
    def __init__(self, pages):
        if pages:
            self.pages = pages
        else:
            self.pages = []
        self.parent_pages = [("", gettext("(None, this will be a top page)"))]
        for page in self.pages:
            self.parent_pages.append( (str(page.id), "%s (%s)" % (page.path, page.title)))

    path            = TextField(gettext("Path"),             validators = [DataRequired()])
    title_da        = TextField(gettext("Title (Danish)"),            validators = [DataRequired()])
    title_en        = TextField(gettext("Title (English)"),           default="")
...

@app.route("/admin/pages/edit/", methods=["GET", "POST"])
@app.route("/admin/pages/edit/<page_id>", methods=["GET", "POST"])
@login_required
def admin_edit_page(page_id=None):
    app.logger.debug("admin_edit_page")
    pages = Page.query.all()
    form = AdminPageForm(pages=pages)
    if form.validate_on_submit():
        app.logger.debug("SUBMITTED")
        if page_id:
            app.logger.debug("GOT PAGE ID --> EXISTING PAGE")
            page= db.session.query(Page).filter(Page.id==page_id).first()
        else:
            app.logger.debug("NOT PAGE ID --> NEW PAGE")
            page = Page()
        page.path          = form.path.data

....

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.