Add an announcement banner
This commit is contained in:
parent
0815c96c1c
commit
ea21b07657
|
@ -82,6 +82,8 @@ urlpatterns = [
|
||||||
url(r'^utile_cof/diff_cof$', gestioncof_views.liste_diffcof),
|
url(r'^utile_cof/diff_cof$', gestioncof_views.liste_diffcof),
|
||||||
url(r'^utile_bda/bda_revente$', gestioncof_views.liste_bdarevente),
|
url(r'^utile_bda/bda_revente$', gestioncof_views.liste_bdarevente),
|
||||||
url(r'^k-fet/', include('kfet.urls')),
|
url(r'^k-fet/', include('kfet.urls')),
|
||||||
|
# djconfig
|
||||||
|
url(r"^config", gestioncof_views.ConfigUpdate.as_view())
|
||||||
]
|
]
|
||||||
|
|
||||||
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
default_app_config = 'gestioncof.apps.GestioncofConfig'
|
14
gestioncof/apps.py
Normal file
14
gestioncof/apps.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class GestioncofConfig(AppConfig):
|
||||||
|
name = 'gestioncof'
|
||||||
|
verbose_name = "Gestion des adhérents du COF"
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
self.register_config()
|
||||||
|
|
||||||
|
def register_config(self):
|
||||||
|
import djconfig
|
||||||
|
from .forms import GestioncofConfigForm
|
||||||
|
djconfig.register(GestioncofConfigForm)
|
|
@ -5,6 +5,8 @@ from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
||||||
from django.forms.formsets import BaseFormSet, formset_factory
|
from django.forms.formsets import BaseFormSet, formset_factory
|
||||||
from django.core.validators import MinLengthValidator
|
from django.core.validators import MinLengthValidator
|
||||||
|
|
||||||
|
from djconfig.forms import ConfigForm
|
||||||
|
|
||||||
from gestioncof.models import CofProfile, EventCommentValue, \
|
from gestioncof.models import CofProfile, EventCommentValue, \
|
||||||
CalendarSubscription, Club
|
CalendarSubscription, Club
|
||||||
from gestioncof.widgets import TriStateCheckbox
|
from gestioncof.widgets import TriStateCheckbox
|
||||||
|
@ -378,3 +380,16 @@ class ClubsForm(forms.Form):
|
||||||
queryset=Club.objects.all(),
|
queryset=Club.objects.all(),
|
||||||
widget=forms.CheckboxSelectMultiple,
|
widget=forms.CheckboxSelectMultiple,
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
|
|
||||||
|
# ---
|
||||||
|
# Announcements banner
|
||||||
|
# TODO: move this to the `gestion` app once the supportBDS branch is merged
|
||||||
|
# ---
|
||||||
|
|
||||||
|
class GestioncofConfigForm(ConfigForm):
|
||||||
|
gestion_banner = forms.CharField(
|
||||||
|
label=_("Announcements banner"),
|
||||||
|
help_text=_("An empty banner disables annoucements"),
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
|
|
@ -778,6 +778,17 @@ header .open > .dropdown-toggle.btn-default {
|
||||||
border-color: white;
|
border-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Announcements banner ------------------ */
|
||||||
|
|
||||||
|
#banner {
|
||||||
|
background-color: #d86b01;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
color: white;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FORMS --------------------------------- */
|
/* FORMS --------------------------------- */
|
||||||
|
|
||||||
|
|
23
gestioncof/templates/gestioncof/banner_update.html
Normal file
23
gestioncof/templates/gestioncof/banner_update.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{% extends "base_title.html" %}
|
||||||
|
{% load bootstrap %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block page_size %}col-sm-8{%endblock%}
|
||||||
|
|
||||||
|
{% block realcontent %}
|
||||||
|
<h2>{% trans "Global configuration" %}</h2>
|
||||||
|
<form id="profile form-horizontal" method="post" action="">
|
||||||
|
<div class="row" style="margin: 0 15%;">
|
||||||
|
{% csrf_token %}
|
||||||
|
<fieldset"center-block">
|
||||||
|
{% for field in form %}
|
||||||
|
{{ field | bootstrap }}
|
||||||
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<input type="submit" class="btn btn-primary pull-right"
|
||||||
|
value={% trans "Save" %} />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
|
@ -16,6 +16,14 @@
|
||||||
<h2 class="member-status">{% if user.first_name %}{{ user.first_name }}{% else %}<tt>{{ user.username }}</tt>{% endif %}, {% if user.profile.is_cof %}<tt class="user-is-cof">au COF{% else %}<tt class="user-is-not-cof">non-COF{% endif %}</tt></h2>
|
<h2 class="member-status">{% if user.first_name %}{{ user.first_name }}{% else %}<tt>{{ user.username }}</tt>{% endif %}, {% if user.profile.is_cof %}<tt class="user-is-cof">au COF{% else %}<tt class="user-is-not-cof">non-COF{% endif %}</tt></h2>
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{% if config.gestion_banner %}
|
||||||
|
<div id="banner" class="container">
|
||||||
|
<span class="glyphicon glyphicon-bullhorn"></span>
|
||||||
|
<span>{{ config.gestion_banner }}</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
<div class="messages">
|
<div class="messages">
|
||||||
|
|
|
@ -10,6 +10,8 @@ from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.views import login as django_login_view
|
from django.contrib.auth.views import login as django_login_view
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
|
from django.core.urlresolvers import reverse_lazy
|
||||||
|
from django.views.generic import FormView
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
|
||||||
|
@ -21,10 +23,11 @@ from gestioncof.models import EventCommentField, EventCommentValue, \
|
||||||
CalendarSubscription
|
CalendarSubscription
|
||||||
from gestioncof.models import CofProfile, Club
|
from gestioncof.models import CofProfile, Club
|
||||||
from gestioncof.decorators import buro_required, cof_required
|
from gestioncof.decorators import buro_required, cof_required
|
||||||
from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \
|
from gestioncof.forms import (
|
||||||
SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
|
UserProfileForm, EventStatusFilterForm, SurveyForm, SurveyStatusFilterForm,
|
||||||
RegistrationProfileForm, EventForm, CalendarForm, EventFormset, \
|
RegistrationUserForm, RegistrationProfileForm, EventForm, CalendarForm,
|
||||||
RegistrationPassUserForm, ClubsForm
|
EventFormset, RegistrationPassUserForm, ClubsForm, GestioncofConfigForm
|
||||||
|
)
|
||||||
|
|
||||||
from bda.models import Tirage, Spectacle
|
from bda.models import Tirage, Spectacle
|
||||||
|
|
||||||
|
@ -758,3 +761,18 @@ def calendar_ics(request, token):
|
||||||
response = HttpResponse(content=vcal.to_ical())
|
response = HttpResponse(content=vcal.to_ical())
|
||||||
response['Content-Type'] = "text/calendar"
|
response['Content-Type'] = "text/calendar"
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigUpdate(FormView):
|
||||||
|
form_class = GestioncofConfigForm
|
||||||
|
template_name = "gestioncof/banner_update.html"
|
||||||
|
success_url = reverse_lazy("home")
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if request.user is None or not request.user.is_superuser:
|
||||||
|
raise Http404
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.save()
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
|
@ -18,6 +18,17 @@ input[type=number]::-webkit-outer-spin-button {
|
||||||
100% { background: yellow; }
|
100% { background: yellow; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Announcements banner */
|
||||||
|
|
||||||
|
#banner {
|
||||||
|
background-color: #d86b01;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
color: white;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Top row
|
* Top row
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
{% if config.gestion_banner %}
|
||||||
|
<div id="banner" class="container">
|
||||||
|
<span class="glyphicon glyphicon-bullhorn"></span>
|
||||||
|
<span>{{ config.gestion_banner }}</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
<div class="row messages">
|
<div class="row messages">
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
|
|
Loading…
Reference in a new issue