From 46423b05801ec5356c49e46f95c294b004bf853e Mon Sep 17 00:00:00 2001 From: pyros_astroguita Date: Thu, 19 Oct 2023 20:53:38 +0200 Subject: [PATCH] add view for quota --- src/core/pyros_django/scp_mgmt/templates/scp_mgmt/quota_sp.html | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/core/pyros_django/scp_mgmt/urls.py | 4 +++- src/core/pyros_django/scp_mgmt/views.py | 18 +++++++++++++++--- 3 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 src/core/pyros_django/scp_mgmt/templates/scp_mgmt/quota_sp.html diff --git a/src/core/pyros_django/scp_mgmt/templates/scp_mgmt/quota_sp.html b/src/core/pyros_django/scp_mgmt/templates/scp_mgmt/quota_sp.html new file mode 100644 index 0000000..aa33038 --- /dev/null +++ b/src/core/pyros_django/scp_mgmt/templates/scp_mgmt/quota_sp.html @@ -0,0 +1,128 @@ +{% extends "base.html" %} + +{% load tags %} +{% block content %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% for institute in institutes %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% for sp in institute.scientific_programs.all %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% endfor %} + + {% endfor %} + + + +{% endblock %} diff --git a/src/core/pyros_django/scp_mgmt/urls.py b/src/core/pyros_django/scp_mgmt/urls.py index 93d3227..c7b9753 100644 --- a/src/core/pyros_django/scp_mgmt/urls.py +++ b/src/core/pyros_django/scp_mgmt/urls.py @@ -43,5 +43,7 @@ urlpatterns = [ path("detail_science_theme//",views.detail_science_theme,name="detail_science_theme"), path("edit_science_theme//",views.edit_science_theme,name="edit_science_theme"), path("delete_science_theme//",views.delete_science_theme,name="delete_science_theme"), - path("test_tac_auto",views.test_tac_auto,name="test_tac_auto") + path("test_tac_auto",views.test_tac_auto,name="test_tac_auto"), + # quota + path("quota_sp",views.quota_sp,name="quota_sp") ] diff --git a/src/core/pyros_django/scp_mgmt/views.py b/src/core/pyros_django/scp_mgmt/views.py index 6ff8230..828ed5d 100644 --- a/src/core/pyros_django/scp_mgmt/views.py +++ b/src/core/pyros_django/scp_mgmt/views.py @@ -2,7 +2,7 @@ from datetime import date, datetime from dateutil.relativedelta import relativedelta import matplotlib.pyplot as plt -import re,io,urllib,base64 +import re,io,urllib,base64, os # Django imports from django.http.response import HttpResponse @@ -22,12 +22,12 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from dashboard.config_pyros import ConfigPyros from .functions import get_global_svg_timeline, get_svg_timeline, get_proposal_svg_timeline from user_mgmt.models import ScientificProgram, Institute, Period, SP_Period_User, SP_Period, PyrosUser, SP_Period_Guest, ScienceTheme #, UserLevel -from seq_submit.models import Sequence +from seq_submit.models import Sequence, Quota #from src.core.pyros_django import scientific_program from .forms import PeriodForm, ScienceThemeForm, ScientificProgramForm, InstituteForm, SP_PeriodForm,TACAssociationForm from src.core.pyros_django.dashboard.decorator import level_required - +from src.core.pyros_django.obs_config.obsconfig_class import OBSConfig @@ -807,6 +807,18 @@ def institute_list(request): }) +@login_required +@level_required("Admin", "Unit-PI", "Observer", "Operator", "TAC", "Management board member") +def quota_sp(request): + institutes = Institute.objects.all() + scientific_programs = ScientificProgram.objects.all() + config = OBSConfig(os.environ["PATH_TO_OBSCONF_FILE"],os.environ["unit_name"]) + current_night = config.fn.date2night("now") + current_period = Period.objects.exploitation_period() + quota_current_night = Quota.objects.get(id_period=current_period.id, night_id=current_night) + return render(request, 'scp_mgmt/quota_sp.html', locals()) + + # Exploitation Periods CRUD @login_required -- libgit2 0.21.2
name quota_f d_total d_totalq d_totalx d_previous d_previousq d_previousx d_current d_currentq d_currentx d_passed d_passedq d_passedx d_schedule d_scheduleq d_schedulex d_next d_nextq d_nextx
Current night : {{ current_night }} {{quota_current_night.d_total}} {{quota_current_night.d_totalq}}{{quota_current_night.d_totalx}} {{quota_current_night.d_previous}} {{quota_current_night.d_previousq}}{{quota_current_night.d_previousx}} {{quota_current_night.d_current}} {{quota_current_night.d_currentq}}{{quota_current_night.d_currentx}} {{quota_current_night.d_passed}} {{quota_current_night.d_passedq}}{{quota_current_night.d_passedx}} {{quota_current_night.d_schedule}} {{quota_current_night.d_scheduleq}}{{quota_current_night.d_schedulex}} {{quota_current_night.d_next}} {{quota_current_night.d_nextq}}{{quota_current_night.d_nextx}}
Institute :{{institute}} {{institute.quota_f}} {{institute.quota.d_total}} {{institute.quota.d_totalq}}{{institute.quota.d_totalx}} {{institute.quota.d_previous}} {{institute.quota.d_previousq}}{{institute.quota.d_previousx}} {{institute.quota.d_current}} {{institute.quota.d_currentq}}{{institute.quota.d_currentx}} {{institute.quota.d_passed}} {{institute.quota.d_passedq}}{{institute.quota.d_passedx}} {{institute.quota.d_schedule}} {{institute.quota.d_scheduleq}}{{institute.quota.d_schedulex}} {{institute.quota.d_next}} {{institute.quota.d_nextq}}{{institute.quota.d_nextx}}
Scientific program: {{sp.name}} {{sp.quota_f}} {{sp.quota.d_total}} {{sp.quota.d_totalq}}{{sp.quota.d_totalx}} {{sp.quota.d_previous}} {{sp.quota.d_previousq}}{{sp.quota.d_previousx}} {{sp.quota.d_current}} {{sp.quota.d_currentq}}{{sp.quota.d_currentx}} {{sp.quota.d_passed}} {{sp.quota.d_passedq}}{{sp.quota.d_passedx}} {{sp.quota.d_schedule}} {{sp.quota.d_scheduleq}}{{sp.quota.d_schedulex}} {{sp.quota.d_next}} {{sp.quota.d_nextq}}{{sp.quota.d_nextx}}