Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiate between BaseUser and User #159

Open
AntonioMrtz opened this issue Jul 4, 2024 · 3 comments
Open

Differentiate between BaseUser and User #159

AntonioMrtz opened this issue Jul 4, 2024 · 3 comments
Assignees
Labels
backend Backend related issues help-wanted Help is wanted python Pull requests that update Python code refactor Code changes or improvements that do not change code behaviour

Comments

@AntonioMrtz
Copy link
Owner

Description

Differentiate between BaseUser and User by creating a Base class for all users and a User class that implements it, just like Artist is doing it at the moment.

Context

User class serves as BaseUser class and Artist inherits from it. The issue appears when trying to implement new users like for example an admin. This type of user doesnt care about fields such as playback_history and so.

Currently User class is both a Base class and a Concrete one. This can lead to confusion because other inheritances in the app such as songs have a Base and Concrete class that are not the same.

The aim is to:

  • Encapsulate common user attributes into a Base class BaseUser
  • Create a concrete User class User that inherits from BaseUser and its being inherited by Artists.

Watch below for more info about the attributes:

@dataclass
class UserDAO:
    """Represents  user data in the persistence layer"""

    name: str - common
    photo: str - common
    register_date: str - common
    password: bytes - common
    playback_history: list[str] - user and its children classes
    playlists: list[str] - user and its children classes
    saved_playlists: list[str] - user and its children classes

@dataclass
class ArtistDAO(UserDAO):
    """Represents artist data in the persistence layer"""

    uploaded_songs: list[str] - artist and its children classes

How to do it

  • Create BaseUser
  • Modify User
  • Change type annotations from User to BaseUser in the common methods

Testing

  • Ensure old functionalities still works
  • Test new funcionality
@AntonioMrtz AntonioMrtz added backend Backend related issues refactor Code changes or improvements that do not change code behaviour python Pull requests that update Python code labels Jul 4, 2024
@AntonioMrtz
Copy link
Owner Author

@AntonioMrtz AntonioMrtz added the help-wanted Help is wanted label Jul 4, 2024
@AntonioMrtz AntonioMrtz pinned this issue Aug 26, 2024
@AlesSust
Copy link

AlesSust commented Oct 8, 2024

Hi @AntonioMrtz. I saw your issue and I would like to contribute to project Would you assign this to me? :)

@AntonioMrtz
Copy link
Owner Author

AntonioMrtz commented Oct 9, 2024

Hi @AlesSust , welcome to the project and thanks for your time. Sure, I will asign you to the issue. Let me know if you need anything :).We have a website with the project docs for set up the app and related topics. If you find this project interesting/helpful, I'd appreciate it if you could star the repo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related issues help-wanted Help is wanted python Pull requests that update Python code refactor Code changes or improvements that do not change code behaviour
Projects
None yet
Development

No branches or pull requests

2 participants