@@ -253,41 +253,46 @@ def get_export_users_emails(self, users):
253253 headers = [
254254 "Имя и фамилия" ,
255255 "Возраст" ,
256- "ВУЗ " ,
256+ "Город " ,
257257 "Специальность" ,
258258 "Эл. почта" ,
259259 ]
260260 )
261261
262262 today = date .today ()
263263
264- # date_limit_18 = date(today.year - 18, today.month, today.day)
265- user_ed = UserEducation .objects .select_related (
266- "user" , "user__v2_speciality"
267- ).filter (education_status = "Студент" )
268- # users = (
269- # CustomUser.objects.all()
270- # .select_related("v2_speciality")
271- # )
264+ date_limit_18 = date (today .year - 18 , today .month , today .day )
265+ date_limit_22 = date (today .year - 22 , today .month , today .day )
266+ # user_ed = UserEducation.objects.select_related(
267+ # "user", "user__v2_speciality"
268+ # ).filter(education_status="Студент")
269+ users = (
270+ CustomUser .objects .all ()
271+ .select_related ("v2_speciality" )
272+ .filter (
273+ birthday__gte = date_limit_18 ,
274+ birthday__lte = date_limit_22
275+ )
276+ )
272277 # little_mans = users.filter(birthday__lte=date_limit_18)
273278 # big_mans = users.exclude(id__in=little_mans.values_list("id", flat=True))
274279
275280 # whole_quality = users.count()
276281 # quantity_little_mans = little_mans.count()
277282 # quantity_big_mans = whole_quality - quantity_little_mans
278283
279- for ed in user_ed :
284+ for user in users :
280285 response_data .append (
281286 [
282- ed . user .first_name + " " + ed . user .last_name ,
283- (today .year - ed . user .birthday .year )
284- if ed . user .birthday .year
287+ user .first_name + " " + user .last_name ,
288+ (today .year - user .birthday .year )
289+ if user .birthday .year
285290 else None ,
286- ed . organization_name ,
287- ed . user .v2_speciality
288- if ed . user .v2_speciality
289- else ed . user .speciality ,
290- ed . user .email ,
291+ user . city ,
292+ user .v2_speciality
293+ if user .v2_speciality
294+ else user .speciality ,
295+ user .email ,
291296 ]
292297 )
293298
0 commit comments