This commit is contained in:
Emmanuel Viennet 2023-11-17 14:43:25 +01:00
commit 66f3cc97e0
7 changed files with 40 additions and 26 deletions

View File

@ -1014,7 +1014,7 @@ def _edit_one(assiduite_unique: Assiduite, data: dict) -> tuple[int, str]:
else assiduite_unique.external_data
)
if force and not external_data.get("module", False):
if force and not (external_data is not None and external_data.get("module", False) != ""):
errors.append(
"param 'moduleimpl_id' : le moduleimpl_id ne peut pas être nul"
)

View File

@ -331,15 +331,16 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
>Saisie Absences journée</a></span>
"""
)
year, week, day = datetime.date.today().isocalendar()
semaine: str = f"{year}-W{week}"
H.append(
f"""
<span class="moduleimpl_abs_link"><a class="stdlink" href="{
url_for(
"assiduites.signal_assiduites_group",
"assiduites.signal_assiduites_diff",
scodoc_dept=g.scodoc_dept,
group_ids=group_id,
jour=datetime.date.today().isoformat(),
semaine=semaine,
formsemestre_id=formsemestre.id,
moduleimpl_id="" if moduleimpl_id is None else moduleimpl_id
)}"

View File

@ -1,6 +1,5 @@
// <=== CONSTANTS and GLOBALS ===>
const TIMEZONE = "Europe/Paris";
let url;
function getUrl() {
@ -192,8 +191,9 @@ function sync_get(path, success, errors) {
*/
async function async_get(path, success, errors) {
console.log("async_get " + path);
let response;
try {
const response = await fetch(path);
response = await fetch(path);
if (response.ok) {
const data = await response.json();
success(data);
@ -204,6 +204,8 @@ async function async_get(path, success, errors) {
console.error(error);
if (errors) errors(error);
}
return response;
}
/**
@ -234,8 +236,9 @@ function sync_post(path, data, success, errors) {
*/
async function async_post(path, data, success, errors) {
console.log("async_post " + path);
let response;
try {
const response = await fetch(path, {
response = await fetch(path, {
method: "POST",
headers: {
"Content-Type": "application/json",
@ -253,6 +256,8 @@ async function async_post(path, data, success, errors) {
console.error(error);
if (errors) errors(error);
}
return response;
}
// <<== Gestion des actions de masse ==>>
@ -630,13 +635,17 @@ function updateDate() {
)
);
openAlertModal("Attention", div, "", "#eec660");
$(dateInput).datepicker(
"setDate",
Date.toFRA(lastWorkDay.toIsoUtcString().split("T")[0])
);
const date_fra = Date.toFRA(lastWorkDay.toIsoUtcString().split("T")[0]);
$(dateInput).datepicker("setDate", date_fra);
dateInput.value = date_fra;
date = lastWorkDay;
dateStr = formatDate(lastWorkDay).capitalize();
}
console.warn(dateStr, date, date.toIsoUtcString());
document.querySelector("#datestr").textContent = dateStr;
return true;
}

View File

@ -89,8 +89,8 @@
const readOnly = {{ readonly }};
updateDate();
setupDate();
updateDate();
setupTimeLine();
window.forceModule = "{{ forcer_module }}"

View File

@ -3,6 +3,7 @@
{% block scripts %}
{{ super() }}
<script src="{{scu.STATIC_DIR}}/js/etud_info.js"></script>
<script src="{{scu.STATIC_DIR}}/js/date_utils.js"></script>
{% endblock %}
{% block app_content %}
@ -31,8 +32,8 @@
const group_ids = "{{group_ids}}";
function stats() {
const deb = document.querySelector('#stats_date_debut').value;
const fin = document.querySelector('#stats_date_fin').value;
const deb = Date.fromFRA(document.querySelector('#stats_date_debut').value);
const fin = Date.fromFRA(document.querySelector('#stats_date_fin').value);
location.href = `VisualisationAssiduitesGroupe?group_ids=${group_ids}&date_debut=${deb}&date_fin=${fin}`;
}

View File

@ -954,24 +954,27 @@
editList.push(edit);
})
$.when(
asyncCreateAssiduiteGroup(createList, (data) => {
const values = { "create": {}, "edit": {} };
Promise.all(
[asyncCreateAssiduiteGroup(createList, (data) => {
values.create = data;
}),
asyncEditAssiduiteGroup(editList, (data) => {
values.edit = data;
})
).done((c, e) => {
})]
).then(() => {
const c = values.create;
const e = values.edit;
let error;
Object.keys(c[0].success).forEach((k) => {
Object.keys(c.success).forEach((k) => {
const assiduite = createList[Number.parseInt(k)];
assiduite["assiduite_id"] = c[0].success[k].message.assiduite_id;
assiduite["assiduite_id"] = c.success[k].message.assiduite_id;
assiduites[assiduite.etudid].push(assiduite);
})
if (c[0].errors.length > 0) {
error = c[0].errors[Object.keys(c[0].errors)[0]];
if (c.errors.length > 0) {
error = c.errors[Object.keys(c.errors)[0]];
if (error.message.indexOf("Module") != -1) {
const html = `
<h3>Aucun module n'a été spécifié (préférence du semestre concerné)</h3>
@ -982,7 +985,7 @@
toCreate.length = 0
}
}
Object.keys(e[0].success).forEach((k) => {
Object.keys(e.success).forEach((k) => {
const { etudid, assiduite_id, moduleimpl_id, etat } = editList[Number.parseInt(k)]
assiduites[etudid].map((a) => {
if (a.assiduite_id == assiduite_id) {

View File

@ -1019,7 +1019,7 @@ def visu_assi_group():
short=False,
),
date_debut=_dateiso_to_datefr(dates["debut"]),
date_fin=_dateiso_to_datefr(dates["debut"]),
date_fin=_dateiso_to_datefr(dates["fin"]),
gr_tit=gr_tit,
group_ids=request.args.get("group_ids", None),
sco=ScoData(formsemestre=groups_infos.get_formsemestre()),