blob: 3491998be86e877b04ec07e14f104100d9b71f40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
from ..flask_extend import Blueprint
from flask import request
from ..utils import templated, redirect
from ..model import db, Category
mod = Blueprint('categories', __name__)
@mod.route("/", methods=("GET", "POST"))
@templated()
def manage ():
if request.method == "GET":
categories = Category.query.order_by(Category.name).all()
return { 'cats' : categories }
else:
for id, name in request.form.iteritems():
if id.startswith("n-"):
db.session.add(Category(name = name))
else:
Category.get(id).name = name
db.session.commit()
return redirect(".manage")
|