Exemple #1
0
def find_user_and_schedule(sid):
    user = users.find_by_id(get_userid())
    if not user:
        abort(401)
    s = scheds.find_by_id(sid)
    if not s:
        abort(404)
    return (user, scheds.from_row(s))
Exemple #2
0
def edit_schedule(id, module):
    if request.method == 'GET':
        s = scheds.from_row(scheds.find_by_id(id, with_entry=False))
        return render_template(module['edit_template'], schedule=s)
    else:
        moduletype = module['type']
        logi('edit schedule: type=%d, sid=%d', moduletype, id)
        try:
            module['validate']()
        except ValueError, e:
            logi('edit schedule: validation error type=%d, sid=%d, errors=%s', moduletype, id, e.errors.keys())
            s = scheds.from_row(scheds.find_by_id(id, with_entry=False))
            return render_template(module['edit_template'], schedule=s,
                    errors=e.errors)

        obj = module['make_obj'](request.form)
        logi('edit schedule: update type=%d, sid=%d, when=%s, body=%s', moduletype, id, obj['when'], obj['body'])
        scheds.update(id, obj['when'], obj['body'])
        return redirect(url_for(module['index']))
Exemple #3
0
def delete_schedule(id, module):
    if request.method == 'GET':
        s = scheds.from_row(scheds.find_by_id(id))
        return render_template(module['delete_template'], schedule=s)
    else:
        if is_yes():
            logi('delete schedule: type=%d, sid=%d', module['type'], id)
            scheds.delete_by_id(id)
        else:
            logi('not delete schedule: type=%d, sid=%d', module['type'], id)
        return redirect(url_for(module['index']))
Exemple #4
0
def show_event(id):
    s = scheds.from_row(scheds.find_by_id(id))
    return render_template("admin/show_event.html", schedule=s)