Skip to content

Commit

Permalink
clear eventtype color css on eventtype form save
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Jul 6, 2023
1 parent 8a33af0 commit 6747930
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ephios/core/forms/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django import forms
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.core.cache import cache
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.template.loader import render_to_string
Expand Down Expand Up @@ -247,6 +248,10 @@ def clean_color(self):
raise ValidationError(_("You need to enter a valid color"))
return self.cleaned_data["color"]

def save(self, commit=True):
super().save(commit=commit)
cache.delete("eventtype_colors_css")


class EventTypePreferenceForm(PreferenceForm):
registry = event_type_preference_registry
Expand Down
18 changes: 10 additions & 8 deletions ephios/core/templates/core/event_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

{% block content %}
<style nonce="{{ request.csp_nonce }}">
{% cache 900 "eventtype_colors" %}
{% eventtype_colors %}
{% endcache %}
</style>
{% cache 900 "eventtype_colors_css" %}
{% eventtype_colors %}
{% endcache %}
</style>

<div class="page-header">
<h1>{% translate "Events" %}
Expand Down Expand Up @@ -79,7 +79,8 @@ <h1>{% translate "Events" %}
><i class="fas fa-arrow-left"></i> {{ prev_month_first|date:"F Y" }}</a>
{% if perms.core.add_event %}
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle d-none d-md-inline-block" type="button" id="eventCreateButton"
<button class="btn btn-primary dropdown-toggle d-none d-md-inline-block" type="button"
id="eventCreateButton"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-plus"></span>
{% translate "Add event" %}
Expand Down Expand Up @@ -146,10 +147,11 @@ <h1>{% translate "Events" %}
<div class="list-group-item list-group-item-action p-0 d-flex flex-row">
<div class="m-0 py-2 d-flex flex-column flex-lg-row-reverse justify-content-around flex-grow-0">
<div class="ps-lg-2 d-flex flex-row flex-lg-column justify-content-center event-list-status-icon"
{% if counter %}
{% if counter %}
data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-html="true"
title="{% for state in counter %}<div>{% if event.shifts.all|length > 1 %}{{ counter|get:state }} {% endif %}{{ ParticipationStates.labels_dict|get:state }}</div>{% endfor %}"
{% endif %}>
title="{% for state in counter %}<div>
{% if event.shifts.all|length > 1 %}{{ counter|get:state }} {% endif %}{{ ParticipationStates.labels_dict|get:state }}</div>{% endfor %}"
{% endif %}>
{% if counter|get:ParticipationStates.CONFIRMED > 0 %}
<span class="text-success fa fa-user-check ps-2"></span>
{% elif counter|get:ParticipationStates.REQUESTED > 0 %}
Expand Down
2 changes: 1 addition & 1 deletion ephios/core/templates/core/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1 class="page-header">
</h1>

<style nonce="{{ request.csp_nonce }}">
{% cache 900 "eventtype_colors" %}
{% cache 900 "eventtype_colors_css" %}
{% eventtype_colors %}
{% endcache %}
</style>
Expand Down

0 comments on commit 6747930

Please sign in to comment.