Merge branch 'Kerl/banner' into 'master'
Add an announcement banner Closes #151 See merge request !236
This commit is contained in:
commit
5bed02c3fc
11 changed files with 116 additions and 6 deletions
|
@ -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:
|
||||
|
|
|
@ -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.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
|
||||
)
|
||||
|
|
|
@ -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 --------------------------------- */
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
{# CSS #}
|
||||
{# CSS #}
|
||||
<link type="text/css" rel="stylesheet" href="{% static "css/bootstrap.min.css" %}" />
|
||||
<link type="text/css" rel="stylesheet" href="{% static "css/cof.css" %}" />
|
||||
<link href="https://fonts.googleapis.com/css?family=Dosis|Dosis:700|Raleway|Roboto:300,300i,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{% static "font-awesome/css/font-awesome.min.css" %}">
|
||||
|
||||
{# JS #}
|
||||
{# JS #}
|
||||
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
{% block extra_head %}{% endblock %}
|
||||
|
|
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>
|
||||
</div><!-- /.container -->
|
||||
</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 %}
|
||||
{% for message in 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.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)
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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 %}
|
||||
<div class="row messages">
|
||||
{% for message in messages %}
|
||||
|
|
Loading…
Reference in a new issue