view frontend/mfrontend/views/jobcontrol.py @ 21:9a45dfaec157

To by było, miejmy nadzieję, na tyle w kwestii szablonu CSV
author Michał Rudowicz <michal.rudowicz@fl9.eu>
date Mon, 11 Apr 2011 09:50:23 +0200
parents c87f82a15606
children 28eb82047167
line wrap: on
line source

#!/usr/bin/python
# -*- coding: utf-8 -*-

from flask import Module, render_template, request, url_for
from flask import escape, session, redirect, flash, abort, g
from mfrontend import db, utils, exceptions, decorators
jobcontrol = Module(__name__)

@jobcontrol.route('/')
@decorators.login_required
def index():
    jobs = db.get_jobs(None, None, None)
    return render_template('joblist.html', jobs=jobs)

@jobcontrol.route('/add/', methods=['GET', 'POST'])
@decorators.login_required
def add():
    if request.method == 'POST':
        try:
            db.new_job(session['user_id'],
                        request.form["label"],
                        request.form["hash"],
                        request.form["method"])
            return redirect(url_for('index'))
        except Exception as e:
            flash(e)
    return render_template('newjob.html')