Skip to content

Refactor Role and Authorization Models#31

Merged
berggren merged 1 commit intomainfrom
refactor
Nov 3, 2024
Merged

Refactor Role and Authorization Models#31
berggren merged 1 commit intomainfrom
refactor

Conversation

@berggren
Copy link
Contributor

@berggren berggren commented Nov 3, 2024

Summary:

This refactoring consolidates role definitions and streamlines authorization logic by moving Role, UserRole, and GroupRole from a separate roles.py module into role.py, user.py, and group.py, respectively.

Technical Details:

  • Consolidated Role Definitions: The Role enum, previously defined in src/datastores/sql/models/roles.py, is now located in src/datastores/sql/models/role.py. This centralizes the role definitions and removes the need for a dedicated roles.py file. This improves code organization and makes it easier to manage role-related logic.
  • Integrated User and Group Roles: The UserRole and GroupRole models, originally defined in roles.py, have been moved into user.py and group.py, respectively. This change more closely couples roles with the entities they pertain to (users and groups), promoting better code cohesion and simplifying related database operations. This reduces unnecessary imports and clarifies the relationships between users, groups, and their respective roles.
  • Updated Imports and Relationships: All affected files have been updated with the correct import paths to reflect the new locations of the Role, UserRole, and GroupRole definitions. The relationships between these models and other models (e.g., File, Folder) have been preserved to maintain database integrity. The group_user_association_table is now directly referenced in user.py, further streamlining the code.
  • Removal of Redundant File: The src/datastores/sql/models/roles.py file has been deleted as its contents have been migrated to other modules. This removes redundancy and simplifies the project structure.

@berggren berggren merged commit da37da8 into main Nov 3, 2024
@berggren berggren deleted the refactor branch November 3, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant