diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2011-08-09 17:29:44 +0200 |
|---|---|---|
| committer | Alexis Metaireau <alexis@notmyidea.org> | 2011-08-09 23:49:44 +0200 |
| commit | 4b08af56f8c1e6bb25365a5bc691c5bdf3156458 (patch) | |
| tree | 46144f4eb1ececb379434fd58a6a54a3c45448e2 /budget/web.py | |
| parent | 0e5bab13af39d2fc7073860aa05279bcf9f19e82 (diff) | |
| download | ihatemoney-mirror-4b08af56f8c1e6bb25365a5bc691c5bdf3156458.zip ihatemoney-mirror-4b08af56f8c1e6bb25365a5bc691c5bdf3156458.tar.gz ihatemoney-mirror-4b08af56f8c1e6bb25365a5bc691c5bdf3156458.tar.bz2 | |
Do not redirect users to the creation form when they are trying to log in.
Fixes #9
Diffstat (limited to 'budget/web.py')
| -rw-r--r-- | budget/web.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/budget/web.py b/budget/web.py index 6b3849f..049fae9 100644 --- a/budget/web.py +++ b/budget/web.py @@ -28,16 +28,18 @@ def authenticate(redirect_url=None): redirect_url = redirect_url or url_for("list_bills", project_id=project_id) project = Project.query.get(project_id) + create_project = False # We don't want to create the project by default if not project: - flash("This project doesn't exist (yet). You can create it by filling this form") - return redirect(url_for("create_project", project_id=project_id)) + # But if the user try to connect to an unexisting project, we will + # propose him a link to the creation form. + create_project = project_id # if credentials are already in session, redirect if project_id in session and project.password == session[project_id]: return redirect(redirect_url) # else process the form - if request.method == "POST": + if project and request.method == "POST": if form.validate(): if not form.password.data == project.password: form.errors['password'] = ["The password is not the right one"] @@ -51,7 +53,8 @@ def authenticate(redirect_url=None): session.update() return redirect(redirect_url) - return render_template("authenticate.html", form=form) + return render_template("authenticate.html", form=form, + create_project=create_project) @app.route("/create", methods=["GET", "POST"]) def create_project(): |
