def create_profile(): """If this is the user's first login, the create_or_login function will redirect here so that the user can set up his profile. """ if g.user.is_authenticated() or "openid" not in session: return redirect(url_for("index")) form = ProfileForm() if form.validate_on_submit(): flash(u"Profile successfully created", "success") user = User(session["openid"]) user.email = form.email.data user.name = form.name.data db.session.add(user) db.session.commit() login_user(user) session.pop("openid") notify_admins_new_user(user) return redirect(oid.get_next_url()) if request.method == "GET": form.name.data = request.args.get("name") form.email.data = request.args.get("email") return render_template("create_profile.html", next_url=oid.get_next_url(), errors=form.errors, form=form)
def poke(doit=False): keyholders = User.query_keyholders().all() for k in keyholders: for key in k.keys: if key.allocated: continue if key.last_activity.days in (3, 5, 7) or key.last_activity.days >= 10: notify_stale_keyholder(k, key, doit=doit)
def init_db(): db.create_all() for k in 'Zuse Lovelace Colmar Turing Pascal Yazu Babbage Napier'.split(): db.session.add(Key(name=k)) u = User('olt') u.is_keyholder = True u.is_admin = True db.session.add(u) u = User(None) u.is_keymanager = True u.name = "Surfstation" db.session.add(u) db.session.commit()
def keys(): keys = Key.query_ordered().all() keyholders = User.query_keyholders().all() return render_template("keys.html", keys=keys, keyholders=keyholders)
def index(): keys = Key.query_ordered().all() keyholders = [] if g.user.is_keyholder: keyholders = User.query_keyholders().all() return render_template("index.html", keys=keys, keyholders=keyholders)