Pastebin
Paste #3383: No description
< previous paste - next paste>
Pasted by Anonymous Coward
# views.py def admin_edit_page(page_id=None): app.logger.debug("admin_edit_page") pages = Page.query.all() form = AdminPageForm(pages=pages) # forms.py class AdminPageForm(Form): content_type_choices = [ ("text", "Text"), ("markdown", "Markdown"), ("raw", "Raw") ] pages = [] parent_pages = [] def __init__(self, *args, **kwargs): pages = kwargs.pop('pages'); if pages: self.pages = pages print "YES" else: self.pages = [] self.parent_pages = [("", gettext("(None, this will be a top page)"))] for page in self.pages: print ". ", page.id, page.path, page.title self.parent_pages.append( (str(page.id), "%s (%s)" % (page.path, page.title))) self.parent_id = SelectField(gettext("Parent page (changed)"), choices=self.parent_pages, default="") self.content_type = SelectField(gettext("Content type"), validators = [DataRequired()], choices=[("foo","foo")], default="text") print "--------------------" print self.parent_pages super(AdminPageForm, self).__init__(*args, **kwargs) print self.parent_pages path = TextField(gettext("Path"), validators = [DataRequired()]) title_da = TextField(gettext("Title (Danish)"), validators = [DataRequired()]) title_en = TextField(gettext("Title (English)"), default="") title_de = TextField(gettext("Title (German)"), default="") content_type = SelectField(gettext("Content type"), validators = [DataRequired()], choices=content_type_choices, default="text") visible = BooleanField(gettext("Visible"), default=True) content_da = TextAreaField(gettext("Content (Danish)"), validators = [DataRequired()]) content_en = TextAreaField(gettext("Content (English)"), default="" ) content_de = TextAreaField(gettext("Content (German)"), default="") meta_description= TextAreaField(gettext("Meta description"), default="") meta_keywords = TextAreaField(gettext("Meta keywords"), default="") parent_id = SelectField(gettext("Parent page"), choices=parent_pages, default="") sort_order = TextField(gettext("Sort order"), validators = [DataRequired()], default="0")
New Paste
Go to most recent paste.