def __init__(self, post=None, *args, **kwargs): Form.__init__(self, *args, **kwargs) self.category_id.choices = Category.get_list() if post: self.id = kwargs.get("id") if kwargs.get("id") else 0 self.title.data = post.title self.body.data = post.body self.extra_body.data = post.extra_body self.anonymous.data = post.anonymous self.category_id.data = post.category_id self.cover_picture_id.data = post.cover_picture_id
def __init__(self, post=None, *args, **kwargs): super(PostForm, self).__init__(*args, **kwargs) self.category_id.choices = Category.get_list() self.status.choices = Post.get_status_list() self.lang.choices = Post.get_language_list() if not post: language = str(get_locale()) self.lang.data = language if not self.is_submitted() and post: self.title.data = post.title self.body.data = post.body self.extra_body.data = post.extra_body self.anonymous.data = post.anonymous self.category_id.data = post.category_id self.status.data = post.status self.lang.data = post.lang self.cover_picture_id.data = post.cover_picture_id self.editor_version.data = post.editor_version
def new_article(): """Nuovo articolo""" form = NewArticleForm() form.categ.choices = [(-1, '--Selezionare una categoria--')] + \ Category.get_list(True) form.template.data = GeneratorConfig.get_template_def_name() form.publish_date.data = datetime.date.today() if form.validate_on_submit(): descr = form.description.data title = f"{form.name.data} - {form.purpose.data}" categ_id = form.categ.data filename = f'{form.name.data}.xml' lastmod = form.publish_date.data is_ind = form.add_to_index.data article = Article(title, categ_id, filename, lastmod, None, is_ind) db.session.add(article) db.session.commit() art_path = GeneratorConfig.get_boilerplate_article_path() with open(art_path) as fh: boilerplate_text = get_article_boilerplate(fh.read(), article, descr) session['boilerplate'] = boilerplate_text session['new_article_path'] = os.path.join( GeneratorConfig.get_translations_folder(), filename) return redirect(url_for('main.article_boilerplate')) data = dict() error = None session['boilerplate'] = None session['new_article_path'] = None return render_template("new_article.html", form=form, title="Nuovo Articolo", action='Inserisci')
def __init__(self, *args, **kwargs): super(TranferForm, self).__init__(*args, **kwargs) cat_list = Category.get_list() self.from_id.choices = cat_list self.to_id.choices = cat_list
def view_categories(current_user): return response_for_category_list(Category.get_list())
def __init__(self, *args, **kwargs): Form.__init__(self, *args, **kwargs) cat_list = Category.get_list() self.from_id.choices = cat_list self.to_id.choices = cat_list