aboutsummaryrefslogtreecommitdiff
path: root/budget
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2011-08-09 17:29:44 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2011-08-09 23:49:44 +0200
commit4b08af56f8c1e6bb25365a5bc691c5bdf3156458 (patch)
tree46144f4eb1ececb379434fd58a6a54a3c45448e2 /budget
parent0e5bab13af39d2fc7073860aa05279bcf9f19e82 (diff)
downloadihatemoney-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')
-rw-r--r--budget/templates/authenticate.html5
-rw-r--r--budget/web.py11
2 files changed, 12 insertions, 4 deletions
diff --git a/budget/templates/authenticate.html b/budget/templates/authenticate.html
index 8b57c67..d4f7df6 100644
--- a/budget/templates/authenticate.html
+++ b/budget/templates/authenticate.html
@@ -6,6 +6,11 @@
<p class=error>{{ ", ".join(errors) }}</p>
{% endfor %}
+{% if create_project %}
+<p class="info">The project you are trying to access do not exist, do you want
+to <a href="{{ url_for("create_project", project_id=create_project) }}">create it</a>?
+</p>
+{% endif %}
<form action="" method="POST" accept-charset="utf-8">
{{ form.hidden_tag() }}
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():