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 a button in admin settings to enable/disable validation of organizer billing #504

Open
wants to merge 9 commits into
base: development
Choose a base branch
from

Conversation

HungNgien
Copy link
Collaborator

@HungNgien HungNgien commented Jan 10, 2025

image
Button in admin panels

image
When validation is enabled

image
When validation is disabled

This PR resolves #486

Summary by Sourcery

New Features:

  • Allow administrators to enable or disable billing validation through a dedicated button in the admin settings.

Copy link

sourcery-ai bot commented Jan 10, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new toggle button in the admin settings to enable or disable the validation of organizer billing information. When enabled, organizers are required to provide valid billing information. Disabling the toggle removes this requirement.

Sequence diagram for toggling billing validation

sequenceDiagram
    actor Admin
    participant UI
    participant ToggleBillingValidationView
    participant GlobalSettings

    Admin->>UI: Access billing validation settings
    UI->>ToggleBillingValidationView: GET request
    ToggleBillingValidationView->>GlobalSettings: Get billing_validation setting
    GlobalSettings-->>ToggleBillingValidationView: Return current state
    ToggleBillingValidationView-->>UI: Display toggle button
    UI-->>Admin: Show current validation state

    Admin->>UI: Click toggle button
    UI->>ToggleBillingValidationView: POST request with new state
    ToggleBillingValidationView->>GlobalSettings: Update billing_validation setting
    ToggleBillingValidationView-->>UI: Redirect to success URL
    UI-->>Admin: Show updated state
Loading

Class diagram for billing validation implementation

classDiagram
    class ToggleBillingValidationView {
        +ValidState: StrEnum
        -gs: GlobalSettingsObject
        +get_context_data()
        +post(request)
        +get_success_url()
    }

    class ValidState {
        <<enumeration>>
        DISABLED
        ENABLED
    }

    class Event {
        +live_issues()
    }

    class GlobalSettingsObject {
        +settings
    }

    ToggleBillingValidationView --> GlobalSettingsObject
    ToggleBillingValidationView --> ValidState
    Event --> GlobalSettingsObject

    note for ToggleBillingValidationView "Handles billing validation toggle"
    note for Event "Modified to check billing validation setting"
Loading

File-Level Changes

Change Details Files
Added a toggle button in the admin settings.
  • Created a new view ToggleBillingValidationView to handle the toggle functionality.
  • Added a new template toggle_billing_validation.html for the toggle button UI.
  • Updated the admin navigation to include a link to the new toggle.
  • Added a new URL route for the toggle view.
src/pretix/control/views/global_settings.py
src/pretix/control/templates/pretixcontrol/toggle_billing_validation.html
src/pretix/control/navigation.py
src/pretix/control/urls.py
Implemented the billing validation toggle logic.
  • The ToggleBillingValidationView reads and updates the billing_validation setting in the global settings.
  • The event.py file now checks the billing_validation setting before adding a billing-related issue.
src/pretix/control/views/global_settings.py
src/pretix/base/models/event.py

Assessment against linked issues

Issue Objective Addressed Explanation
#486 Enable an admin setting to toggle validation of organizer billing information
#486 Allow events to be published without mandatory billing information when validation is disabled

Possibly linked issues


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

@HungNgien HungNgien marked this pull request as ready for review January 10, 2025 05:00
Copy link

@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 @HungNgien - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider consolidating the default value handling for billing_validation - it's currently set in both ToggleBillingValidationView.get_context_data() and implicitly in Event.live_issues(). This could lead to maintenance issues if the defaults get out of sync.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@mariobehling mariobehling requested a review from hongquan January 10, 2025 05:36
Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

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

Please change the URL from /control/admin/global/toggle_billing_validation/ to /control/admin/global/billing_validation/

src/pretix/base/models/event.py Outdated Show resolved Hide resolved
src/pretix/control/views/global_settings.py Outdated Show resolved Hide resolved
src/pretix/helpers/enums.py Outdated Show resolved Hide resolved
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.

Enable/Disable Event Publishing configuration on admin settings.
3 participants