diff --git a/api/education/views.py b/api/education/views.py index 81e814cf57..3bf0dbda51 100644 --- a/api/education/views.py +++ b/api/education/views.py @@ -88,5 +88,5 @@ def get_applications_by_card(request): def get_achievement_by_card(request): request_data = json.loads(request.body) - result = Achievement.get_achievement_by_card(request_data["card_pk"]) - return JsonResponse({"result": result}) + achievements = Achievement.get_achievement_by_card(request_data["card_pk"]) + return JsonResponse({"achievements": achievements}) diff --git a/education/models.py b/education/models.py index 3e2ea988c7..cfd1dfb9c6 100644 --- a/education/models.py +++ b/education/models.py @@ -169,24 +169,28 @@ def get_applications_by_card(card_pk): {"field": 'date', "key": 'date', "title": 'Дата'}, {"field": 'speciality', "key": 'speciality', "title": 'Специальность'}, ] - data_applications = { + template_applications = { "pk": -1, "date": '', "speciality": '', } for i in entrance_exam_data: columns.append({"field": i.synonym, "key": i.synonym, "title": i.short_title}) - data_applications[i.synonym] = 0 + template_applications[i.synonym] = 0 + temp_applications = template_applications.copy() for i in data: - if current_application != i.application_pk: - applications.append(data_applications) - data_applications["pk"] = i.application_pk - data_applications["date"] = i.date.strftime('%d.%m.%Y') - data_applications["speciality"] = i.spec_title - data_applications[i.subject_synonym] = i.grade if i.grade else 0 + if current_application != i.application_pk and current_application != -1: + applications.append(temp_applications) + temp_applications = template_applications.copy() + temp_applications["pk"] = i.application_pk + temp_applications["date"] = i.date.strftime('%d.%m.%Y') + temp_applications["speciality"] = i.spec_title + temp_applications[i.subject_synonym] = i.grade if i.grade else 0 current_application = i.application_pk + if temp_applications.get("pk"): + applications.append(temp_applications) return applications, columns class Meta: diff --git a/l2-frontend/src/modals/EnrolleesApplication.vue b/l2-frontend/src/modals/EnrolleesApplication.vue index 4e33e6a82a..a4af261943 100644 --- a/l2-frontend/src/modals/EnrolleesApplication.vue +++ b/l2-frontend/src/modals/EnrolleesApplication.vue @@ -86,6 +86,12 @@ const props = defineProps({ }); const application = ref([]); const applicationsColumns = ref([]); +const getApplications = async () => { + const data = await api('/education/get-applications-by-card', { card_pk: props.card_pk }); + application.value = data.applications; + applicationsColumns.value = data.columns; +}; + const achievements = ref([]); const achievementsColumns = ref([ { field: 'pk', key: 'pk', title: '№' }, @@ -93,20 +99,15 @@ const achievementsColumns = ref([ { field: 'date', key: 'date', title: 'Статус' }, { field: 'grade', key: 'grade', title: 'Оценка' }, ]); - -const hideModal = () => { - emit('hideEnrollees'); -}; -const getApplications = async () => { - const data = await api('/education/get-applications-by-card', { card_pk: props.card_pk }); - application.value = data.applications; - applicationsColumns.value = data.columns; -}; const getAchievements = async () => { const data = await api('/education/get-achievements-by-card', { card_pk: props.card_pk }); achievements.value = data.achievements; }; +const hideModal = () => { + emit('hideEnrollees'); +}; + onMounted(() => { getApplications(); getAchievements();