From 506a8351643ece744c6850b825a7584f2a20c36f Mon Sep 17 00:00:00 2001 From: Alexey Kudelko Date: Wed, 16 Oct 2024 22:03:45 +0300 Subject: [PATCH 1/4] fix --- project_rates/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_rates/views.py b/project_rates/views.py index a28471fb..6b5d2792 100644 --- a/project_rates/views.py +++ b/project_rates/views.py @@ -66,7 +66,7 @@ def create(self, request, *args, **kwargs) -> Response: send_email.delay( ProjectRatedParams( message_type=MessageTypeEnum.PROJECT_RATED.value, - user_id=project.leader.name, + user_id=project.leader.id, project_name=project.name, project_id=project.id, schema_id=2, From 44f2b680d65a2a4e2d82697d10a8052ec9a0454d Mon Sep 17 00:00:00 2001 From: Alexey Kudelko Date: Wed, 16 Oct 2024 22:12:11 +0300 Subject: [PATCH 2/4] fix 1 --- project_rates/views.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/project_rates/views.py b/project_rates/views.py index 6b5d2792..1d5574f8 100644 --- a/project_rates/views.py +++ b/project_rates/views.py @@ -27,7 +27,7 @@ class RateProject(generics.CreateAPIView): serializer_class = ProjectScoreCreateSerializer permission_classes = [IsExpertPost] - def get_needed_data(self) -> tuple[dict, list[int]]: + def get_needed_data(self) -> tuple[dict, list[int], str]: data = self.request.data user_id = self.request.user.id project_id = self.kwargs.get("project_id") @@ -36,18 +36,20 @@ def get_needed_data(self) -> tuple[dict, list[int]]: criterion["criterion_id"] for criterion in data ] # is needed for validation later - Expert.objects.get(user__id=user_id, programs__criterias__id=criteria_to_get[0]) + expert = Expert.objects.get( + user__id=user_id, programs__criterias__id=criteria_to_get[0] + ) for criterion in data: criterion["user"] = user_id criterion["project"] = project_id criterion["criteria"] = criterion.pop("criterion_id") - return data, criteria_to_get + return data, criteria_to_get, expert.programs.all().first().name def create(self, request, *args, **kwargs) -> Response: try: - data, criteria_to_get = self.get_needed_data() + data, criteria_to_get, program_name = self.get_needed_data() serializer = ProjectScoreCreateSerializer( data=data, criteria_to_get=criteria_to_get, many=True @@ -70,6 +72,7 @@ def create(self, request, *args, **kwargs) -> Response: project_name=project.name, project_id=project.id, schema_id=2, + program_name=program_name, ) ) From 6efc54ea1f0a158542209acc839e9ce9485c1dd2 Mon Sep 17 00:00:00 2001 From: Alexey Kudelko Date: Wed, 16 Oct 2024 22:19:30 +0300 Subject: [PATCH 3/4] fix 1 --- vacancy/mapping.py | 1 + vacancy/tasks.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vacancy/mapping.py b/vacancy/mapping.py index 93a88a03..e92d0864 100644 --- a/vacancy/mapping.py +++ b/vacancy/mapping.py @@ -59,6 +59,7 @@ class ProjectRatedParams(BaseEmailCeleryParams): MessageTypeEnum.OUTDATED.value: "У вашей вакансии истёк срок годности", MessageTypeEnum.REJECTED.value: "На ваш отклик ответили отказом", MessageTypeEnum.REGISTERED_PROGRAM_USER.value: "Вы зарегистрировались на программу", + MessageTypeEnum.PROJECT_RATED.value: "Ваш проект был оценён", } diff --git a/vacancy/tasks.py b/vacancy/tasks.py index eb76a037..384a71f7 100644 --- a/vacancy/tasks.py +++ b/vacancy/tasks.py @@ -10,12 +10,13 @@ get_link, MessageTypeEnum, message_type_to_title, + EmailParamsType, ) from vacancy.models import Vacancy @app.task -def send_email(data: CeleryEmailParams): +def send_email(data: EmailParamsType): context_data = ContextDataDict( text=create_text_for_email(data), title=message_type_to_title[data["message_type"]], From 01dbf4f0bedb9334b1a257f99082294bbbfd05cc Mon Sep 17 00:00:00 2001 From: Alexey Kudelko Date: Wed, 16 Oct 2024 22:36:46 +0300 Subject: [PATCH 4/4] fix 1 --- users/tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/users/tasks.py b/users/tasks.py index 7724fedd..ddd4beba 100644 --- a/users/tasks.py +++ b/users/tasks.py @@ -5,6 +5,7 @@ from weasyprint import HTML from procollab.celery import app +from procollab.settings import EMAIL_USER from users.typing import UserCVData from users.services.cv_data_prepare import UserCVDataPreparer @@ -24,8 +25,9 @@ def send_mail_cv(user_id: int, user_email: str, filename: str): template_content = f.read() email = EmailMessage( - subject='Procollab | Резюме', + subject="Procollab | Резюме", body=template_content, + from_email=EMAIL_USER, to=[user_email], ) email.content_subtype = "html"