From 72e58cb0ee90af06fa325014a6adc78e480da33d Mon Sep 17 00:00:00 2001 From: Alexey Kudelko Date: Tue, 12 Nov 2024 00:49:57 +0300 Subject: [PATCH 1/2] loadout students --- users/admin.py | 111 +++++++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/users/admin.py b/users/admin.py index aaf4c616..37cba5b4 100644 --- a/users/admin.py +++ b/users/admin.py @@ -253,8 +253,7 @@ def get_export_users_emails(self, users): headers=[ "Имя и фамилия", "Возраст", - "Интересы", - "ВУЗ / Школа", + "ВУЗ", "Специальность", "Эл. почта", ] @@ -262,65 +261,77 @@ def get_export_users_emails(self, users): today = date.today() - date_limit_18 = date(today.year - 18, today.month, today.day) - users = ( - CustomUser.objects.all() - .select_related("v2_speciality") - .prefetch_related( - "collaborations__project", - "collaborations__project__industry", - "skills__skill", - "education", - ) + # date_limit_18 = date(today.year - 18, today.month, today.day) + user_ed = ( + UserEducation.objects + .select_related("user", "user__v2_speciality") + .filter(education_status="Студент") ) - little_mans = users.filter(birthday__lte=date_limit_18) - big_mans = users.exclude(id__in=little_mans.values_list("id", flat=True)) + # users = ( + # CustomUser.objects.all() + # .select_related("v2_speciality") + # ) + # little_mans = users.filter(birthday__lte=date_limit_18) + # big_mans = users.exclude(id__in=little_mans.values_list("id", flat=True)) # whole_quality = users.count() # quantity_little_mans = little_mans.count() # quantity_big_mans = whole_quality - quantity_little_mans - for baby in little_mans: - interests = [ - collab.project.industry.name if collab.project.industry else "" - for collab in baby.collaborations.all() - ] - if not len(interests): - interests = [ - skill_to_obj.skill.name if skill_to_obj.skill else "" - for skill_to_obj in baby.skills.all() - ] - if not len(interests): - interests = baby.key_skills.split(",") if baby.key_skills else [] + for ed in user_ed: response_data.append( - [ - baby.first_name + " " + baby.last_name, - today.year - baby.birthday.year, - ", ".join(interests), - "; ".join(baby.education.values_list("organization_name", flat=True)), - baby.v2_speciality if baby.v2_speciality else baby.speciality, - baby.email, - ] - ) + [ + ed.user.first_name + " " + ed.user.last_name, + (today.year - ed.user.birthday.year) if ed.user.birthday.year else None, + ed.organization_name, + ed.user.speciality_v2 if ed.user.speciality_v2 else ed.user.speciality, + ed.user.email - for big_man in big_mans: - industry_names = [ - collab.project.industry.name if collab.project.industry else "" - for collab in big_man.collaborations.all() ] - response_data.append( - [ - big_man.first_name + " " + big_man.last_name, - today.year - big_man.birthday.year, - ", ".join(industry_names), - "; ".join(big_man.education.values_list("organization_name", flat=True)), - big_man.v2_speciality - if big_man.v2_speciality - else big_man.speciality, - big_man.email, - ] + ) + # for baby in little_mans: + # interests = [ + # collab.project.industry.name if collab.project.industry else "" + # for collab in baby.collaborations.all() + # ] + # if not len(interests): + # interests = [ + # skill_to_obj.skill.name if skill_to_obj.skill else "" + # for skill_to_obj in baby.skills.all() + # ] + # if not len(interests): + # interests = baby.key_skills.split(",") if baby.key_skills else [] + # response_data.append( + # [ + # baby.first_name + " " + baby.last_name, + # today.year - baby.birthday.year, + # ", ".join(interests), + # "; ".join(baby.education.values_list("organization_name", flat=True)), + # baby.v2_speciality if baby.v2_speciality else baby.speciality, + # baby.email, + # ] + # ) + # + # for big_man in big_mans: + # industry_names = [ + # collab.project.industry.name if collab.project.industry else "" + # for collab in big_man.collaborations.all() + # ] + # response_data.append( + # [ + # big_man.first_name + " " + big_man.last_name, + # today.year - big_man.birthday.year, + # ", ".join(industry_names), + # "; ".join(big_man.education.values_list("organization_name", flat=True)), + # big_man.v2_speciality + # if big_man.v2_speciality + # else big_man.speciality, + # big_man.email, + # ] + # ) + # для малолеток указать теги проектов, если нет - навыки # для старших - специальность, вуз, учебное заведение From fcabba2f199e5402801e8569e19ec28185b81ab7 Mon Sep 17 00:00:00 2001 From: Alexey Kudelko Date: Tue, 12 Nov 2024 00:50:54 +0300 Subject: [PATCH 2/2] loadout students --- users/admin.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/users/admin.py b/users/admin.py index 37cba5b4..80ff242d 100644 --- a/users/admin.py +++ b/users/admin.py @@ -262,11 +262,9 @@ def get_export_users_emails(self, users): today = date.today() # date_limit_18 = date(today.year - 18, today.month, today.day) - user_ed = ( - UserEducation.objects - .select_related("user", "user__v2_speciality") - .filter(education_status="Студент") - ) + user_ed = UserEducation.objects.select_related( + "user", "user__v2_speciality" + ).filter(education_status="Студент") # users = ( # CustomUser.objects.all() # .select_related("v2_speciality") @@ -280,15 +278,17 @@ def get_export_users_emails(self, users): for ed in user_ed: response_data.append( - [ - ed.user.first_name + " " + ed.user.last_name, - (today.year - ed.user.birthday.year) if ed.user.birthday.year else None, - ed.organization_name, - ed.user.speciality_v2 if ed.user.speciality_v2 else ed.user.speciality, - ed.user.email - - ] - + [ + ed.user.first_name + " " + ed.user.last_name, + (today.year - ed.user.birthday.year) + if ed.user.birthday.year + else None, + ed.organization_name, + ed.user.speciality_v2 + if ed.user.speciality_v2 + else ed.user.speciality, + ed.user.email, + ] ) # for baby in little_mans: