Commit a444ac844d9f0378c66b3534c576782a1719e8f8

Authored by Alexis Koralewski
1 parent dc5e48b6
Exists in dev

fixing listing of sp where user is involved to (v2), added button to propose a S…

…P that hasn't been proposed ever
src/core/pyros_django/misc/templates/base.html
... ... @@ -588,7 +588,7 @@ footer{
588 588 <footer class="sticky-footer">
589 589 <div>
590 590 <div class="text-right my-auto">
591   - <span>VERSION 0.2.3.1_2.0_3.6_2021-10-07</span>
  591 + <span>VERSION 0.2.4.0_2.0_3.6_2021-10-07</span>
592 592 </div>
593 593 </div>
594 594 </footer>
... ...
src/core/pyros_django/scientific_program/templates/scientific_program/scientific_program_detail.html
... ... @@ -31,7 +31,10 @@
31 31 {% with sp_periods|first as last_sp_period %}
32 32 {% if last_sp_period %}
33 33 <a class="btn btn-info" href="{% url 'repropose_scientific_program' id_SP=scientific_program.id id_SP_Period=last_sp_period.period.id %}"> Repropose this SP for a new exploitation period </a>
  34 + {% else %}
  35 + <a class="btn btn-info" href="{% url 'create_scientific_program_period' id_SP=scientific_program.id %}"> Propose this SP for a exploitation period </a>
34 36 {% endif %}
  37 +
35 38 {% endwith %}
36 39 {% endif %}
37 40 {% if CAN_DELETE_SP %}
... ...
src/core/pyros_django/scientific_program/views.py
... ... @@ -555,11 +555,11 @@ def scientific_program_list(request):
555 555 scientific_programs = ScientificProgram.objects.all().order_by("-id")
556 556 CAN_VIEW_ALL_SP = request.session.get("role") in ("Admin","Unit-PI","Unit-board")
557 557 CAN_VIEW_HIS_SP = request.session.get("role") == "Observer"
558   - if (len(scientific_programs) > 0):
559   - # get all SP that are in proposal
560   - sp_of_user = SP_Period_User.objects.filter(user=request.user.id).values("SP_Period").values("scientific_program")
561   - else:
562   - scientific_programs = None
  558 + if not CAN_VIEW_ALL_SP:
  559 + # get all SP associated to that user
  560 + sp_periods_of_user = SP_Period_User.objects.filter(user=request.user.id).values_list("SP_Period",flat=True)
  561 + list_of_sp_id = SP_Period.objects.filter(id__in=sp_periods_of_user).values("scientific_program")
  562 + sp_of_user = ScientificProgram.objects.filter(id__in=list_of_sp_id)
563 563  
564 564 return render(request, 'scientific_program/scientific_programs.html', {
565 565 'scientific_programs': scientific_programs,
... ...