summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2013-10-15 23:32:39 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2013-10-15 23:32:39 +0200
commit821ed2fd7fa725c7bd0353fd3f5a7e843198682d (patch)
treeffcac35060b31a26ac4933dc7fef87cff047e354 /app/views
parente34e288bc5713a5a34958be8e678d2b23f4c7adb (diff)
downloadkosten-821ed2fd7fa725c7bd0353fd3f5a7e843198682d.tar.gz
kosten-821ed2fd7fa725c7bd0353fd3f5a7e843198682d.tar.bz2
kosten-821ed2fd7fa725c7bd0353fd3f5a7e843198682d.zip
Quotestyle
Diffstat (limited to 'app/views')
-rw-r--r--app/views/__init__.py38
-rw-r--r--app/views/categories.py8
-rw-r--r--app/views/consts.py22
-rw-r--r--app/views/expenses.py22
-rw-r--r--app/views/login.py8
5 files changed, 49 insertions, 49 deletions
diff --git a/app/views/__init__.py b/app/views/__init__.py
index 275a6c9..101f393 100644
--- a/app/views/__init__.py
+++ b/app/views/__init__.py
@@ -12,52 +12,52 @@ from ..flask_extend import Blueprint
from flask import flash
__all__ = [
- "db", "app",
- "current_user", "login_required",
- "templated", "redirect",
- "Blueprint", "flash",
- "request", "url_for"
+ 'db', 'app',
+ 'current_user', 'login_required',
+ 'templated', 'redirect',
+ 'Blueprint', 'flash',
+ 'request', 'url_for'
]
# check for mobile visitors
-mobile_checks = ["J2ME", "Opera Mini"]
+mobile_checks = ['J2ME', 'Opera Mini']
app.add_template_global(zip)
@app.before_request
def handle_mobile():
- ua = request.environ.get("HTTP_USER_AGENT", "")
+ ua = request.environ.get('HTTP_USER_AGENT', '')
flask.g.is_mobile = any((x in ua) for x in mobile_checks)
-@app.template_filter("static_url")
+@app.template_filter('static_url')
def static_url(s, **kwargs):
- return url_for("static", filename=s, **kwargs)
+ return url_for('static', filename=s, **kwargs)
-@app.template_filter("eur")
+@app.template_filter('eur')
def eur(s):
- return (u"%s EUR" % s)
+ return (u'%s EUR' % s)
-@app.template_filter("date")
-def format_date(s, format="%Y/%m"):
- if hasattr(s, "date"):
+@app.template_filter('date')
+def format_date(s, format='%Y/%m'):
+ if hasattr(s, 'date'):
return s.date.strftime(format)
else:
return s.strftime(format)
@app.errorhandler(404)
def page_not_found (error):
- return render_template("404.jinja", page = request.path), 404
+ return render_template('404.jinja', page = request.path), 404
# Now import the views
from . import categories, consts, expenses, login, api
app.register_blueprint(login.mod)
app.register_blueprint(expenses.mod)
-app.register_blueprint(consts.mod, url_prefix="/const")
-app.register_blueprint(categories.mod, url_prefix="/cat")
+app.register_blueprint(consts.mod, url_prefix='/const')
+app.register_blueprint(categories.mod, url_prefix='/cat')
for m in api.mods:
- app.register_blueprint(m, url_prefix="/api")
+ app.register_blueprint(m, url_prefix='/api')
-app.add_url_rule("/", endpoint = "index", build_only = True)
+app.add_url_rule('/', endpoint = 'index', build_only = True)
diff --git a/app/views/categories.py b/app/views/categories.py
index 1857737..347828b 100644
--- a/app/views/categories.py
+++ b/app/views/categories.py
@@ -6,22 +6,22 @@ from ..model import Category
mod = Blueprint('categories', __name__)
-@mod.route("/", methods=("GET", "POST"))
+@mod.route('/', methods=('GET', 'POST'))
@login_required
@templated()
def manage ():
- if request.method == "GET":
+ if request.method == 'GET':
categories = Category.of(current_user).order_by(Category.name).all()
return { 'cats' : categories }
else:
for id, name in request.form.iteritems():
- if id.startswith("n-"):
+ if id.startswith('n-'):
db.session.add(Category(name = name, user = current_user))
else:
Category.get(id).name = name
db.session.commit()
- return redirect(".manage")
+ return redirect('.manage')
diff --git a/app/views/consts.py b/app/views/consts.py
index d41e683..20b3db1 100644
--- a/app/views/consts.py
+++ b/app/views/consts.py
@@ -28,7 +28,7 @@ def const_form(cur=None, obj=None):
return form
-@mod.route("/")
+@mod.route('/')
@login_required
@templated()
def list ():
@@ -51,35 +51,35 @@ def list ():
return { 'current': current, 'old': old, 'future': future }
-@mod.route("/<int:id>")
+@mod.route('/<int:id>')
@login_required
@templated()
def show(id):
return { 'exp': ConstExpense.get(id) }
-@mod.route("/edit/<int:id>", methods=("GET", "POST"))
+@mod.route('/edit/<int:id>', methods=('GET', 'POST'))
@login_required
@templated()
def edit(id):
exp = ConstExpense.get(id)
form = const_form(exp)
- if request.method == "POST":
- if "deleteB" in request.form:
+ if request.method == 'POST':
+ if 'deleteB' in request.form:
db.session.delete(exp)
db.session.commit()
- return redirect(".list")
+ return redirect('.list')
elif form.validate(): # change
form.populate_obj(exp)
db.session.commit()
- return redirect(".show", id = id)
+ return redirect('.show', id = id)
return { 'form': form }
-@mod.route("/add/from/<int:other>")
+@mod.route('/add/from/<int:other>')
@login_required
-@templated(".add")
+@templated('.add')
def add_from(other):
exp = ConstExpense() # needed to initialize 'CE.next'
@@ -96,7 +96,7 @@ def add_from(other):
return { 'form': form }
-@mod.route("/add/", methods=("GET", "POST"))
+@mod.route('/add/', methods=('GET', 'POST'))
@login_required
@templated()
def add ():
@@ -109,6 +109,6 @@ def add ():
exp.user = current_user
db.session.add(exp)
db.session.commit()
- return redirect(".show", id = exp.id)
+ return redirect('.show', id = exp.id)
return { 'form': form }
diff --git a/app/views/expenses.py b/app/views/expenses.py
index 8946377..f5181e9 100644
--- a/app/views/expenses.py
+++ b/app/views/expenses.py
@@ -53,20 +53,20 @@ def next_date(exp):
else:
return exp.date.replace(month = exp.date.month + 1)
-@mod.app_template_test("last_date")
+@mod.app_template_test('last_date')
def is_last(exp):
return exp.date >= datetime.date.today().replace(day = 1)
-@mod.route("/<int(fixed_digits=4):year>/<int(fixed_digits=2):month>")
+@mod.route('/<int(fixed_digits=4):year>/<int(fixed_digits=2):month>')
@login_required
-@templated(".show")
+@templated('.show')
def show_date(year, month):
c,p = calc_month_and_pie(year, month)
return { 'exps' : [c], 'pies' : [p] }
-mod.add_url_rule("/<path:p>", endpoint = "show_date_str", build_only = True)
+mod.add_url_rule('/<path:p>', endpoint = 'show_date_str', build_only = True)
-@mod.route("/")
+@mod.route('/')
@login_required
@templated()
def show():
@@ -80,15 +80,15 @@ def show():
return { 'exps' : [first, second], 'pies': [pfirst, psecond] }
-@mod.route("/edit/<int:id>", methods=("GET", "POST"))
+@mod.route('/edit/<int:id>', methods=('GET', 'POST'))
@login_required
@templated()
def edit(id):
exp = SingleExpense.get(id)
form = expense_form(exp)
- if request.method == "POST":
- if "deleteB" in request.form:
+ if request.method == 'POST':
+ if 'deleteB' in request.form:
db.session.delete(exp)
elif form.validate(): # change
@@ -98,11 +98,11 @@ def edit(id):
return { 'form': form }
db.session.commit()
- return redirect("index")
+ return redirect('index')
return { 'form': form }
-@mod.route("/add/", methods=("GET", "POST"))
+@mod.route('/add/', methods=('GET', 'POST'))
@login_required
@templated()
def add():
@@ -117,6 +117,6 @@ def add():
db.session.add(exp)
db.session.commit()
- return redirect(".add")
+ return redirect('.add')
return { 'form': form }
diff --git a/app/views/login.py b/app/views/login.py
index 8815626..333a330 100644
--- a/app/views/login.py
+++ b/app/views/login.py
@@ -10,20 +10,20 @@ from flask import redirect
mod = Blueprint('login', __name__)
-@mod.route("/login", methods=("GET", "POST"))
+@mod.route('/login', methods=('GET', 'POST'))
@templated()
def login():
form = LoginForm(flash=u"Login fehlgeschlagen!")
if form.validate_on_submit():
login_user(form.user)
- return redirect(request.args.get("next") or url_for("index"))
+ return redirect(request.args.get('next') or url_for('index'))
return { 'form': form }
-@mod.route("/logout")
+@mod.route('/logout')
def logout():
logout_user()
- return redirect(url_for(".login"))
+ return redirect(url_for('.login'))
login_manager.login_view = 'login.login'