Skip to content

Commit

Permalink
loadout students
Browse files Browse the repository at this point in the history
  • Loading branch information
sh1nkey committed Nov 11, 2024
1 parent 68b6153 commit 72e58cb
Showing 1 changed file with 61 additions and 50 deletions.
111 changes: 61 additions & 50 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,74 +253,85 @@ 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",
)
# 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,
# ]
# )

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

Expand Down

0 comments on commit 72e58cb

Please sign in to comment.