Merge branch 'Kerl/django111-packages' into 'supportBDS'
Upgrade to Django 1.11 - We upgrade our django packages to 1.11 (beta 1) - We apply some necessary changes in the settings file - We prepare to upgrade Django-autocomplete-light - We upgrade some other packages See merge request !179
This commit is contained in:
commit
0e4cfc5121
21 changed files with 67 additions and 254 deletions
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import autocomplete_light
|
||||
from datetime import timedelta
|
||||
from custommail.shortcuts import send_mass_custom_mail
|
||||
|
||||
|
@ -119,8 +118,6 @@ class AttributionAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
class ChoixSpectacleAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[])
|
||||
|
||||
def tirage(self, obj):
|
||||
return obj.participant.tirage
|
||||
list_display = ("participant", "tirage", "spectacle", "priority",
|
||||
|
|
6
bda/apps.py
Normal file
6
bda/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BdAConfig(AppConfig):
|
||||
name = "bda"
|
||||
verbose_name = "Gestion des tirages du BdA"
|
|
@ -1,18 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
from bda.models import Participant, Spectacle
|
||||
|
||||
autocomplete_light.register(
|
||||
Participant, search_fields=('user__username', 'user__first_name',
|
||||
'user__last_name'),
|
||||
autocomplete_js_attributes={'placeholder': 'participant...'})
|
||||
|
||||
autocomplete_light.register(
|
||||
Spectacle, search_fields=('title', ),
|
||||
autocomplete_js_attributes={'placeholder': 'spectacle...'})
|
6
bds/apps.py
Normal file
6
bds/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BDSConfig(AppConfig):
|
||||
name = "bds"
|
||||
verbose_name = "Application de gestion du BDS"
|
|
@ -1,33 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.auth.models import Group, Permission
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_groups(apps, schema_editor):
|
||||
from django.contrib.auth.management import create_permissions
|
||||
|
||||
apps.models_module = True
|
||||
create_permissions(apps, verbosity=0)
|
||||
apps.models_module = None
|
||||
|
||||
memberp = Permission.objects.get(
|
||||
codename="member",
|
||||
content_type__app_label="bds"
|
||||
)
|
||||
burop = Permission.objects.get(
|
||||
codename="buro",
|
||||
content_type__app_label="bds"
|
||||
)
|
||||
|
||||
# Creates the groups for BDS members and staff
|
||||
member = Group.objects.create(name="bds_members")
|
||||
buro = Group.objects.create(name="bds_buro")
|
||||
|
||||
# Associates the permissions to the respective groups
|
||||
member.permissions = [memberp]
|
||||
buro.permissions = [memberp, burop]
|
||||
"""
|
||||
Creates the groups for BDS members and staff
|
||||
"""
|
||||
Group = apps.get_model("auth", "Group")
|
||||
Group.objects.get_or_create(name="bds_members")
|
||||
Group.objects.get_or_create(name="bds_buro")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
|
@ -5,8 +5,6 @@ from django.core.urlresolvers import reverse
|
|||
from django.utils.safestring import mark_safe
|
||||
import django.utils.six as six
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
from .petits_cours_models import PetitCoursDemande, \
|
||||
PetitCoursSubject, PetitCoursAbility, PetitCoursAttribution, \
|
||||
PetitCoursAttributionCounter
|
||||
|
@ -94,7 +92,6 @@ class EventAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
class EventRegistrationAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(EventRegistration, exclude=[])
|
||||
list_display = ('__unicode__' if six.PY2 else '__str__', 'event', 'user',
|
||||
'paid')
|
||||
list_filter = ('paid',)
|
||||
|
|
6
cof/apps.py
Normal file
6
cof/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class COFConfig(AppConfig):
|
||||
name = "cof"
|
||||
verbose_name = "Application de gestion du COF"
|
|
@ -1,10 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
autocomplete_light.register(
|
||||
User, search_fields=('username', 'first_name', 'last_name'),
|
||||
attrs={'placeholder': 'membre...'}
|
||||
)
|
14
cof/forms.py
14
cof/forms.py
|
@ -12,8 +12,7 @@ from django.forms.formsets import BaseFormSet, formset_factory
|
|||
from django.db.models import Max
|
||||
from django.core.validators import MinLengthValidator
|
||||
|
||||
from .models import CofProfile, EventCommentValue, \
|
||||
CalendarSubscription, Club
|
||||
from .models import CofProfile, EventCommentValue, CalendarSubscription
|
||||
from .widgets import TriStateCheckbox
|
||||
|
||||
from gestion.models import Profile
|
||||
|
@ -368,14 +367,3 @@ class CalendarForm(forms.ModelForm):
|
|||
model = CalendarSubscription
|
||||
fields = ['subscribe_to_events', 'subscribe_to_my_shows',
|
||||
'other_shows']
|
||||
|
||||
|
||||
class ClubsForm(forms.Form):
|
||||
"""
|
||||
Formulaire d'inscription d'un membre à plusieurs clubs du COF.
|
||||
"""
|
||||
clubs = forms.ModelMultipleChoiceField(
|
||||
label="Inscriptions aux clubs du COF",
|
||||
queryset=Club.objects.all(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False)
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
<li><a href="{% url "admin:index" %}">Administration générale</a></li>
|
||||
<li><a href="{% url "petits-cours-demandes-list" %}">Demandes de petits cours</a></li>
|
||||
<li><a href="{% url "registration" %}">Inscription d'un nouveau membre</a></li>
|
||||
<li><a href="{% url "liste-clubs" %}">Gestion des clubs</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<h4>Évènements & Sondages</h4>
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
{% extends "base_title.html" %}
|
||||
|
||||
{% block page_size %}col-sm-8{% endblock %}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>Clubs enregistrés sur GestioCOF</h2>
|
||||
<ul>
|
||||
{% for club in owned_clubs %}
|
||||
<li>
|
||||
<a href="{% url "membres-club" club.name %}">
|
||||
{{ club }} ({% for respo in club.respos.all %}{{ respo.get_full_name }}, {% empty %}pas de respo{% endfor %})
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% if other_clubs %}
|
||||
{% for club in other_clubs %}
|
||||
<li>
|
||||
<p>
|
||||
{{ club }} ({% for respo in club.respos.all %}{{ respo.get_full_name }}, {% empty %}pas de respo{% endfor %})
|
||||
</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endblock %}
|
|
@ -1,41 +0,0 @@
|
|||
{% extends "base_title.html" %}
|
||||
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>{{ club }}</h2>
|
||||
|
||||
|
||||
{% if club.respos.exists %}
|
||||
<h3>Respo{{ club.respos.all|pluralize }}</h3>
|
||||
<table class="table table-striped">
|
||||
{% for member in club.respos.all %}
|
||||
<tr>
|
||||
<td>{{ member }}</td>
|
||||
<td>{{ member.email }}</td>
|
||||
<td><a class="glyphicon glyphicon-arrow-down"
|
||||
href="{% url "change-respo" club.name member.id %}"></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<h3>Pas de respo</h3>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if club.membres.exists %}
|
||||
<h3>Liste des membres</h3>
|
||||
<table class="table table-striped">
|
||||
{% for member in members_no_respo %}
|
||||
<tr>
|
||||
<td>{{ member }}</td>
|
||||
<td>{{ member.email }}</td>
|
||||
<td><a class="glyphicon glyphicon-arrow-up"
|
||||
href="{% url "change-respo" club.name member.id %}"></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
Ce club ne comporte actuellement aucun membre.
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
|
@ -16,7 +16,6 @@
|
|||
<hr />
|
||||
<table>
|
||||
{{ cofprofile_form | bootstrap }}
|
||||
{{ clubs_form | bootstrap }}
|
||||
</table>
|
||||
{{ event_formset.management_form }}
|
||||
{% for event_form in event_formset %}
|
||||
|
|
|
@ -70,10 +70,3 @@ calendar_patterns = [
|
|||
views.calendar_ics,
|
||||
name="calendar.ics")
|
||||
]
|
||||
|
||||
clubs_patterns = [
|
||||
url(r'^membres/(?P<name>\w+)', views.membres_club, name='membres-club'),
|
||||
url(r'^liste', views.liste_clubs, name='liste-clubs'),
|
||||
url(r'^change_respo/(?P<club_name>\w+)/(?P<user_id>\d+)',
|
||||
views.change_respo, name='change-respo'),
|
||||
]
|
||||
|
|
71
cof/views.py
71
cof/views.py
|
@ -6,8 +6,8 @@ from datetime import timedelta
|
|||
from icalendar import Calendar, Event as Vevent
|
||||
from custommail.shortcuts import send_custom_mail
|
||||
|
||||
from django.shortcuts import redirect, get_object_or_404, render
|
||||
from django.http import Http404, HttpResponse, HttpResponseForbidden
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
|
@ -21,12 +21,12 @@ from .models import Event, EventRegistration, EventOption, \
|
|||
EventOptionChoice
|
||||
from .models import EventCommentField, EventCommentValue, \
|
||||
CalendarSubscription
|
||||
from .models import CofProfile, Club
|
||||
from .models import CofProfile
|
||||
from .decorators import buro_required, cof_required
|
||||
from .forms import (
|
||||
EventStatusFilterForm, SurveyForm, SurveyStatusFilterForm,
|
||||
RegistrationUserForm, RegistrationProfileForm, RegistrationCofProfileForm,
|
||||
EventForm, CalendarForm, EventFormset, RegistrationPassUserForm, ClubsForm
|
||||
EventForm, CalendarForm, EventFormset, RegistrationPassUserForm
|
||||
)
|
||||
|
||||
from bda.models import Tirage, Spectacle
|
||||
|
@ -305,9 +305,8 @@ def registration_form2(request, login_clipper=None, username=None,
|
|||
# COF - profile
|
||||
cofprofile_form = RegistrationCofProfileForm()
|
||||
registration_set_ro_fields(user_form, profile_form)
|
||||
# events & clubs
|
||||
# events
|
||||
event_formset = EventFormset(events=events, prefix='events')
|
||||
clubs_form = ClubsForm()
|
||||
if username:
|
||||
member = get_object_or_404(User, username=username)
|
||||
(profile, _) = Profile.objects.get_or_create(user=member)
|
||||
|
@ -328,8 +327,6 @@ def registration_form2(request, login_clipper=None, username=None,
|
|||
event_formset = EventFormset(
|
||||
events=events, prefix='events',
|
||||
current_registrations=current_registrations)
|
||||
# Clubs
|
||||
clubs_form = ClubsForm(initial={'clubs': member.clubs.all()})
|
||||
elif not login_clipper:
|
||||
# new user
|
||||
user_form = RegistrationPassUserForm()
|
||||
|
@ -337,14 +334,12 @@ def registration_form2(request, login_clipper=None, username=None,
|
|||
profile_form = RegistrationProfileForm()
|
||||
cofprofile_form = RegistrationCofProfileForm()
|
||||
event_formset = EventFormset(events=events, prefix='events')
|
||||
clubs_form = ClubsForm()
|
||||
return render(request, "cof/registration_form.html",
|
||||
{"member": member, "login_clipper": login_clipper,
|
||||
"user_form": user_form,
|
||||
"profile_form": profile_form,
|
||||
"cofprofile_form": cofprofile_form,
|
||||
"event_formset": event_formset,
|
||||
"clubs_form": clubs_form})
|
||||
"event_formset": event_formset})
|
||||
|
||||
|
||||
@buro_required
|
||||
|
@ -368,7 +363,6 @@ def registration(request):
|
|||
user_form = RegistrationUserForm(request_dict)
|
||||
profile_form = RegistrationProfileForm(request_dict)
|
||||
cofprofile_form = RegistrationCofProfileForm(request_dict)
|
||||
clubs_form = ClubsForm(request_dict)
|
||||
events = Event.objects.filter(old=False).all()
|
||||
event_formset = EventFormset(events=events, data=request_dict,
|
||||
prefix='events')
|
||||
|
@ -409,7 +403,6 @@ def registration(request):
|
|||
profile_form.is_valid(),
|
||||
cofprofile_form.is_valid(),
|
||||
event_formset.is_valid(),
|
||||
clubs_form.is_valid()
|
||||
))
|
||||
if forms_are_valid:
|
||||
# Enregistrement du profil
|
||||
|
@ -455,11 +448,6 @@ def registration(request):
|
|||
# l'inscription aux événements et/ou donner la
|
||||
# possibilité d'associer un mail aux événements
|
||||
# send_custom_mail(...)
|
||||
# Enregistrement des inscriptions aux clubs
|
||||
member.clubs.clear()
|
||||
for club in clubs_form.cleaned_data['clubs']:
|
||||
club.membres.add(member)
|
||||
club.save()
|
||||
success = True
|
||||
# Messages
|
||||
if success:
|
||||
|
@ -476,56 +464,11 @@ def registration(request):
|
|||
"cofprofile_form": cofprofile_form,
|
||||
"member": member,
|
||||
"login_clipper": login_clipper,
|
||||
"event_formset": event_formset,
|
||||
"clubs_form": clubs_form})
|
||||
"event_formset": event_formset})
|
||||
else:
|
||||
return render(request, "registration.html")
|
||||
|
||||
|
||||
# -----
|
||||
# Clubs
|
||||
# -----
|
||||
|
||||
|
||||
@login_required
|
||||
def membres_club(request, name):
|
||||
# Vérification des permissions : l'utilisateur doit être membre du burô
|
||||
# ou respo du club.
|
||||
user = request.user
|
||||
club = get_object_or_404(Club, name=name)
|
||||
if not request.user.profile.is_buro \
|
||||
and club not in user.clubs_geres.all():
|
||||
return HttpResponseForbidden('<h1>Permission denied</h1>')
|
||||
members_no_respo = club.membres.exclude(clubs_geres=club).all()
|
||||
return render(request, 'membres_clubs.html',
|
||||
{'club': club,
|
||||
'members_no_respo': members_no_respo})
|
||||
|
||||
|
||||
@buro_required
|
||||
def change_respo(request, club_name, user_id):
|
||||
club = get_object_or_404(Club, name=club_name)
|
||||
user = get_object_or_404(User, id=user_id)
|
||||
if user in club.respos.all():
|
||||
club.respos.remove(user)
|
||||
elif user in club.membres.all():
|
||||
club.respos.add(user)
|
||||
else:
|
||||
raise Http404
|
||||
return redirect('membres-club', name=club_name)
|
||||
|
||||
|
||||
@cof_required
|
||||
def liste_clubs(request):
|
||||
clubs = Club.objects
|
||||
if request.user.profile.is_buro:
|
||||
data = {'owned_clubs': clubs.all()}
|
||||
else:
|
||||
data = {'owned_clubs': request.user.clubs_geres,
|
||||
'other_clubs': clubs.exclude(respos=request.user)}
|
||||
return render(request, 'liste_clubs.html', data)
|
||||
|
||||
|
||||
@buro_required
|
||||
def export_members(request):
|
||||
response = HttpResponse(content_type='text/csv')
|
||||
|
|
|
@ -42,26 +42,26 @@ INSTALLED_APPS = (
|
|||
'bootstrapform',
|
||||
'channels',
|
||||
'widget_tweaks',
|
||||
'bda',
|
||||
'bds',
|
||||
'cof',
|
||||
'gestion',
|
||||
'kfet',
|
||||
'custommail',
|
||||
'bda.apps.BdAConfig',
|
||||
'bds.apps.BDSConfig',
|
||||
'cof.apps.COFConfig',
|
||||
'gestion.apps.GestionConfig',
|
||||
'kfet.apps.KFetConfig',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE = [
|
||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
||||
'kfet.middleware.KFetAuthenticationMiddleware',
|
||||
'kfet.middleware.kfet_auth_middleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
)
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'gestioCOF.urls'
|
||||
|
||||
|
@ -76,9 +76,6 @@ TEMPLATES = [
|
|||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.static',
|
||||
'gestion.context_processors.context_processor',
|
||||
'kfet.context_processors.auth',
|
||||
],
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
Fichier principal de configuration des urls du projet GestioCOF
|
||||
"""
|
||||
|
||||
import autocomplete_light
|
||||
import gestion.urls
|
||||
import kfet.urls
|
||||
import bda.urls
|
||||
|
@ -17,14 +16,11 @@ from django.contrib.auth import views as django_views
|
|||
|
||||
from cof import views as cof_views
|
||||
from cof.urls import export_patterns, petitcours_patterns, \
|
||||
surveys_patterns, events_patterns, calendar_patterns, \
|
||||
clubs_patterns
|
||||
surveys_patterns, events_patterns, calendar_patterns
|
||||
from cof.autocomplete import autocomplete
|
||||
|
||||
from gestion import views as gestion_views
|
||||
|
||||
autocomplete_light.autodiscover()
|
||||
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = [
|
||||
|
@ -48,8 +44,6 @@ urlpatterns = [
|
|||
url(r'^event/', include(events_patterns)),
|
||||
# Calendrier
|
||||
url(r'^calendar/', include(calendar_patterns)),
|
||||
# Clubs
|
||||
url(r'^clubs/', include(clubs_patterns)),
|
||||
# Infos persos
|
||||
url(r'^outsider/password-change$',
|
||||
django_views.password_change,
|
||||
|
|
6
gestion/apps.py
Normal file
6
gestion/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class GestionConfig(AppConfig):
|
||||
name = "gestion"
|
||||
verbose_name = "Gestion des outils communs COF/BDS"
|
|
@ -1,11 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import (absolute_import, division,
|
||||
print_function, unicode_literals)
|
||||
from builtins import *
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class KFetConfig(AppConfig):
|
||||
name = 'kfet'
|
||||
verbose_name = "Application K-Fêt"
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import (absolute_import, division,
|
||||
print_function, unicode_literals)
|
||||
from builtins import *
|
||||
|
||||
from django.http import HttpResponseForbidden
|
||||
from kfet.backends import KFetBackend
|
||||
from kfet.models import Account
|
||||
|
||||
class KFetAuthenticationMiddleware(object):
|
||||
def process_request(self, request):
|
||||
kfet_backend = KFetBackend()
|
||||
|
||||
def kfet_auth_middleware(get_response):
|
||||
kfet_backend = KFetBackend()
|
||||
|
||||
def middleware(request):
|
||||
temp_request_user = kfet_backend.authenticate(request)
|
||||
if temp_request_user:
|
||||
request.real_user = request.user
|
||||
request.user = temp_request_user
|
||||
return get_response(request)
|
||||
|
||||
return middleware
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
configparser==3.5.0
|
||||
Django==1.8.*
|
||||
Django==1.11b1
|
||||
django-autocomplete-light==2.3.3
|
||||
django-autoslug==1.9.3
|
||||
django-cas-ng==3.5.5
|
||||
django-grappelli==2.8.1
|
||||
django-recaptcha==1.0.5
|
||||
mysqlclient==1.3.7
|
||||
Pillow==3.3.0
|
||||
six==1.10.0
|
||||
unicodecsv==0.14.1
|
||||
icalendar==3.10
|
||||
django-cas-ng==3.5.6
|
||||
django-recaptcha==1.2.1
|
||||
mysqlclient==1.3.10
|
||||
Pillow
|
||||
six
|
||||
unicodecsv
|
||||
icalendar
|
||||
django-bootstrap-form==3.2.1
|
||||
asgiref==0.14.0
|
||||
daphne==0.14.3
|
||||
asgi-redis==0.14.0
|
||||
asgiref==1.0.0
|
||||
daphne==1.0.3
|
||||
asgi-redis==1.0.0
|
||||
statistics==1.0.3.5
|
||||
future==0.15.2
|
||||
django-widget-tweaks==1.4.1
|
||||
|
|
Loading…
Reference in a new issue