Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/common/constants/permission_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,14 @@ class PermissionConstants(Enum):
group=Group.SYSTEM_RES_MODEL, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE_MODEL]
)
RESOURCE_MODEL_EDIT = Permission(
group=Group.SYSTEM_RES_MODEL, operate=Operate.EDIT, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE]
)
RESOURCE_MODEL_DELETE = Permission(
group=Group.SYSTEM_RES_MODEL, operate=Operate.DELETE, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE]
)
OPERATION_LOG_READ = Permission(
group=Group.OPERATION_LOG, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.OPERATION_LOG]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code snippet seems to be configuring permissions in an enumeration class, which is common in many systems for managing access control. However, it lacks comments explaining each permission's purpose and usage context.

Here are some general observations:

  1. Permission Naming:

    • While the names are descriptive, they could benefit from more specific naming that clearly identifies their functionality.
    • Consider using singular forms where appropriate (e.g., RESOURCE_MODEL instead of RESOURCE_MODELS, unless multiple models exist).
  2. Consistency:

    • Ensure consistency across all entries regarding the structure. For example, if one has parent groups [SystemGroup.RESOURCE], all might ideally follow this pattern.
  3. Documentation:

    • Add docstrings (docstrings) to explain what each permission represents and its use case within the system.
  4. Code Formatting:

    • Keep the format consistent throughout, including indentation and spacing.

Suggested Improvements

  1. Docstrings:

    """
    Access constants defining different types of permissions in the application.
    """
  2. Clearer Permissions:

    RESOURCE_MODEL_VIEW = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.READ, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
    
    RESOURCE_MODEL_CREATE = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.CREATE, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
    
    RESOURCE_MODEL_UPDATE = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.UPDATE, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
    
    RESOURCE_MODEL_DELETE = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.DELETE, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
  3. Optimization:

    • If you anticipate needing additional permissions related to ResourceModel, consider creating a separate module to avoid cluttering this class with unrelated functionalities.
    • Ensure that there are no duplicate or overly complex configurations that could hinder performance.

In summary, while the existing code works correctly, adding clearer documentation and potentially separating logic into manageable modules can improve maintainability and readability.

Expand Down
Loading