Skip to content

Conversation

Gagan-Ram
Copy link
Member

@Gagan-Ram Gagan-Ram commented Jul 12, 2025

Currently, any team member can edit general info of organizer in ey-common (https://app.eventyay.com/tickets/common/organizer/openai/update)
The PR aims to restrict the edit permission to only those Team members who has appropriate permission ("can_change_organizer_settings" to be precise)

Changes made:

  • Disable form fields on UI if user don't have appropriate permission
  • Only save the form with updated fields if user has the permission

Summary by Sourcery

Restrict editing of organizer general info to only those team members with the can_change_organizer_settings permission by adding permission checks to form rendering and submission.

Enhancements:

  • Disable name and slug fields in the organizer general info form for users without the can_change_organizer_settings permission.
  • Prevent unauthorized users from saving changes to the organizer name and slug by preserving the original values in form_valid.

Copy link
Contributor

sourcery-ai bot commented Jul 12, 2025

Reviewer's Guide

This PR integrates organizer permission checks into the form lifecycle, disabling UI inputs for unauthorized users and preventing any saved changes if the user lacks the 'can_change_organizer_settings' permission.

Sequence diagram for organizer general info edit permission enforcement

sequenceDiagram
    actor User
    participant View as OrganizerUpdateView
    participant Form
    participant Permission as PermissionSystem

    User->>View: Request organizer general info edit page
    View->>Permission: Check 'can_change_organizer_settings' permission
    Permission-->>View: Permission result
    View->>Form: Generate form (fields disabled if no permission)
    User->>View: Submit form
    View->>Permission: Check 'can_change_organizer_settings' permission
    Permission-->>View: Permission result
    alt User has permission
        View->>Form: Save submitted data
    else User lacks permission
        View->>Form: Overwrite changes with original data
    end
    View->>User: Return response
Loading

File-Level Changes

Change Details Files
Added permission-based disabling of form fields
  • Invoke has_organizer_permission in get_form
  • Disable 'name' and 'slug' fields when permission is missing
src/pretix/eventyay_common/views/organizer.py
Guarded form submission to discard unauthorized edits
  • Check permission again in form_valid
  • Reset cleaned_data for 'name' and 'slug' to original values if unauthorized
src/pretix/eventyay_common/views/organizer.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Gagan-Ram - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Sak1012
Copy link
Member

Sak1012 commented Jul 20, 2025

Hey Can you add screenshots of the changes

@Gagan-Ram
Copy link
Member Author

@Sak1012 To test the PR, please create a Team that includes a member who does not have the "Can change organizer settings" permission.
Now this member must not able to change the organizer's name from their account.
restr_non_org

Copy link
Contributor

@Saksham-Sirohi Saksham-Sirohi left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants