Skip to content

Commit

Permalink
fix enrollees modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Wellheor1 committed Sep 13, 2023
1 parent b86b4c3 commit ca4c7c1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions api/education/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
20 changes: 12 additions & 8 deletions education/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 10 additions & 9 deletions l2-frontend/src/modals/EnrolleesApplication.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,28 @@ 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: '' },
{ field: 'title', key: 'title', title: 'Название' },
{ 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();
Expand Down

0 comments on commit ca4c7c1

Please sign in to comment.