Esempio n. 1
0
File: schedule.py Progetto: kzkn/fc
def schedule():
    info_msgs = []
    if g.user.has_not_registered_schedule_yet():
        info_msgs.append(u'未登録の練習があります:' +
                u'参加/不参加の登録をお願いします。<br>' +
                u'予定が未定な方は、とりあえず参加/不参加どちらかで登録' +
                u'して、あとで更新してもらっても構いません。')
    ps = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_PRACTICE)]
    gs = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_GAME)]
    es = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_EVENT)]
    return render_template('schedule.html',
                           practices=ps, games=gs, events=es,
                           info_msgs=info_msgs)
Esempio n. 2
0
File: mobile.py Progetto: kzkn/fc
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))
Esempio n. 3
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']))
Esempio n. 4
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']))
Esempio n. 5
0
File: mobile.py Progetto: kzkn/fc
def practices():
    user = users.find_by_id(get_userid())
    if not user:
        abort(401)
    ps = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_PRACTICE)]
    return render_template("mobile/practices.html", user=user, practices=ps)
Esempio n. 6
0
File: mobile.py Progetto: kzkn/fc
def non_registered_practices():
    user = users.find_by_id(get_userid())
    if not user:
        abort(401)
    ps = [scheds.from_row(s) for s in scheds.find_non_registered(user.id, scheds.TYPE_PRACTICE)]
    return render_template("mobile/practices.html", user=user, practices=ps, info_msg=u"未登録の練習があります。")
Esempio n. 7
0
File: mobile.py Progetto: kzkn/fc
def events():
    user = users.find_by_id(get_userid())
    if not user:
        abort(401)
    es = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_EVENT)]
    return render_template("mobile/events.html", user=user, events=es)
Esempio n. 8
0
File: mobile.py Progetto: kzkn/fc
def games():
    user = users.find_by_id(get_userid())
    if not user:
        abort(401)
    gs = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_GAME)]
    return render_template("mobile/games.html", user=user, games=gs)
Esempio n. 9
0
def show_event(id):
    s = scheds.from_row(scheds.find_by_id(id))
    return render_template("admin/show_event.html", schedule=s)
Esempio n. 10
0
def event_history():
    es = [scheds.from_row(s) for s in scheds.find_dones(scheds.TYPE_EVENT)]
    ys, es = schedules_group_by_year(es)
    return render_template('admin/event_history.html', years=ys, events=es)
Esempio n. 11
0
def game_history():
    gs = [scheds.from_row(s) for s in scheds.find_dones(scheds.TYPE_GAME)]
    ys, gs = schedules_group_by_year(gs)
    return render_template('admin/game_history.html', years=ys, games=gs)
Esempio n. 12
0
def practice_history():
    ps = [scheds.from_row(s) for s in scheds.find_dones(scheds.TYPE_PRACTICE)]
    ys, ps = schedules_group_by_year(ps)
    return render_template('admin/practice_history.html', years=ys, practices=ps)
Esempio n. 13
0
def event():
    es = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_EVENT)]
    return render_template('admin/event.html', events=es)
Esempio n. 14
0
def game():
    gs = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_GAME)]
    return render_template('admin/game.html', games=gs)
Esempio n. 15
0
def practice():
    ps = [scheds.from_row(s) for s in scheds.find(scheds.TYPE_PRACTICE)]
    return render_template('admin/practice.html', practices=ps)