1- import urllib .parse
21from datetime import date
32
43import tablib
4+ import urllib .parse
55from django .conf import settings
66from django .contrib import admin
77from django .contrib .auth .models import Permission
88from django .http import HttpResponse
99from django .shortcuts import redirect
1010from django .urls import path
11- from django .utils .timezone import now
1211
13- from core .admin import SkillToObjectInline
1412from core .utils import XlsxFileToExport
1513from mailing .views import MailingTemplateRender
1614from users .services .users_activity import UserActivityDataPreparer
17-
18- from .helpers import force_verify_user , send_verification_completed_email
15+ from .helpers import send_verification_completed_email , force_verify_user
1916from .models import (
2017 CustomUser ,
21- Expert ,
22- Investor ,
18+ UserAchievement ,
2319 Member ,
2420 Mentor ,
25- UserAchievement ,
26- UserEducation ,
27- UserLanguages ,
21+ Expert ,
22+ Investor ,
2823 UserLink ,
29- UserSkillConfirmation ,
24+ UserEducation ,
3025 UserWorkExperience ,
26+ UserSkillConfirmation ,
27+ UserLanguages ,
3128)
3229
30+ from core .admin import SkillToObjectInline
31+
3332admin .site .register (Permission )
3433
3534
@@ -56,7 +55,7 @@ class UserLanguagesInline(admin.TabularInline):
5655
5756@admin .action (description = "Сделать выбранных пользователей подтверждёнными" )
5857def make_active (modeladmin , request , queryset ):
59- queryset .update (is_active = True , verification_date = now (). date () )
58+ queryset .update (is_active = True )
6059
6160
6261@admin .register (CustomUser )
@@ -269,9 +268,7 @@ def get_users_activity(self, _) -> HttpResponse:
269268 binary_data_to_export ,
270269 content_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ,
271270 )
272- response ["Content-Disposition" ] = (
273- f"attachment; filename*=UTF-8''{ encoded_file_name } "
274- )
271+ response ["Content-Disposition" ] = f'attachment; filename*=UTF-8\' \' { encoded_file_name } '
275272
276273 return response
277274
@@ -280,8 +277,7 @@ def get_export_users_emails(self, users):
280277 headers = [
281278 "Имя и фамилия" ,
282279 "Возраст" ,
283- "Интересы" ,
284- "ВУЗ / Школа" ,
280+ "Город" ,
285281 "Специальность" ,
286282 "Эл. почта" ,
287283 ]
@@ -290,67 +286,80 @@ def get_export_users_emails(self, users):
290286 today = date .today ()
291287
292288 date_limit_18 = date (today .year - 18 , today .month , today .day )
289+ date_limit_22 = date (today .year - 22 , today .month , today .day )
290+ # user_ed = UserEducation.objects.select_related(
291+ # "user", "user__v2_speciality"
292+ # ).filter(education_status="Студент")
293293 users = (
294294 CustomUser .objects .all ()
295295 .select_related ("v2_speciality" )
296- .prefetch_related (
297- "collaborations__project" ,
298- "collaborations__project__industry" ,
299- "skills__skill" ,
300- "education" ,
296+ .filter (
297+ birthday__lte = date_limit_18 ,
298+ birthday__gte = date_limit_22
301299 )
302300 )
303- little_mans = users .filter (birthday__lte = date_limit_18 )
304- big_mans = users .exclude (id__in = little_mans .values_list ("id" , flat = True ))
301+ # little_mans = users.filter(birthday__lte=date_limit_18)
302+ # big_mans = users.exclude(id__in=little_mans.values_list("id", flat=True))
305303
306304 # whole_quality = users.count()
307305 # quantity_little_mans = little_mans.count()
308306 # quantity_big_mans = whole_quality - quantity_little_mans
309307
310- for baby in little_mans :
311- interests = [
312- collab .project .industry .name if collab .project .industry else ""
313- for collab in baby .collaborations .all ()
314- ]
315- if not len (interests ):
316- interests = [
317- skill_to_obj .skill .name if skill_to_obj .skill else ""
318- for skill_to_obj in baby .skills .all ()
319- ]
320- if not len (interests ):
321- interests = baby .key_skills .split ("," ) if baby .key_skills else []
308+ for user in users :
322309 response_data .append (
323310 [
324- baby .first_name + " " + baby .last_name ,
325- today .year - baby .birthday .year ,
326- ", " .join (interests ),
327- "; " .join (
328- baby .education .values_list ("organization_name" , flat = True )
329- ),
330- baby .v2_speciality if baby .v2_speciality else baby .speciality ,
331- baby .email ,
311+ user .first_name + " " + user .last_name ,
312+ (today .year - user .birthday .year )
313+ if user .birthday .year
314+ else None ,
315+ user .city ,
316+ user .v2_speciality
317+ if user .v2_speciality
318+ else user .speciality ,
319+ user .email ,
332320 ]
333321 )
334322
335- for big_man in big_mans :
336- industry_names = [
337- collab .project .industry .name if collab .project .industry else ""
338- for collab in big_man .collaborations .all ()
339- ]
340- response_data .append (
341- [
342- big_man .first_name + " " + big_man .last_name ,
343- today .year - big_man .birthday .year ,
344- ", " .join (industry_names ),
345- "; " .join (
346- big_man .education .values_list ("organization_name" , flat = True )
347- ),
348- big_man .v2_speciality
349- if big_man .v2_speciality
350- else big_man .speciality ,
351- big_man .email ,
352- ]
353- )
323+ # for baby in little_mans:
324+ # interests = [
325+ # collab.project.industry.name if collab.project.industry else ""
326+ # for collab in baby.collaborations.all()
327+ # ]
328+ # if not len(interests):
329+ # interests = [
330+ # skill_to_obj.skill.name if skill_to_obj.skill else ""
331+ # for skill_to_obj in baby.skills.all()
332+ # ]
333+ # if not len(interests):
334+ # interests = baby.key_skills.split(",") if baby.key_skills else []
335+ # response_data.append(
336+ # [
337+ # baby.first_name + " " + baby.last_name,
338+ # today.year - baby.birthday.year,
339+ # ", ".join(interests),
340+ # "; ".join(baby.education.values_list("organization_name", flat=True)),
341+ # baby.v2_speciality if baby.v2_speciality else baby.speciality,
342+ # baby.email,
343+ # ]
344+ # )
345+ #
346+ # for big_man in big_mans:
347+ # industry_names = [
348+ # collab.project.industry.name if collab.project.industry else ""
349+ # for collab in big_man.collaborations.all()
350+ # ]
351+ # response_data.append(
352+ # [
353+ # big_man.first_name + " " + big_man.last_name,
354+ # today.year - big_man.birthday.year,
355+ # ", ".join(industry_names),
356+ # "; ".join(big_man.education.values_list("organization_name", flat=True)),
357+ # big_man.v2_speciality
358+ # if big_man.v2_speciality
359+ # else big_man.speciality,
360+ # big_man.email,
361+ # ]
362+ # )
354363
355364 # для малолеток указать теги проектов, если нет - навыки
356365 # для старших - специальность, вуз, учебное заведение
0 commit comments