You've already forked RekomenciBackend
chore
This commit is contained in:
@@ -4,7 +4,7 @@ from template_project.application.common.identity_provider import IdentityProvid
|
||||
from template_project.application.common.interactor import to_interactor
|
||||
from template_project.application.common.unit_of_work import UnitOfWork
|
||||
from template_project.application.resume.data_gateway import ResumeDataGateway
|
||||
from template_project.application.resume.entity import ResumeId
|
||||
from template_project.application.resume.entity import Resume, ResumeId
|
||||
from template_project.application.resume.errors import ResumeDoesBelongUserError
|
||||
|
||||
|
||||
@@ -32,25 +32,36 @@ class EditResumeInteractor:
|
||||
experience_type: ExperienceType | None,
|
||||
) -> _Response:
|
||||
user = await self.identity_provider.get_current_user()
|
||||
resume = await self.resume_data_gateway.load(resume_id)
|
||||
if resume.user_id != user.id:
|
||||
old_resume = await self.resume_data_gateway.load(resume_id)
|
||||
if old_resume.user_id != user.id:
|
||||
raise ResumeDoesBelongUserError
|
||||
|
||||
if position is not None:
|
||||
resume.position = position
|
||||
if about_me is not None:
|
||||
resume.about_me = about_me
|
||||
if key_skills is not None:
|
||||
resume.key_skills = key_skills
|
||||
if experience_type is not None:
|
||||
resume.experience_type = experience_type
|
||||
new_position = position if position is not None else old_resume.position
|
||||
new_about_me = about_me if about_me is not None else old_resume.about_me
|
||||
new_key_skills = key_skills if key_skills is not None else old_resume.key_skills
|
||||
new_experience_type = experience_type if experience_type is not None else old_resume.experience_type
|
||||
|
||||
new_resume = Resume.factory(
|
||||
user_id=user.id,
|
||||
position=new_position,
|
||||
about_me=new_about_me,
|
||||
key_skills=new_key_skills,
|
||||
experience_type=new_experience_type,
|
||||
down_resume_id=old_resume.id,
|
||||
up_resume_id=None,
|
||||
)
|
||||
|
||||
await self.unit_of_work.add(new_resume)
|
||||
|
||||
if old_resume.up_resume_id is None:
|
||||
old_resume.up_resume_id = new_resume.id
|
||||
|
||||
await self.unit_of_work.commit()
|
||||
|
||||
return _Response(
|
||||
id=resume.id,
|
||||
position=resume.position,
|
||||
about_me=resume.about_me,
|
||||
key_skills=resume.key_skills,
|
||||
experience_type=resume.experience_type,
|
||||
id=new_resume.id,
|
||||
position=new_resume.position,
|
||||
about_me=new_resume.about_me,
|
||||
key_skills=new_resume.key_skills,
|
||||
experience_type=new_resume.experience_type,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user