fix: normalizar sync de google sheets para todos los dias, reparar 500 en ciclos lectivos, selector de ciclo lectivo en comisiones y opciones --keep-db --keep-users en install.sh

This commit is contained in:
2026-09-23 19:36:54 -03:00
parent 5771476ee9
commit 195bfd915e
10 changed files with 270 additions and 85 deletions
+24
View File
@@ -156,8 +156,32 @@ const translateHelper = function(s) {
return s || '';
};
const urlForHelper = function(endpoint, params = {}) {
if (!endpoint) return '#';
const parts = endpoint.split('.');
const blueprint = parts.length > 1 ? parts[0] : '';
const action = parts.length > 1 ? parts[1] : parts[0];
let pathStr = `/${blueprint}/${action}`.replace(/^\/\//, '/').replace(/\/$/, '');
if (params && typeof params === 'object') {
const q = [];
for (const [k, v] of Object.entries(params)) {
if (k === 'id' || k === 'pk') {
pathStr += `/${v}`;
} else {
q.push(`${encodeURIComponent(k)}=${encodeURIComponent(v)}`);
}
}
if (q.length > 0) {
pathStr += (pathStr.includes('?') ? '&' : '?') + q.join('&');
}
}
return pathStr;
};
env.addGlobal('_', translateHelper);
env.addFilter('_', translateHelper);
env.addGlobal('url_for', urlForHelper);
env.addFilter('url_for', urlForHelper);
app.set('view engine', 'html');
+13 -1
View File
@@ -833,6 +833,7 @@ const handleCommissionsList = async (req, res) => {
let commissions = [];
let subjects = [];
let teachers = [];
let academic_terms = [];
try {
const [cRes, uRes] = await Promise.allSettled([
@@ -854,6 +855,15 @@ const handleCommissionsList = async (req, res) => {
teachers: c.teachers || (c.teacher_name ? [{ name: c.teacher_name, role: 'Titular' }] : [])
}));
subjects = cRes.value.data.subjects || [];
academic_terms = cRes.value.data.academic_terms || [];
}
// Si por alguna razón no vinieron academic_terms en commissions, intentar fallback
if (!academic_terms || academic_terms.length === 0) {
try {
const termsRes = await req.apiClient.get('/academic-terms');
academic_terms = termsRes.data?.terms || termsRes.data?.academic_terms || [];
} catch (tErr) {}
}
if (uRes.status === 'fulfilled' && uRes.value.data) {
@@ -872,6 +882,7 @@ const handleCommissionsList = async (req, res) => {
commissions,
subjects,
teachers,
academic_terms,
search,
subject_filter: subject_id ? parseInt(subject_id, 10) : '',
shift_filter: shift,
@@ -993,12 +1004,13 @@ const handleCommissionDetail = async (req, res) => {
const handleCommissionAdd = async (req, res) => {
try {
const { subject_id, code, semester, year, shift, teacher_id, max_students, schedule, virtual_link } = req.body;
const { subject_id, code, semester, year, shift, teacher_id, max_students, schedule, virtual_link, academic_term_id } = req.body;
const payload = {
subject_id: parseInt(subject_id, 10),
code: (code || '').trim(),
semester: semester || '1C',
year: year ? parseInt(year, 10) : 2026,
academic_term_id: academic_term_id ? parseInt(academic_term_id, 10) : null,
shift: shift || 'Mañana',
teacher_id: teacher_id ? parseInt(teacher_id, 10) : null,
max_students: max_students ? parseInt(max_students, 10) : 40,