diff --git a/cof/urls.py b/cof/urls.py
index 06b1087a..363d3cfb 100644
--- a/cof/urls.py
+++ b/cof/urls.py
@@ -82,6 +82,8 @@ urlpatterns = [
url(r'^utile_cof/diff_cof$', gestioncof_views.liste_diffcof),
url(r'^utile_bda/bda_revente$', gestioncof_views.liste_bdarevente),
url(r'^k-fet/', include('kfet.urls')),
+ # djconfig
+ url(r"^config", gestioncof_views.ConfigUpdate.as_view())
]
if 'debug_toolbar' in settings.INSTALLED_APPS:
diff --git a/gestioncof/__init__.py b/gestioncof/__init__.py
index e69de29b..b77fdb94 100644
--- a/gestioncof/__init__.py
+++ b/gestioncof/__init__.py
@@ -0,0 +1 @@
+default_app_config = 'gestioncof.apps.GestioncofConfig'
diff --git a/gestioncof/apps.py b/gestioncof/apps.py
new file mode 100644
index 00000000..c3182b2d
--- /dev/null
+++ b/gestioncof/apps.py
@@ -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)
diff --git a/gestioncof/forms.py b/gestioncof/forms.py
index b52f5417..793f14e5 100644
--- a/gestioncof/forms.py
+++ b/gestioncof/forms.py
@@ -5,6 +5,8 @@ from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
from django.forms.formsets import BaseFormSet, formset_factory
from django.core.validators import MinLengthValidator
+from djconfig.forms import ConfigForm
+
from gestioncof.models import CofProfile, EventCommentValue, \
CalendarSubscription, Club
from gestioncof.widgets import TriStateCheckbox
@@ -378,3 +380,16 @@ class ClubsForm(forms.Form):
queryset=Club.objects.all(),
widget=forms.CheckboxSelectMultiple,
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
+ )
diff --git a/gestioncof/static/css/cof.css b/gestioncof/static/css/cof.css
index fda55d98..e1cdd763 100644
--- a/gestioncof/static/css/cof.css
+++ b/gestioncof/static/css/cof.css
@@ -778,6 +778,17 @@ header .open > .dropdown-toggle.btn-default {
border-color: white;
}
+/* Announcements banner ------------------ */
+
+#banner {
+ background-color: #d86b01;
+ width: 100%;
+ text-align: center;
+ padding: 10px;
+ color: white;
+ font-size: larger;
+}
+
/* FORMS --------------------------------- */
diff --git a/gestioncof/templates/base.html b/gestioncof/templates/base.html
index 6c570ae8..41880c61 100644
--- a/gestioncof/templates/base.html
+++ b/gestioncof/templates/base.html
@@ -8,13 +8,13 @@
- {# CSS #}
+ {# CSS #}
- {# JS #}
+ {# JS #}
{% block extra_head %}{% endblock %}
diff --git a/gestioncof/templates/gestioncof/banner_update.html b/gestioncof/templates/gestioncof/banner_update.html
new file mode 100644
index 00000000..b2432eae
--- /dev/null
+++ b/gestioncof/templates/gestioncof/banner_update.html
@@ -0,0 +1,23 @@
+{% extends "base_title.html" %}
+{% load bootstrap %}
+{% load i18n %}
+
+{% block page_size %}col-sm-8{%endblock%}
+
+{% block realcontent %}
+
{% trans "Global configuration" %}
+
+{% endblock %}
diff --git a/gestioncof/templates/gestioncof/base_header.html b/gestioncof/templates/gestioncof/base_header.html
index a7e29eb7..21441875 100644
--- a/gestioncof/templates/gestioncof/base_header.html
+++ b/gestioncof/templates/gestioncof/base_header.html
@@ -16,6 +16,14 @@
{% if user.first_name %}{{ user.first_name }}{% else %}{{ user.username }}{% endif %}, {% if user.profile.is_cof %}au COF{% else %}non-COF{% endif %}
+
+{% if config.gestion_banner %}
+
+
+ {{ config.gestion_banner }}
+
+{% endif %}
+
{% if messages %}
{% for message in messages %}
diff --git a/gestioncof/views.py b/gestioncof/views.py
index 6a728ea6..f98c51df 100644
--- a/gestioncof/views.py
+++ b/gestioncof/views.py
@@ -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.models import User
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.contrib import messages
@@ -21,10 +23,11 @@ from gestioncof.models import EventCommentField, EventCommentValue, \
CalendarSubscription
from gestioncof.models import CofProfile, Club
from gestioncof.decorators import buro_required, cof_required
-from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \
- SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
- RegistrationProfileForm, EventForm, CalendarForm, EventFormset, \
- RegistrationPassUserForm, ClubsForm
+from gestioncof.forms import (
+ UserProfileForm, EventStatusFilterForm, SurveyForm, SurveyStatusFilterForm,
+ RegistrationUserForm, RegistrationProfileForm, EventForm, CalendarForm,
+ EventFormset, RegistrationPassUserForm, ClubsForm, GestioncofConfigForm
+)
from bda.models import Tirage, Spectacle
@@ -758,3 +761,18 @@ def calendar_ics(request, token):
response = HttpResponse(content=vcal.to_ical())
response['Content-Type'] = "text/calendar"
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)
diff --git a/kfet/static/kfet/css/kpsul.css b/kfet/static/kfet/css/kpsul.css
index ba88e433..da1cffa1 100644
--- a/kfet/static/kfet/css/kpsul.css
+++ b/kfet/static/kfet/css/kpsul.css
@@ -18,6 +18,17 @@ input[type=number]::-webkit-outer-spin-button {
100% { background: yellow; }
}
+/* Announcements banner */
+
+#banner {
+ background-color: #d86b01;
+ width: 100%;
+ text-align: center;
+ padding: 10px;
+ color: white;
+ font-size: larger;
+}
+
/*
* Top row
*/
diff --git a/kfet/templates/kfet/base_messages.html b/kfet/templates/kfet/base_messages.html
index 440b8c10..3af19b31 100644
--- a/kfet/templates/kfet/base_messages.html
+++ b/kfet/templates/kfet/base_messages.html
@@ -1,3 +1,10 @@
+{% if config.gestion_banner %}
+
+
+ {{ config.gestion_banner }}
+
+{% endif %}
+
{% if messages %}
{% for message in messages %}