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

Add demo group (DEV-1040) #725

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add demo group (DEV-1040) #725

wants to merge 1 commit into from

Conversation

mikefeldberg
Copy link
Contributor

@mikefeldberg mikefeldberg commented Nov 21, 2024

DEV-1040

Summary by Sourcery

Add a new 'Demo' permission group and template, update user setup utilities to include demo users, and adjust permissions accordingly. Implement migrations to support these changes and update tests to cover demo user scenarios.

New Features:

  • Introduce a new 'Demo' permission group and template to manage demo users.

Enhancements:

  • Modify the user setup utility to include a demo user with specific attributes.

Build:

  • Add migrations to create the 'Demo' group and update permissions for demo users.

Tests:

  • Update test cases to include scenarios for the demo user, ensuring they do not have certain permissions.

Copy link

sourcery-ai bot commented Nov 21, 2024

Reviewer's Guide by Sourcery

This PR implements a new demo group functionality by adding a Demo permission group template and modifying the user permission handling system to accommodate demo users. The implementation includes changes to handle demo users differently from regular caseworkers, particularly in terms of permissions and client profile access.

Class diagram for updated user and permission handling

classDiagram
    class User {
        +String email
        +save()
    }
    class PermissionGroupTemplate {
        +String name
        +add_permission(Permission)
    }
    class PermissionGroup {
        +Organization organization
        +Group group
    }
    class Organization {
        +add_user(User)
    }
    class Permission {
        +String codename
    }
    class ContentType {
        +get_for_model(Model)
    }
    class ClientProfile {
    }
    User --> PermissionGroup
    PermissionGroupTemplate --> Permission
    PermissionGroup --> Organization
    PermissionGroup --> Group
    ContentType --> ClientProfile
    PermissionGroupTemplate o-- Permission : add
    PermissionGroupTemplate : +get_or_create(name)
    PermissionGroup : +get_or_create(organization, template)
    Permission : +filter(codename, content_type)
    ContentType : +objects.get_for_model(ClientProfile)

    note for User "Demo users have specific email pattern '+demo@example.com'"
    note for PermissionGroupTemplate "New 'Demo' template added"
    note for PermissionGroup "Handles both 'Caseworker' and 'Demo' groups"
Loading

File-Level Changes

Change Details Files
Added new Demo permission group template and associated infrastructure
  • Created new Demo group template enum value
  • Added migration to create Demo group and permission template
  • Added demo user to test utilities
apps/betterangels-backend/accounts/groups.py
apps/betterangels-backend/accounts/migrations/0039_add_demo_group.py
apps/betterangels-backend/common/tests/utils.py
Modified permission handling logic to support demo users
  • Updated user permission group retrieval to include Demo group template
  • Added logic to detect demo users by email pattern
  • Modified default permission assignment based on user type
  • Added specific client profile permissions for non-caseworker groups
apps/betterangels-backend/accounts/utils.py
apps/betterangels-backend/clients/schema.py
apps/betterangels-backend/clients/migrations/0010_demo_clientprofile_permissions.py
Updated tests to include demo user scenarios
  • Added demo user to permission tests
  • Added test case to verify demo users cannot create client profiles
apps/betterangels-backend/clients/tests/test_permissions.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@mikefeldberg mikefeldberg changed the title add demo group; migrations wip; tests wip (DEV-1040) Add demo group (DEV-1040) Nov 21, 2024
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