Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/new students loadout #484

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 61 additions & 50 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,73 +253,84 @@ def get_export_users_emails(self, users):
headers=[
"Имя и фамилия",
"Возраст",
"Интересы",
"ВУЗ / Школа",
"ВУЗ",
"Специальность",
"Эл. почта",
]
)

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",
)
)
little_mans = users.filter(birthday__lte=date_limit_18)
big_mans = users.exclude(id__in=little_mans.values_list("id", flat=True))
# date_limit_18 = date(today.year - 18, today.month, today.day)
user_ed = UserEducation.objects.select_related(
"user", "user__v2_speciality"
).filter(education_status="Студент")
# 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,
# ]
# )

# для малолеток указать теги проектов, если нет - навыки
# для старших - специальность, вуз, учебное заведение
Expand Down
Loading