def post(self, category_id): """ Edits a category's name and description Args: category_id: category's id Returns: A template or a redirect if validation passes. """ category = Category.get_by_id(category_id) category_name = category.name form = CategoryForm() form.submit.label.text = 'Edit' if form.validate_on_submit(): category.update(form.name.data, form.description.data) flash('Category {0} has been edited.'.format(category_name), 'success') return redirect(url_for('blog.category', category_id=category.id)) return render_template('blog/category/edit.html', category=category, form=form)
def get(self, category_id): """ Edit a category name and description Args: category_id: category's id Returns: A template with the category form. """ form = CategoryForm() form.submit.label.text = 'Edit' return render_template('blog/category/edit.html', category=Category.get_by_id(category_id), form=form)