From a444ac844d9f0378c66b3534c576782a1719e8f8 Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Thu, 7 Oct 2021 14:42:15 +0200 Subject: [PATCH] fixing listing of sp where user is involved to (v2), added button to propose a SP that hasn't been proposed ever --- src/core/pyros_django/misc/templates/base.html | 2 +- src/core/pyros_django/scientific_program/templates/scientific_program/scientific_program_detail.html | 3 +++ src/core/pyros_django/scientific_program/views.py | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/pyros_django/misc/templates/base.html b/src/core/pyros_django/misc/templates/base.html index 2ce9686..3c6e1ea 100644 --- a/src/core/pyros_django/misc/templates/base.html +++ b/src/core/pyros_django/misc/templates/base.html @@ -588,7 +588,7 @@ footer{ diff --git a/src/core/pyros_django/scientific_program/templates/scientific_program/scientific_program_detail.html b/src/core/pyros_django/scientific_program/templates/scientific_program/scientific_program_detail.html index c8485ba..3cb1707 100644 --- a/src/core/pyros_django/scientific_program/templates/scientific_program/scientific_program_detail.html +++ b/src/core/pyros_django/scientific_program/templates/scientific_program/scientific_program_detail.html @@ -31,7 +31,10 @@ {% with sp_periods|first as last_sp_period %} {% if last_sp_period %} Repropose this SP for a new exploitation period + {% else %} + Propose this SP for a exploitation period {% endif %} + {% endwith %} {% endif %} {% if CAN_DELETE_SP %} diff --git a/src/core/pyros_django/scientific_program/views.py b/src/core/pyros_django/scientific_program/views.py index 8ec5cd2..e68c0cb 100644 --- a/src/core/pyros_django/scientific_program/views.py +++ b/src/core/pyros_django/scientific_program/views.py @@ -555,11 +555,11 @@ def scientific_program_list(request): scientific_programs = ScientificProgram.objects.all().order_by("-id") CAN_VIEW_ALL_SP = request.session.get("role") in ("Admin","Unit-PI","Unit-board") CAN_VIEW_HIS_SP = request.session.get("role") == "Observer" - if (len(scientific_programs) > 0): - # get all SP that are in proposal - sp_of_user = SP_Period_User.objects.filter(user=request.user.id).values("SP_Period").values("scientific_program") - else: - scientific_programs = None + if not CAN_VIEW_ALL_SP: + # get all SP associated to that user + sp_periods_of_user = SP_Period_User.objects.filter(user=request.user.id).values_list("SP_Period",flat=True) + list_of_sp_id = SP_Period.objects.filter(id__in=sp_periods_of_user).values("scientific_program") + sp_of_user = ScientificProgram.objects.filter(id__in=list_of_sp_id) return render(request, 'scientific_program/scientific_programs.html', { 'scientific_programs': scientific_programs, -- libgit2 0.21.2