forked from DGNum/gestioCOF
Ajout d'une vue : membres d'un club
- Liste des membres inscrits à un club. - Vue accessible aux membres du burô et aux respos des clubs concernés.
This commit is contained in:
parent
c07cf654fb
commit
f25243b082
4 changed files with 42 additions and 3 deletions
|
@ -16,7 +16,8 @@ from django.contrib.auth import views as django_views
|
||||||
from django_cas_ng import views as django_cas_views
|
from django_cas_ng import views as django_cas_views
|
||||||
from gestioncof import views as gestioncof_views, csv_views
|
from gestioncof import views as gestioncof_views, csv_views
|
||||||
from gestioncof.urls import export_patterns, petitcours_patterns, \
|
from gestioncof.urls import export_patterns, petitcours_patterns, \
|
||||||
surveys_patterns, events_patterns, calendar_patterns
|
surveys_patterns, events_patterns, calendar_patterns, \
|
||||||
|
clubs_patterns
|
||||||
|
|
||||||
from gestioncof.autocomplete import autocomplete
|
from gestioncof.autocomplete import autocomplete
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@ urlpatterns = [
|
||||||
url(r'^event/', include(events_patterns)),
|
url(r'^event/', include(events_patterns)),
|
||||||
# Calendrier
|
# Calendrier
|
||||||
url(r'^calendar/', include(calendar_patterns)),
|
url(r'^calendar/', include(calendar_patterns)),
|
||||||
|
# Clubs
|
||||||
|
url(r'^clubs/', include(clubs_patterns)),
|
||||||
# Authentification
|
# Authentification
|
||||||
url(r'^cof/denied$', TemplateView.as_view(template_name='cof-denied.html'),
|
url(r'^cof/denied$', TemplateView.as_view(template_name='cof-denied.html'),
|
||||||
name="cof-denied"),
|
name="cof-denied"),
|
||||||
|
|
20
gestioncof/templates/membres_clubs.html
Normal file
20
gestioncof/templates/membres_clubs.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "base_title.html" %}
|
||||||
|
|
||||||
|
{% block realcontent %}
|
||||||
|
<h2>{{ club }}</h2>
|
||||||
|
|
||||||
|
{% if club.membres.exists %}
|
||||||
|
<h3>Liste des membres</h3>
|
||||||
|
<table class="table table-striped">
|
||||||
|
{% for member in club.membres.all %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ member }}</td>
|
||||||
|
<td>{{ member.email }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
Ce club ne contient actuellement aucun membre.
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -52,3 +52,7 @@ calendar_patterns = [
|
||||||
url(r'^(?P<token>[a-z0-9-]+)/calendar.ics$',
|
url(r'^(?P<token>[a-z0-9-]+)/calendar.ics$',
|
||||||
'gestioncof.views.calendar_ics')
|
'gestioncof.views.calendar_ics')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
clubs_patterns = [
|
||||||
|
url(r'^membres/(?P<name>\w+)', views.membres_club)
|
||||||
|
]
|
||||||
|
|
|
@ -10,7 +10,7 @@ from datetime import timedelta
|
||||||
from icalendar import Calendar, Event as Vevent
|
from icalendar import Calendar, Event as Vevent
|
||||||
|
|
||||||
from django.shortcuts import redirect, get_object_or_404, render
|
from django.shortcuts import redirect, get_object_or_404, render
|
||||||
from django.http import Http404, HttpResponse
|
from django.http import Http404, HttpResponse, HttpResponseForbidden
|
||||||
from django.contrib.auth.decorators import login_required
|
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
|
||||||
|
@ -24,7 +24,7 @@ from gestioncof.models import Event, EventRegistration, EventOption, \
|
||||||
from gestioncof.models import EventCommentField, EventCommentValue, \
|
from gestioncof.models import EventCommentField, EventCommentValue, \
|
||||||
CalendarSubscription
|
CalendarSubscription
|
||||||
from gestioncof.shared import send_custom_mail
|
from gestioncof.shared import send_custom_mail
|
||||||
from gestioncof.models import CofProfile, Clipper
|
from gestioncof.models import CofProfile, Clipper, 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 UserProfileForm, EventStatusFilterForm, \
|
||||||
SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
|
SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
|
||||||
|
@ -483,6 +483,18 @@ def registration(request):
|
||||||
return render(request, "registration.html")
|
return render(request, "registration.html")
|
||||||
|
|
||||||
|
|
||||||
|
@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>')
|
||||||
|
return render(request, 'membres_clubs.html', {'club': club})
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def export_members(request):
|
def export_members(request):
|
||||||
response = HttpResponse(content_type='text/csv')
|
response = HttpResponse(content_type='text/csv')
|
||||||
|
|
Loading…
Reference in a new issue