Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
6 changed files with 83 additions and 5 deletions
Showing only changes of commit 238b6b10d4 - Show all commits

View File

@ -642,6 +642,17 @@ class BasePreferences(object):
"category": "assi", "category": "assi",
}, },
), ),
(
"non_travail",
{
"initvalue": "sam, dim",
"title": "Jours non travaillés",
"size": 40,
"category": "assi",
"only_global": True,
"explanation": "Liste des jours (lun,mar,mer,jeu,ven,sam,dim)",
},
),
# portal # portal
( (
"portal_url", "portal_url",

View File

@ -28,6 +28,9 @@
.infos { .infos {
position: relative; position: relative;
width: fit-content; width: fit-content;
display: flex;
justify-content: space-evenly;
align-content: center;
} }
#datestr { #datestr {
@ -36,6 +39,9 @@
border: 1px #444 solid; border: 1px #444 solid;
border-radius: 5px; border-radius: 5px;
padding: 5px; padding: 5px;
min-width: 100px;
display: inline-block;
min-height: 20px;
} }
#tl_slider { #tl_slider {

View File

@ -467,7 +467,18 @@ function updateDate() {
const date = dateInput.valueAsDate; const date = dateInput.valueAsDate;
$("#datestr").text(formatDate(date).capitalize()); if (!verifyNonWorkDays(date.getDay(), nonWorkDays)) {
$("#datestr").text(formatDate(date).capitalize());
dateInput.setAttribute("value", date.toISOString().split("T")[0]);
return true;
} else {
const att = document.createTextNode(
"Le jour sélectionné n'est pas un jour travaillé."
);
openAlertModal("Erreur", att, "", "crimson");
dateInput.value = dateInput.getAttribute("value");
return false;
}
} }
function verifyDateInSemester() { function verifyDateInSemester() {
@ -519,6 +530,39 @@ function formatDateModal(str, separator = "·") {
return new moment.tz(str, TIMEZONE).format(`DD/MM/Y ${separator} HH:mm`); return new moment.tz(str, TIMEZONE).format(`DD/MM/Y ${separator} HH:mm`);
} }
/**
* Vérifie si la date sélectionnée n'est pas un jour non travaillé
* Renvoie Vrai si le jour est non travaillé
*/
function verifyNonWorkDays(day, nonWorkdays) {
let d = "";
switch (day) {
case 0:
d = "dim";
break;
case 1:
d = "lun";
break;
case 2:
d = "mar";
break;
case 3:
d = "mer";
break;
case 4:
d = "jeu";
break;
case 5:
d = "ven";
break;
case 6:
d = "sam";
break;
}
return nonWorkdays.indexOf(d) != -1;
}
/** /**
* Fonction qui vérifie si une période est dans un interval * Fonction qui vérifie si une période est dans un interval
* Objet période / interval * Objet période / interval
@ -573,7 +617,9 @@ function isConflictSameAsTimeLine(conflict) {
* @returns {Date} la date sélectionnée * @returns {Date} la date sélectionnée
*/ */
function getDate() { function getDate() {
const date = document.querySelector("#tl_date").valueAsDate; const date = new Date(
document.querySelector("#tl_date").getAttribute("value")
);
date.setHours(0, 0, 0, 0); date.setHours(0, 0, 0, 0);
return date; return date;
} }

View File

@ -37,7 +37,7 @@
<div class="infos"> <div class="infos">
Date: <span id="datestr"></span> Date: <span id="datestr"></span>
<input type="date" name="tl_date" id="tl_date" value="{{ date }}" onchange="updateDate()"> <input type="date" name="tl_date" id="tl_date" value="{{ date }}">
</div> </div>
{{timeline|safe}} {{timeline|safe}}
@ -70,11 +70,16 @@
<script> <script>
const etudid = {{ sco.etud.id }}; const etudid = {{ sco.etud.id }};
const nonWorkDays = [{{ nonworkdays| safe }}];
setupDate(() => { setupDate(() => {
actualizeEtud(etudid); if (updateDate()) {
updateSelect() actualizeEtud(etudid);
updateSelect()
}
}); });
setupTimeLine(() => { setupTimeLine(() => {
updateJustifyBtn(); updateJustifyBtn();
}); });

View File

@ -70,6 +70,8 @@
{% include "assiduites/prompt.j2" %} {% include "assiduites/prompt.j2" %}
<script> <script>
const nonWorkDays = [{{ nonworkdays| safe }}];
updateDate(); updateDate();
setupDate(); setupDate();
setupTimeLine(); setupTimeLine();

View File

@ -207,6 +207,7 @@ def signal_assiduites_etud():
lunch=lunch, lunch=lunch,
timeline=_timeline(), timeline=_timeline(),
afternoon=afternoon, afternoon=afternoon,
nonworkdays=_non_work_days(),
forcer_module=sco_preferences.get_preference( forcer_module=sco_preferences.get_preference(
"forcer_module", dept_id=g.scodoc_dept_id "forcer_module", dept_id=g.scodoc_dept_id
), ),
@ -214,6 +215,12 @@ def signal_assiduites_etud():
).build() ).build()
def _non_work_days():
non_travail = sco_preferences.get_preference("non_travail", None)
non_travail = non_travail.replace(" ", "").split(",")
return ",".join([f"'{i.lower()}'" for i in non_travail])
def _str_to_num(string: str): def _str_to_num(string: str):
parts = [*map(float, string.split(":"))] parts = [*map(float, string.split(":"))]
hour = parts[0] hour = parts[0]
@ -395,6 +402,7 @@ def signal_assiduites_group():
grp=sco_groups_view.menu_groups_choice(groups_infos), grp=sco_groups_view.menu_groups_choice(groups_infos),
moduleimpl_select=_module_selector(formsemestre, moduleimpl_id), moduleimpl_select=_module_selector(formsemestre, moduleimpl_id),
timeline=_timeline(), timeline=_timeline(),
nonworkdays=_non_work_days(),
formsemestre_date_debut=str(formsemestre.date_debut), formsemestre_date_debut=str(formsemestre.date_debut),
formsemestre_date_fin=str(formsemestre.date_fin), formsemestre_date_fin=str(formsemestre.date_fin),
forcer_module=sco_preferences.get_preference( forcer_module=sco_preferences.get_preference(