Skip to content

Conversation

@prayag78
Copy link
Contributor

@prayag78 prayag78 commented Nov 28, 2025

Summary

Color settings saved but presale page didn't update (missing CSS regeneration trigger). Added CSS regeneration trigger in EventUpdate.form_valid() method when color/theme settings are modified.

Fixes #1175

Add imports

from eventyay.base.settings import SETTINGS_AFFECTING_CSS
from eventyay.presale.style import regenerate_css

Add in form_valid()

if self.sform.has_changed() and any(p in self.sform.changed_data for p in SETTINGS_AFFECTING_CSS):
    regenerate_css.apply_async(args=(self.request.event.pk,))
image Screenshot 2025-11-28 220200

Summary by Sourcery

Bug Fixes:

  • Trigger presale CSS regeneration after saving event settings that affect styling so color/theme changes are reflected immediately.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures that when event color-related settings change in the event settings form, the presale page CSS is regenerated asynchronously, fixing a bug where saved color changes did not visually update.

Sequence diagram for updating event color settings and triggering CSS regeneration

sequenceDiagram
    actor AdminUser
    participant Browser
    participant DjangoServer
    participant EventUpdateView
    participant CeleryBroker
    participant TicketsInvalidateTask as tickets_invalidate_cache
    participant RegenerateCSSTask as regenerate_css

    AdminUser->>Browser: Edit event color settings
    AdminUser->>Browser: Click save
    Browser->>DjangoServer: POST /events/<id>/settings
    DjangoServer->>EventUpdateView: form_valid(form)

    EventUpdateView->>TicketsInvalidateTask: apply_async(kwargs={event: event_pk})

    alt Settings affecting CSS changed
        EventUpdateView->>RegenerateCSSTask: apply_async(args=(event_pk))
    else No CSS related settings changed
        EventUpdateView-->>RegenerateCSSTask: No call
    end

    EventUpdateView-->>DjangoServer: form_valid success
    DjangoServer-->>Browser: Redirect to success_url

    CeleryBroker-->>TicketsInvalidateTask: Dispatch task
    TicketsInvalidateTask->>TicketsInvalidateTask: Invalidate event ticket cache

    CeleryBroker-->>RegenerateCSSTask: Dispatch task (if triggered)
    RegenerateCSSTask->>RegenerateCSSTask: Regenerate event presale CSS
    RegenerateCSSTask-->>StaticFilesStore: Write updated CSS for event

    Browser->>StaticFilesStore: Request event presale page and CSS
    StaticFilesStore-->>Browser: Serve updated CSS
    Browser-->>AdminUser: Display updated event colors
Loading

Class diagram for EventUpdateView form_valid CSS regeneration logic

classDiagram
    class EventUpdateView {
        +form_valid(form)
        -sform
        -request
    }

    class TicketsModule {
        +invalidate_cache(event)
    }

    class RegenerateCSSModule {
        +regenerate_css(event_pk)
    }

    class SettingsConstants {
        <<constant>>
        +SETTINGS_AFFECTING_CSS
    }

    EventUpdateView ..> TicketsModule : uses
    EventUpdateView ..> RegenerateCSSModule : conditionally_uses
    EventUpdateView ..> SettingsConstants : reads

    note for EventUpdateView "form_valid(form) now:
- always calls tickets.invalidate_cache.apply_async(kwargs={event: event_pk})
- additionally calls regenerate_css.apply_async(args=(event_pk))
  when sform.has_changed() and any field in sform.changed_data
  is in SETTINGS_AFFECTING_CSS"
Loading

File-Level Changes

Change Details Files
Trigger asynchronous CSS regeneration when color-related settings are modified in the event settings form.
  • Import the list of settings that affect CSS and the CSS regeneration task.
  • After invalidating ticket cache in EventUpdate.form_valid, check if the settings form has changes that intersect with the CSS-affecting settings list.
  • If relevant settings changed, enqueue the regenerate_css task with the current event primary key so the presale stylesheet is rebuilt.
app/eventyay/eventyay_common/views/event.py
eventyay/base/settings.py (import usage only)
eventyay/presale/style.py (import usage only)

Assessment against linked issues

Issue Objective Addressed Explanation
#1175 Ensure that when color-related settings (e.g., Primary, Accent, Background) are modified and saved, the live preview/presale page immediately reflects the new colors (e.g., via CSS regeneration or similar binding).

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

  • The condition checking whether CSS-related settings changed could be made clearer and more efficient by using set intersection, e.g. if self.sform.has_changed() and SETTINGS_AFFECTING_CSS.intersection(self.sform.changed_data): instead of the any(...) loop.
  • For consistency with the existing tickets.invalidate_cache call, consider using keyword arguments (kwargs={'event': self.request.event.pk}) for regenerate_css.apply_async as well, unless the task signature specifically requires positional args.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The condition checking whether CSS-related settings changed could be made clearer and more efficient by using set intersection, e.g. `if self.sform.has_changed() and SETTINGS_AFFECTING_CSS.intersection(self.sform.changed_data):` instead of the `any(...)` loop.
- For consistency with the existing `tickets.invalidate_cache` call, consider using keyword arguments (`kwargs={'event': self.request.event.pk}`) for `regenerate_css.apply_async` as well, unless the task signature specifically requires positional args.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where color and theme settings changes were saved but not reflected on the presale page due to missing CSS regeneration. The fix adds a trigger to regenerate CSS asynchronously when settings that affect CSS are modified.

Key Changes:

  • Added imports for SETTINGS_AFFECTING_CSS and regenerate_css
  • Added CSS regeneration trigger in EventUpdate.form_valid() when color/theme settings change
  • Follows the existing pattern used in control/views/event.py for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Tested LGTM, please implement the Copilot suggestion

@mariobehling
Copy link
Member

In order to clarify. This does not solve the issue entirely. The colors and design of an organiser can be set at two places:

  1. In the organizer settings. In this case they apply to all events and organiser pages.
  2. In the specific event settings. In this case they apply to the event (currently only to the ticketing pages).

Apparently this PR only related to the organiser settings. I am merging this as it brings us forward to the solution, but it does not fully solve the issue.

@mariobehling mariobehling merged commit 9741041 into fossasia:enext Nov 28, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Eventyay Next Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Color settings do not update in the live preview after modification

3 participants