Skip to content

Commit

Permalink
Merge pull request #479 from PROCOLLAB-github/fix/user-verify
Browse files Browse the repository at this point in the history
Fix/user verify
  • Loading branch information
sh1nkey authored Nov 1, 2024
2 parents ba07d12 + 68b6153 commit 8a9aa19
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 149 deletions.
Empty file.
64 changes: 0 additions & 64 deletions core/management/commands/migrate_education.py

This file was deleted.

51 changes: 0 additions & 51 deletions core/management/commands/reverse_migrate_education.py

This file was deleted.

14 changes: 0 additions & 14 deletions log/migrated_users.json

This file was deleted.

6 changes: 3 additions & 3 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class CustomUserAdmin(admin.ModelAdmin):
"status",
"city",
"region",
"organization", # TODO need to be removed in future.
"speciality",
"v2_speciality",
"key_skills",
Expand Down Expand Up @@ -271,6 +270,7 @@ def get_export_users_emails(self, users):
"collaborations__project",
"collaborations__project__industry",
"skills__skill",
"education",
)
)
little_mans = users.filter(birthday__lte=date_limit_18)
Expand All @@ -297,7 +297,7 @@ def get_export_users_emails(self, users):
baby.first_name + " " + baby.last_name,
today.year - baby.birthday.year,
", ".join(interests),
baby.organization,
"; ".join(baby.education.values_list("organization_name", flat=True)),
baby.v2_speciality if baby.v2_speciality else baby.speciality,
baby.email,
]
Expand All @@ -313,7 +313,7 @@ def get_export_users_emails(self, users):
big_man.first_name + " " + big_man.last_name,
today.year - big_man.birthday.year,
", ".join(industry_names),
big_man.organization,
"; ".join(big_man.education.values_list("organization_name", flat=True)),
big_man.v2_speciality
if big_man.v2_speciality
else big_man.speciality,
Expand Down
3 changes: 1 addition & 2 deletions users/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UserFilter(filters.FilterSet):
Parameters to filter by:
first_name (str), last_name (str), patronymic (str),
city (str), region (str), organization (str), about_me__contains (str),
city (str), region (str), about_me__contains (str),
useful_to_project__contains (str)
Examples:
Expand Down Expand Up @@ -121,7 +121,6 @@ class Meta:
"patronymic",
"city",
"region",
"organization", # TODO need to be removed in future.
"user_type",
"speciality",
)
Expand Down
17 changes: 17 additions & 0 deletions users/migrations/0052_remove_customuser_organization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.11 on 2024-10-25 09:18

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("users", "0051_alter_usereducation_options_customuser_phone_number_and_more"),
]

operations = [
migrations.RemoveField(
model_name="customuser",
name="organization",
),
]
10 changes: 1 addition & 9 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class CustomUser(AbstractUser):
status: CharField instance notifies about the user's status.
region: CharField instance the user's name region.
city: CharField instance the user's name city.
organization: CharField instance the user's place of study or work.
speciality: CharField instance the user's specialty.
datetime_updated: A DateTimeField indicating date of update.
datetime_created: A DateTimeField indicating date of creation.
Expand Down Expand Up @@ -104,13 +103,6 @@ class CustomUser(AbstractUser):
verbose_name="Номер телефона",
help_text="Пример: +7 XXX XX-XX-XX | +7XXXXXXXXX | +7 (XXX) XX-XX-XX"
)
# TODO need to be removed in future `organization` -> `education`.
organization = models.CharField(
max_length=255,
null=True,
blank=True,
help_text="Устаревшее поле -> UserEducation",
)
v2_speciality = models.ForeignKey(
on_delete=models.SET_NULL,
null=True,
Expand Down Expand Up @@ -179,7 +171,7 @@ def calculate_ordering_score(self) -> int:
if self.city:
score += 4
# TODO need to be removed in future.
if self.organization or self.education.all().exists():
if self.education.all().exists():
score += 6
if self.speciality:
score += 7
Expand Down
1 change: 0 additions & 1 deletion users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ class Meta:
"speciality",
"v2_speciality",
"v2_speciality_id",
"organization", # TODO need to be removed in future.
"education",
"work_experience",
"user_languages",
Expand Down
7 changes: 2 additions & 5 deletions users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,6 @@ def post(self, request, *args, **kwargs):
return Response(
"User with given email does not exists!", status=status.HTTP_404_NOT_FOUND
)
except Exception:
return Response(status=status.HTTP_400_BAD_REQUEST)


class ForceVerifyView(APIView):
Expand Down Expand Up @@ -614,9 +612,7 @@ def get(self, request, *args, **kwargs) -> HttpResponse:
data_preparer = UserCVDataPreparerV2(request.user.pk)
user_cv_data: UserCVDataV2 = data_preparer.get_prepared_data()

html_string: str = render_to_string(
data_preparer.TEMPLATE_PATH, user_cv_data
)
html_string: str = render_to_string(data_preparer.TEMPLATE_PATH, user_cv_data)
binary_pdf_file: bytes | None = HTML(string=html_string).write_pdf()

encoded_filename: str = urllib.parse.quote(
Expand All @@ -635,6 +631,7 @@ class UserCVMailing(APIView):
Full-fledged work `UserCVDownload`.
The user can send a letter once per minute.
"""

permission_classes = [IsAuthenticated]

def get(self, request, *args, **kwargs):
Expand Down

0 comments on commit 8a9aa19

Please sign in to comment.