From b03d46b165f0bbc5dcfab35a58e470cfb8a646d5 Mon Sep 17 00:00:00 2001 From: Vladimir Makharev Date: Fri, 23 Sep 2022 17:33:34 +0300 Subject: [PATCH] SPORT-604: Add debtor badge in JS logic --- adminpage/sport/static/sport/js/profile.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/adminpage/sport/static/sport/js/profile.js b/adminpage/sport/static/sport/js/profile.js index aa791059..791315b1 100755 --- a/adminpage/sport/static/sport/js/profile.js +++ b/adminpage/sport/static/sport/js/profile.js @@ -267,13 +267,19 @@ function add_student_row( email, med_group, hours, - maxHours + maxHours, + is_debtor ) { const row = $(` ${full_name} ${ med_group === 'Special 1' - ? `${med_group}` + ? `${med_group}` + : '' + } + ${ + is_debtor + ? `DEBTOR` : '' } @@ -352,14 +358,15 @@ function make_grades_table(grades, maxHours) { 'StudentEmailHours' ); student_hours_tbody = table.append('').children('tbody'); - grades.forEach(({ student_id, full_name, email, med_group, hours }) => { + grades.forEach(({ student_id, full_name, email, med_group, hours, is_debtor }) => { add_student_row( student_id, full_name, email, med_group, hours, - maxHours + maxHours, + is_debtor ); }); return table; @@ -488,7 +495,7 @@ document.addEventListener('DOMContentLoaded', function () { }); function parse_student_from_server(data, h = 0) { - const [student_id, full_name, email, med_group] = data.split('_'); + const [student_id, full_name, email, med_group, is_debtor] = data.split('_'); const hours = h; const student_row = students_in_table[student_id]; if (student_row == null) { @@ -500,7 +507,8 @@ function parse_student_from_server(data, h = 0) { email, med_group, hours, - maxHours + maxHours, + is_debtor ); // add if student isn't present local_hours_changes[student_id] = hours; } else {