Skip to content

Commit

Permalink
Статика - динамика
Browse files Browse the repository at this point in the history
* fix пустых/статичных функций
* Динамическое получение предметов на таблицу абитуриентов
  • Loading branch information
Wellheor1 committed Sep 12, 2023
1 parent 596ce6d commit 5a2b43c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 29 deletions.
1 change: 0 additions & 1 deletion api/education/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
urlpatterns = [
path('get-specialties', views.get_specialties),
path('get-pay-forms', views.get_pay_forms),
path('get-enrollment-orders', views.get_enrollment_orders),
path('get-citizenship', views.get_citizenship),
path('get-exams-filters', views.get_exams_filters),
path('get-achievements-filters', views.get_achievements_filters),
Expand Down
16 changes: 8 additions & 8 deletions api/education/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from clients.models import Citizenship
from education.models import ApplicationEducation, ExamType, Subjects, AchievementType, DocumentTypeEducation, SpecialRights, EducationSpeciality, Achievement, EducationFinanceSource
from education.views import get_all_enrollees
from laboratory.local_settings import SUBJECTS_ENTRANCE_EXAM
from laboratory.utils import current_year


Expand All @@ -26,11 +27,6 @@ def get_pay_forms(request):
return JsonResponse({"result": result})


def get_enrollment_orders(request):
result = []
return JsonResponse({"result": result})


def get_citizenship(request):
result = Citizenship.get_citizenship()
return JsonResponse({"result": result})
Expand Down Expand Up @@ -58,14 +54,13 @@ def get_special_rights(request):


def get_columns(request):
entrance_exam_data = Subjects.objects.filter(pk__in=SUBJECTS_ENTRANCE_EXAM)

columns = [
{"field": 'card', "key": 'card', "title": 'Дело'},
{"field": 'fio', "key": 'fio', "title": 'ФИО'},
{"field": 'applicationSpeciality', "key": 'applicationSpeciality', "title": 'Специальность'},
{"field": 'applicationPersonNumber', "key": 'applicationPersonNumber', "title": 'Номер'},
{"field": 'chemistry', "key": 'chemistry', "title": 'Хим.'},
{"field": 'biology', "key": 'biology', "title": 'Био.'},
{"field": 'russian_language', "key": 'russian_language', "title": 'Рус.'},
{"field": 'achievementPoint', "key": 'achievementPoint', "title": 'ИД'},
{"field": 'achievementСhecked', "key": 'achievementСhecked', "title": 'ИД+'},
{"field": 'totalPoints', "key": 'totalPoint', "title": 'Сумм'},
Expand All @@ -74,6 +69,11 @@ def get_columns(request):
{"field": 'status', "key": 'status', "title": 'Статус'},
{"field": 'create_date', "key": 'create_date', "title": 'Создано'},
]
step = 0
for i in entrance_exam_data:
columns.insert(4+step, {"field": i.synonym, "key": i.synonym, "title": i.short_title})
step += 1

return JsonResponse({"result": columns})


Expand Down
4 changes: 4 additions & 0 deletions education/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,17 @@ class EducationSpecialityAdmin(admin.ModelAdmin):

class SubjectsAdmin(admin.ModelAdmin):
list_display = (
'pk',
'title',
'short_title',
'synonym',
'mmis_id',
)
list_display_links = (
'pk',
'title',
'short_title',
'synonym',
'mmis_id',
)

Expand Down
1 change: 1 addition & 0 deletions education/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class Subjects(models.Model):
title = models.CharField(max_length=255, verbose_name='Наименование предмета', help_text='Химия/основы химии, Математика и т.д')
mmis_id = models.IntegerField(blank=True, null=True, db_index=True, verbose_name='mmis_id')
short_title = models.CharField(max_length=55, default="", verbose_name='Короткое наименование', help_text='Химия/основы химии, Математика и т.д')
synonym = models.CharField(max_length=255, default="", verbose_name='Синоним', help_text='Химия/основы химии - chemistry')

def __str__(self):
return self.title
Expand Down
2 changes: 1 addition & 1 deletion education/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_dashboard_data(application_year, researches):
education_applicationeducation.original,
education_applicationeducation.id as app_id,
education_applicationeducation.date as app_data,
exsubj.title as subj_title,
exsubj.synonym as subj_synonym,
education_entranceexam.grade,
es.title as special_title,
es.id as special_id,
Expand Down
22 changes: 9 additions & 13 deletions education/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from education.sql_func import get_dashboard_data
import simplejson as json

from laboratory.local_settings import SUBJECTS_ENTRANCE_EXAM
from laboratory.settings import MMIS_CONNECT_WITH_PYODBC
from laboratory.utils import current_year
from slog.models import Log
Expand Down Expand Up @@ -172,22 +173,22 @@ def get_all_enrollees(request):
research_contract_ids = Researches.objects.filter(is_contract=True).values_list('id', flat=True)
data = get_dashboard_data(year_study, tuple(research_contract_ids))
last_app_id = -1
entrance_exam_synonym = Subjects.objects.filter(pk__in=SUBJECTS_ENTRANCE_EXAM).values_list('synonym', flat=True)
template_result = {
"card": "",
"fio": "",
"applicationSpeciality": "",
"applicationPersonNumber": "",
"сhemistry": 0,
"biology": 0,
"mathematics": 0,
"russian_language": 0,
"achievementPoint": 0,
"totalPoints": 0,
"is_original": "",
"status": "",
"create_date": "",
"researchContractId": None,
}
for synonym in entrance_exam_synonym:
template_result[synonym] = 0

step = 0
data_res = []
temp_result = template_result.copy()
Expand All @@ -200,7 +201,7 @@ def get_all_enrollees(request):
if expelled and (not i.is_expelled):
continue
if last_app_id != i.app_id and step != 0:
temp_result["totalPoints"] = temp_result["сhemistry"] + temp_result["biology"] + temp_result["russian_language"] + temp_result["achievementPoint"]
temp_result["totalPoints"] = sum([temp_result[synonym] for synonym in entrance_exam_synonym]) + temp_result["achievementPoint"]
data_res.append(temp_result.copy())
temp_result = template_result.copy()
temp_result["card"] = i.card_id
Expand All @@ -213,16 +214,11 @@ def get_all_enrollees(request):
temp_result["researchContractId"] = i.direction_id
temp_result["is_expelled"] = i.is_expelled
temp_result["create_date"] = date
if i.subj_title.lower() in ["химия", "основы химии"]:
temp_result["сhemistry"] = i.grade if i.grade else 0
if i.subj_title.lower() in ["биология"]:
temp_result["biology"] = i.grade if i.grade else 0
if i.subj_title.lower() in ["русский язык"]:
temp_result["russian_language"] = i.grade if i.grade else 0

if i.subj_synonym in entrance_exam_synonym:
temp_result[i.subj_synonym] = i.grade if i.grade else 0
last_app_id = i.app_id
step += 1
if temp_result.get("card"):
temp_result["totalPoints"] = temp_result["сhemistry"] + temp_result["biology"] + temp_result["russian_language"] + temp_result["achievementPoint"]
temp_result["totalPoints"] = sum([temp_result[synonym] for synonym in entrance_exam_synonym]) + temp_result["achievementPoint"]
data_res.append(temp_result.copy())
return data_res
6 changes: 0 additions & 6 deletions l2-frontend/src/pages/Education/Enrollees.vue
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ const isExpelled = ref(false);
const selectedEnrollmentOrders = ref([]);
const enrollmentOrders = ref([]);
const getEnrollmentOrders = async () => {
const data = await api('/education/get-enrollment-orders');
enrollmentOrders.value = data.result;
};
const selectedCitizenship = ref(null);
const citizenship = ref([]);
Expand Down Expand Up @@ -447,9 +443,7 @@ onMounted(
getSpecialties();
getPayForms();
getCompanies();
getEnrollmentOrders();
getCitizenship();
getApplicationFilters();
getExamsFilters();
getAchievementsFilters();
getEducations();
Expand Down

0 comments on commit 5a2b43c

Please sign in to comment.