Open AntonioMrtz opened 4 months ago
@AntonioMrtz Thanks for suggesting this issue! Iād like to work on it.
@xiomaraR All yours, just tell me if you need anything :)
Hi @xiomaraR , how is it going? This weekend I made some major changes related to JWT Authentication. One of the last tasks I had pending about developer experience on the app was to re-enable Swagger docs for backend. Because of the JWT Middleware we had before request had to be made using frontend or Postman, the authentication field all protected endpoints had didn't work as expected. I think I will create a new docs page about tips/help on how to develop the app such as debugging, use of swagger etc.
But for now you can use Swagger docs for making backend requests, Im sure it will improve developer experience and ease the testing/develop. For using Swagger requests on protected endpoints you will need:
Let me know if its useful or if you have any questions about the task. š
Hey @AntonioMrtz so I couldn't find a method in user_service or anywhere else that creates artist from user, so I tried to create one. Will you let me know if I'm on the right track? I wasn't sure of the best way to fetch the user data
def upgrade_user_to_artist(user_name: str) -> None:
"""Promote a user to an artist then deletes user
Args:
user_name (str): user name
Raises:
UserServiceException: unexpected error upgrading user
"""
try:
user = user_repository.get_user(user_name)
if artist_service.create_artist(user.name, user.photo, user.password):
base_user_service.delete_user(user_name)
except Exception as exception:
user_service_logger.exception(
f"Unexpected error upgrading {user_name} to artist"
)
raise UserServiceException from exception
Hi @xiomaraR. Yeah, theres no create artist from user
method, the goal was to create the structure for it in this issue. The code looks good but theres a few things you can improve:
if artist_service.create_artist(user.name, user.photo, user.password):
doesnt return. If something went wrong an exception will be thrown. So theres no need for an if statement there(RepositoryException,Exception)
can lead to better readabilityvalidate_user_exists
is needed before getting the user from db. If we add this check we will need to handle UserNotFoundException
exception and raise it into controller layer so we can send a 404 response.# TODO make it a transaction
inside upgrade_user_to_artist
.Let me know if you need anything. I will be happy to answer š
Hi @xiomaraR are u still working on this issue? :)
Create an endpoint for PATCH /users/:id/promote that accepts the name of an existing user and: