Commit 46423b05801ec5356c49e46f95c294b004bf853e

Authored by pyros_astroguita
1 parent 0dcacc3a
Exists in dev

add view for quota

src/core/pyros_django/scp_mgmt/templates/scp_mgmt/quota_sp.html 0 → 100644
@@ -0,0 +1,128 @@ @@ -0,0 +1,128 @@
  1 +{% extends "base.html" %}
  2 +
  3 +{% load tags %}
  4 +{% block content %}
  5 +
  6 +<style>
  7 + .institute{
  8 + background-color: aqua;
  9 + }
  10 + .sp{
  11 + background-color: aquamarine;
  12 + }
  13 +</style>
  14 +<table class="table table-sm table-bordered tablesorter">
  15 + <thead>
  16 + <tr>
  17 + <td> name </td>
  18 + <td> quota_f </td>
  19 + <td> <b> d_total </b> </td>
  20 + <td> d_totalq </td>
  21 + <td> d_totalx </td>
  22 + <td> <b> d_previous </b> </td>
  23 + <td> d_previousq </td>
  24 + <td> d_previousx </td>
  25 + <td> <b> d_current </b> </td>
  26 + <td> d_currentq </td>
  27 + <td> d_currentx </td>
  28 + <td> <b> d_passed </b> </td>
  29 + <td> d_passedq </td>
  30 + <td> d_passedx </td>
  31 + <td> <b> d_schedule </b> </td>
  32 + <td> d_scheduleq </td>
  33 + <td> d_schedulex </td>
  34 + <td> <b> d_next </b> </td>
  35 + <td> d_nextq </td>
  36 + <td> d_nextx </td>
  37 + </tr>
  38 + </thead>
  39 + <tr class="current_night">
  40 + <td> Current night : {{ current_night }} </td>
  41 + <td> </td>
  42 + <td> <b>{{quota_current_night.d_total}}</b> </td>
  43 + <td>{{quota_current_night.d_totalq}}</td>
  44 + <td>{{quota_current_night.d_totalx}}</td>
  45 +
  46 + <td> <b>{{quota_current_night.d_previous}}</b> </td>
  47 + <td>{{quota_current_night.d_previousq}}</td>
  48 + <td>{{quota_current_night.d_previousx}}</td>
  49 +
  50 + <td> <b>{{quota_current_night.d_current}}</b> </td>
  51 + <td>{{quota_current_night.d_currentq}}</td>
  52 + <td>{{quota_current_night.d_currentx}}</td>
  53 +
  54 + <td> <b>{{quota_current_night.d_passed}}</b> </td>
  55 + <td>{{quota_current_night.d_passedq}}</td>
  56 + <td>{{quota_current_night.d_passedx}}</td>
  57 +
  58 + <td> <b>{{quota_current_night.d_schedule}}</b> </td>
  59 + <td>{{quota_current_night.d_scheduleq}}</td>
  60 + <td>{{quota_current_night.d_schedulex}} </td>
  61 +
  62 + <td> <b>{{quota_current_night.d_next}}</b> </td>
  63 + <td>{{quota_current_night.d_nextq}}</td>
  64 + <td>{{quota_current_night.d_nextx}}</td>
  65 + </tr>
  66 + {% for institute in institutes %}
  67 + <tr class="institute">
  68 + <td> Institute :{{institute}} </td>
  69 + <td>{{institute.quota_f}} </td>
  70 + <td> <b>{{institute.quota.d_total}}</b> </td>
  71 + <td>{{institute.quota.d_totalq}}</td>
  72 + <td>{{institute.quota.d_totalx}}</td>
  73 +
  74 + <td> <b>{{institute.quota.d_previous}}</b> </td>
  75 + <td>{{institute.quota.d_previousq}}</td>
  76 + <td>{{institute.quota.d_previousx}}</td>
  77 +
  78 + <td> <b>{{institute.quota.d_current}}</b> </td>
  79 + <td>{{institute.quota.d_currentq}}</td>
  80 + <td>{{institute.quota.d_currentx}}</td>
  81 +
  82 + <td> <b>{{institute.quota.d_passed}}</b> </td>
  83 + <td>{{institute.quota.d_passedq}}</td>
  84 + <td>{{institute.quota.d_passedx}}</td>
  85 +
  86 + <td> <b>{{institute.quota.d_schedule}}</b> </td>
  87 + <td>{{institute.quota.d_scheduleq}}</td>
  88 + <td>{{institute.quota.d_schedulex}} </td>
  89 +
  90 + <td> <b>{{institute.quota.d_next}}</b> </td>
  91 + <td>{{institute.quota.d_nextq}}</td>
  92 + <td>{{institute.quota.d_nextx}}</td>
  93 + </tr>
  94 + {% for sp in institute.scientific_programs.all %}
  95 + <tr class="sp">
  96 + <td>Scientific program: {{sp.name}} </td>
  97 + <td>{{sp.quota_f}} </td>
  98 + <td> <b>{{sp.quota.d_total}}</b> </td>
  99 + <td>{{sp.quota.d_totalq}}</td>
  100 + <td>{{sp.quota.d_totalx}}</td>
  101 +
  102 + <td> <b>{{sp.quota.d_previous}}</b> </td>
  103 + <td>{{sp.quota.d_previousq}}</td>
  104 + <td>{{sp.quota.d_previousx}}</td>
  105 +
  106 + <td> <b>{{sp.quota.d_current}}</b> </td>
  107 + <td>{{sp.quota.d_currentq}}</td>
  108 + <td>{{sp.quota.d_currentx}}</td>
  109 +
  110 + <td> <b>{{sp.quota.d_passed}}</b> </td>
  111 + <td>{{sp.quota.d_passedq}}</td>
  112 + <td>{{sp.quota.d_passedx}}</td>
  113 +
  114 + <td> <b>{{sp.quota.d_schedule}}</b> </td>
  115 + <td>{{sp.quota.d_scheduleq}}</td>
  116 + <td>{{sp.quota.d_schedulex}} </td>
  117 +
  118 + <td> <b>{{sp.quota.d_next}}</b> </td>
  119 + <td>{{sp.quota.d_nextq}}</td>
  120 + <td>{{sp.quota.d_nextx}}</td>
  121 + </tr>
  122 + {% endfor %}
  123 +
  124 + {% endfor %}
  125 +
  126 +
  127 +
  128 +{% endblock %}
src/core/pyros_django/scp_mgmt/urls.py
@@ -43,5 +43,7 @@ urlpatterns = [ @@ -43,5 +43,7 @@ urlpatterns = [
43 path("detail_science_theme/<int:id>/",views.detail_science_theme,name="detail_science_theme"), 43 path("detail_science_theme/<int:id>/",views.detail_science_theme,name="detail_science_theme"),
44 path("edit_science_theme/<int:id>/",views.edit_science_theme,name="edit_science_theme"), 44 path("edit_science_theme/<int:id>/",views.edit_science_theme,name="edit_science_theme"),
45 path("delete_science_theme/<int:id>/",views.delete_science_theme,name="delete_science_theme"), 45 path("delete_science_theme/<int:id>/",views.delete_science_theme,name="delete_science_theme"),
46 - path("test_tac_auto",views.test_tac_auto,name="test_tac_auto") 46 + path("test_tac_auto",views.test_tac_auto,name="test_tac_auto"),
  47 + # quota
  48 + path("quota_sp",views.quota_sp,name="quota_sp")
47 ] 49 ]
src/core/pyros_django/scp_mgmt/views.py
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 from datetime import date, datetime 2 from datetime import date, datetime
3 from dateutil.relativedelta import relativedelta 3 from dateutil.relativedelta import relativedelta
4 import matplotlib.pyplot as plt 4 import matplotlib.pyplot as plt
5 -import re,io,urllib,base64 5 +import re,io,urllib,base64, os
6 6
7 # Django imports 7 # Django imports
8 from django.http.response import HttpResponse 8 from django.http.response import HttpResponse
@@ -22,12 +22,12 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger @@ -22,12 +22,12 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
22 from dashboard.config_pyros import ConfigPyros 22 from dashboard.config_pyros import ConfigPyros
23 from .functions import get_global_svg_timeline, get_svg_timeline, get_proposal_svg_timeline 23 from .functions import get_global_svg_timeline, get_svg_timeline, get_proposal_svg_timeline
24 from user_mgmt.models import ScientificProgram, Institute, Period, SP_Period_User, SP_Period, PyrosUser, SP_Period_Guest, ScienceTheme #, UserLevel 24 from user_mgmt.models import ScientificProgram, Institute, Period, SP_Period_User, SP_Period, PyrosUser, SP_Period_Guest, ScienceTheme #, UserLevel
25 -from seq_submit.models import Sequence 25 +from seq_submit.models import Sequence, Quota
26 #from src.core.pyros_django import scientific_program 26 #from src.core.pyros_django import scientific_program
27 from .forms import PeriodForm, ScienceThemeForm, ScientificProgramForm, InstituteForm, SP_PeriodForm,TACAssociationForm 27 from .forms import PeriodForm, ScienceThemeForm, ScientificProgramForm, InstituteForm, SP_PeriodForm,TACAssociationForm
28 from src.core.pyros_django.dashboard.decorator import level_required 28 from src.core.pyros_django.dashboard.decorator import level_required
29 29
30 - 30 +from src.core.pyros_django.obs_config.obsconfig_class import OBSConfig
31 31
32 32
33 33
@@ -807,6 +807,18 @@ def institute_list(request): @@ -807,6 +807,18 @@ def institute_list(request):
807 }) 807 })
808 808
809 809
  810 +@login_required
  811 +@level_required("Admin", "Unit-PI", "Observer", "Operator", "TAC", "Management board member")
  812 +def quota_sp(request):
  813 + institutes = Institute.objects.all()
  814 + scientific_programs = ScientificProgram.objects.all()
  815 + config = OBSConfig(os.environ["PATH_TO_OBSCONF_FILE"],os.environ["unit_name"])
  816 + current_night = config.fn.date2night("now")
  817 + current_period = Period.objects.exploitation_period()
  818 + quota_current_night = Quota.objects.get(id_period=current_period.id, night_id=current_night)
  819 + return render(request, 'scp_mgmt/quota_sp.html', locals())
  820 +
  821 +
810 # Exploitation Periods CRUD 822 # Exploitation Periods CRUD
811 823
812 @login_required 824 @login_required