mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
List the projects in session into the home page.
This allows easier access when people don't remembre the name / url of their projects.
This commit is contained in:
parent
2df6e11f05
commit
3417a5a7d4
2 changed files with 14 additions and 8 deletions
|
@ -12,12 +12,14 @@
|
||||||
<p>{{ auth_form.password.label }}<br /> {{ auth_form.password }}</p>
|
<p>{{ auth_form.password.label }}<br /> {{ auth_form.password }}</p>
|
||||||
<p>{{ auth_form.submit }}</p>
|
<p>{{ auth_form.submit }}</p>
|
||||||
</form>
|
</form>
|
||||||
|
{% if 'projects' in session %}
|
||||||
<h3>Recently visisted projects</h3>
|
<h3>Recently visisted projects</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for project in session['projects'] %}
|
{% for id, name in session['projects'] %}
|
||||||
<li>{{ project }}</li>
|
<li><a href="{{ url_for("list_bills", project_id=id) }}">{{ name }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form class="span-10 last" action="{{ url_for('create_project') }}" method="post" class="container span-24 add-bill">
|
<form class="span-10 last" action="{{ url_for('create_project') }}" method="post" class="container span-24 add-bill">
|
||||||
|
|
|
@ -15,7 +15,8 @@ mail = Mail()
|
||||||
def home():
|
def home():
|
||||||
project_form = ProjectForm()
|
project_form = ProjectForm()
|
||||||
auth_form = AuthenticationForm()
|
auth_form = AuthenticationForm()
|
||||||
return render_template("home.html", project_form=project_form, auth_form=auth_form)
|
return render_template("home.html", project_form=project_form,
|
||||||
|
auth_form=auth_form, session=session)
|
||||||
|
|
||||||
@app.route("/authenticate", methods=["GET", "POST"])
|
@app.route("/authenticate", methods=["GET", "POST"])
|
||||||
def authenticate(redirect_url=None):
|
def authenticate(redirect_url=None):
|
||||||
|
@ -40,7 +41,10 @@ def authenticate(redirect_url=None):
|
||||||
form.errors['password'] = ["The password is not the right one"]
|
form.errors['password'] = ["The password is not the right one"]
|
||||||
else:
|
else:
|
||||||
# maintain a list of visited projects
|
# maintain a list of visited projects
|
||||||
session["projects"].append(project_id)
|
if "projects" not in session:
|
||||||
|
session["projects"] = []
|
||||||
|
# add the project on the top of the list
|
||||||
|
session["projects"].insert(0, (project_id, project.name))
|
||||||
session[project_id] = form.password.data
|
session[project_id] = form.password.data
|
||||||
session.update()
|
session.update()
|
||||||
return redirect(redirect_url)
|
return redirect(redirect_url)
|
||||||
|
|
Loading…
Add table
Reference in a new issue