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
4 changed files with 101 additions and 15 deletions
Showing only changes of commit 69eda90eea - Show all commits

View File

@ -20,6 +20,14 @@
<script> <script>
const etudsDefDem = {{ defdem | safe }} const etudsDefDem = {{ defdem | safe }}
const timeMorning = "{{ timeMorning | safe}}";
const timeNoon = "{{ timeNoon | safe}}";
const timeEvening = "{{ timeEvening | safe}}";
const defaultDates = {{ defaultDates | safe }}
const nonWorkDays = [{{ nonworkdays| safe }}];
window.addEventListener('load', () => { window.addEventListener('load', () => {
[...document.querySelectorAll('.tr[etudid]')].forEach((a) => { [...document.querySelectorAll('.tr[etudid]')].forEach((a) => {
try { try {
@ -28,8 +36,33 @@
a.classList.add(defdem); a.classList.add(defdem);
} }
} catch (_) { } } catch (_) { }
});
if (defaultDates != null) {
defaultDates.forEach((dateString) => {
d = moment(dateString).weekday();
if (verifyNonWorkDays(d, nonWorkDays)) return;
matin = `${dateString}T${timeMorning}`;
midi = `${dateString}T${timeNoon}`;
soir = `${dateString}T${timeEvening}`;
console.log(matin, midi, soir)
createColumn(matin, midi);
createColumn(midi, soir);
});
updateAllCol();
} else {
createColumn();
}
}) })
})
</script> </script>

View File

@ -118,6 +118,8 @@
window.forceModule = "{{ forcer_module }}" window.forceModule = "{{ forcer_module }}"
window.forceModule = window.forceModule == "True" ? true : false window.forceModule = window.forceModule == "True" ? true : false
createColumn();
</script> </script>

View File

@ -9,9 +9,8 @@
{% for etud in etudiants %} {% for etud in etudiants %}
<div class="tr" etudid="{{etud.etudid}}"> <div class="tr" etudid="{{etud.etudid}}">
<div class="td sticky"> <div class="td sticky etudinfo" id="row-{{etud.etudid}}">
<span>{{etud.nomprenom}}</span> <span>{{etud.nomprenom}}</span>
<img class="pdp-hover" src="" alt="No Img" etudid="{{etud.etudid}}">
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
@ -40,6 +39,10 @@
gap: 15px; gap: 15px;
} }
.tr[etudid] {
height: 50px;
}
.table-container { .table-container {
overflow: auto; overflow: auto;
position: relative; position: relative;
@ -72,13 +75,13 @@
.th, .th,
.td { .td {
padding: 20px;
text-align: center; text-align: center;
width: 225px; width: 225px;
border: 1px solid #ddd; border: 1px solid #ddd;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-content: center; align-content: center;
min-height: 40px;
} }
.tr { .tr {
@ -88,11 +91,17 @@
width: max-content; width: max-content;
} }
.td span {
align-items: center;
display: flex;
}
.sticky { .sticky {
position: sticky; position: sticky;
left: 0; left: 0;
background-color: #fafafa; background-color: #fafafa;
border-right: 1px solid #ddd; border-right: 1px solid #ddd;
z-index: 100;
} }
.mini-form { .mini-form {
@ -120,7 +129,7 @@
border-radius: 50%; border-radius: 50%;
right: -60px; right: -60px;
top: calc(50% - 50px /2); top: calc(50% - 50px /2);
background-color: #007BFF; background-color: #09c;
color: white; color: white;
border: none; border: none;
outline: none; outline: none;
@ -133,13 +142,13 @@
} }
.th { .th {
background-color: #007BFF; background-color: #09c;
color: white; color: white;
position: relative; position: relative;
} }
.th.error { .th.error {
background-color: crimson; background-color: #d71111;
} }
.tbody .tr:nth-child(even) { .tbody .tr:nth-child(even) {
@ -219,7 +228,7 @@
.th.error:hover .col-error { .th.error:hover .col-error {
display: block; display: block;
z-index: 2000; z-index: 2000;
background-color: crimson; background-color: #d71111;
width: 100%; width: 100%;
min-height: 25%; min-height: 25%;
bottom: -25%; bottom: -25%;
@ -269,7 +278,7 @@
currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm"); currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm");
} }
function createColumn() { function createColumn(dateStart = "", dateEnd = "") {
let table = document.getElementById("studentTable"); let table = document.getElementById("studentTable");
let th = document.createElement("div"); let th = document.createElement("div");
th.classList.add("th", "error"); th.classList.add("th", "error");
@ -282,8 +291,8 @@
<div class="btngroup" style="justify-content: flex-end;"> <div class="btngroup" style="justify-content: flex-end;">
<button class="closeCol" onclick="removeColumn(this)">x</button> <button class="closeCol" onclick="removeColumn(this)">x</button>
</div> </div>
<input type="datetime-local" id="dateStart"> <input type="datetime-local" id="dateStart" value="${dateStart}">
<input type="datetime-local" id="dateEnd"> <input type="datetime-local" id="dateEnd" value="${dateEnd}">
{{moduleimpl_select|safe}} {{moduleimpl_select|safe}}
<div id="mass_action_${col_id}" class="mass"> <div id="mass_action_${col_id}" class="mass">
<input disabled="" type="radio" class="rbtn present" name="mass_action_${col_id}" value="present" onclick="massCol(this)"> <input disabled="" type="radio" class="rbtn present" name="mass_action_${col_id}" value="present" onclick="massCol(this)">
@ -300,8 +309,10 @@
if (dateStart == "") {
const last = [...document.querySelectorAll("#dateStart")].pop(); const last = [...document.querySelectorAll("#dateStart")].pop();
defaultDate(last); defaultDate(last);
}
try { try {
const sl = th.querySelector('.dynaSelect'); const sl = th.querySelector('.dynaSelect');
@ -614,7 +625,7 @@
function updateAllCol() { function updateAllCol() {
const colIds = [...document.querySelectorAll("[col]")].map((col) => { return col.getAttribute('col') }); const colIds = [...document.querySelectorAll("[col]")].map((col) => { return col.getAttribute('col') });
colIds.forEach((colid) => { colIds.forEach((colid) => {
updateAssiduitesCol(colid); getAndUpdateCol(colid)
}) })
} }
@ -1009,7 +1020,6 @@
createColumn(); createColumn();
}); });
createColumn();
setEtuds(); setEtuds();
document.querySelectorAll('.pdp-hover').forEach((el) => { document.querySelectorAll('.pdp-hover').forEach((el) => {

View File

@ -210,6 +210,7 @@ def signal_assiduites_etud():
"js/assiduites.js", "js/assiduites.js",
"libjs/moment.new.min.js", "libjs/moment.new.min.js",
"libjs/moment-timezone.js", "libjs/moment-timezone.js",
"js/etud_info.js",
], ],
cssstyles=[ cssstyles=[
"css/assiduites.css", "css/assiduites.css",
@ -880,6 +881,21 @@ def signal_assiduites_diff():
group_ids: list[int] = request.args.get("group_ids", None) group_ids: list[int] = request.args.get("group_ids", None)
formsemestre_id: int = request.args.get("formsemestre_id", -1) formsemestre_id: int = request.args.get("formsemestre_id", -1)
date: str = request.args.get("jour", datetime.date.today().isoformat()) date: str = request.args.get("jour", datetime.date.today().isoformat())
date_deb: str = request.args.get("date_deb")
date_fin: str = request.args.get("date_fin")
semaine: str = request.args.get("semaine")
if semaine is not None:
semaine = (
f"{scu.annee_scolaire()}-W{semaine}" if "W" not in semaine else semaine
)
date_deb: datetime.date = datetime.datetime.strptime(
semaine + "-1", "%Y-W%W-%w"
)
date_fin: datetime.date = date_deb + datetime.timedelta(days=6)
etudiants: list[dict] = [] etudiants: list[dict] = []
titre = None titre = None
@ -936,6 +952,7 @@ def signal_assiduites_diff():
"js/assiduites.js", "js/assiduites.js",
"libjs/moment.new.min.js", "libjs/moment.new.min.js",
"libjs/moment-timezone.js", "libjs/moment-timezone.js",
"js/etud_info.js",
], ],
) )
@ -968,11 +985,35 @@ def signal_assiduites_diff():
gr=gr_tit, gr=gr_tit,
sem=sem["titre_num"], sem=sem["titre_num"],
defdem=_get_etuds_dem_def(formsemestre), defdem=_get_etuds_dem_def(formsemestre),
timeMorning=ScoDocSiteConfig.get("assi_morning_time", "08:00:00"),
timeNoon=ScoDocSiteConfig.get("assi_lunch_time", "13:00:00"),
timeEvening=ScoDocSiteConfig.get("assi_evening_time", "18:00:00"),
defaultDates=_get_days_between_dates(date_deb, date_fin),
nonworkdays=_non_work_days(),
), ),
html_sco_header.sco_footer(), html_sco_header.sco_footer(),
).build() ).build()
def _get_days_between_dates(deb: str, fin: str):
if deb is None or fin is None:
return "null"
try:
if isinstance(deb, str) and isinstance(fin, str):
date_deb: datetime.date = datetime.date.fromisoformat(deb)
date_fin: datetime.date = datetime.date.fromisoformat(fin)
else:
date_deb, date_fin = deb.date(), fin.date()
except ValueError:
return "null"
dates: list[str] = []
while date_deb <= date_fin:
dates.append(f'"{date_deb.isoformat()}"')
date_deb = date_deb + datetime.timedelta(days=1)
return f"[{','.join(dates)}]"
def _differee( def _differee(
etudiants, moduleimpl_select, date=None, periode=None, formsemestre_id=None etudiants, moduleimpl_select, date=None, periode=None, formsemestre_id=None
): ):