-
Notifications
You must be signed in to change notification settings - Fork 148
Fix CSS not updating after color settings change #1360
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
Fix CSS not updating after color settings change #1360
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnsures 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 regenerationsequenceDiagram
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
Class diagram for EventUpdateView form_valid CSS regeneration logicclassDiagram
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"
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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 theany(...)loop. - For consistency with the existing
tickets.invalidate_cachecall, consider using keyword arguments (kwargs={'event': self.request.event.pk}) forregenerate_css.apply_asyncas 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this 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_CSSandregenerate_css - Added CSS regeneration trigger in
EventUpdate.form_valid()when color/theme settings change - Follows the existing pattern used in
control/views/event.pyfor consistency
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Saksham-Sirohi
left a comment
There was a problem hiding this 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
|
In order to clarify. This does not solve the issue entirely. The colors and design of an organiser can be set at two places:
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. |
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
Add in form_valid()
Summary by Sourcery
Bug Fixes: