Remember last-visited Attract project in session
This allows us to keep rendering the "Shots" and "Assets" links in the sidebar, even when someone navigates away from the project scope.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import functools
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, render_template, redirect, url_for, request, jsonify
|
||||
from flask import Blueprint, render_template, redirect, url_for, request, jsonify, session
|
||||
import flask_login
|
||||
import werkzeug.exceptions as wz_exceptions
|
||||
|
||||
@@ -131,6 +131,8 @@ def attract_project_view(extra_project_projections: dict=None, extension_props=F
|
||||
if not is_attract:
|
||||
return error_project_not_setup_for_attract()
|
||||
|
||||
session['attract_last_project'] = project.to_dict()
|
||||
|
||||
# Check user access.
|
||||
auth = current_attract.auth
|
||||
auth.determine_user_rights(str2id(project['_id']))
|
||||
|
@@ -37,16 +37,17 @@ html(lang="en")
|
||||
a.navbar-item.attract(href="{{ url_for('attract.index') }}",
|
||||
title='Attract')
|
||||
i.pi-attract
|
||||
| {% if project %}
|
||||
| {% if session.get('attract_last_project') %}
|
||||
| {% set attract_last_project = session.get('attract_last_project') %}
|
||||
li
|
||||
a.navbar-item.tasks(href="{{ url_for('attract.tasks.perproject.index', project_url=project.url) }}",
|
||||
title='Tasks for project {{ project.name }}') Tasks
|
||||
a.navbar-item.tasks(href="{{ url_for('attract.tasks.perproject.index', project_url=attract_last_project.url) }}",
|
||||
title='Tasks for project {{ attract_last_project.name }}') Tasks
|
||||
li
|
||||
a.navbar-item.shots(href="{{ url_for('attract.shots.perproject.index', project_url=project.url) }}",
|
||||
title='Shots for project {{ project.name }}') Shots
|
||||
a.navbar-item.shots(href="{{ url_for('attract.shots.perproject.index', project_url=attract_last_project.url) }}",
|
||||
title='Shots for project {{ attract_last_project.name }}') Shots
|
||||
li
|
||||
a.navbar-item.assets(href="{{ url_for('attract.assets.perproject.index', project_url=project.url) }}",
|
||||
title='Assets for project {{ project.name }}') Assets
|
||||
a.navbar-item.assets(href="{{ url_for('attract.assets.perproject.index', project_url=attract_last_project.url) }}",
|
||||
title='Assets for project {{ attract_last_project.name }}') Assets
|
||||
| {% else %}
|
||||
| {% if current_user.is_authenticated %}
|
||||
li
|
||||
|
Reference in New Issue
Block a user