mes perms
This commit is contained in:
parent
6cc04e3792
commit
40a9ce6531
3 changed files with 37 additions and 2 deletions
|
@ -32,8 +32,21 @@
|
|||
<a href="{% url "event:calendar" event.slug %}" class="module">
|
||||
Calendrier
|
||||
</a>
|
||||
{% if staffuser %}
|
||||
<a href="{% url "event:event" event.slug %}" class="module">
|
||||
Toutes les activités
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url "event:event-staff" event.slug user.username %}" class="module">
|
||||
Mes perms
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if staffuser %}
|
||||
<h2>Perms de {{ staffuser.first_name }} {{ staffuser.last_name }}</h2>
|
||||
{% else %}
|
||||
<h2>Planning</h2>
|
||||
{% endif %}
|
||||
|
||||
<div class="planning">
|
||||
{% regroup activities by beginning|date:"Y-m-d" as days_list %}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from django.conf.urls import url
|
||||
from event.views import Index, EventView, ActivityView, EnrolActivityView, EventCalendar
|
||||
from event.views import Index, EventView, EventViewStaff, ActivityView, EnrolActivityView, EventCalendar
|
||||
|
||||
app_name = 'event'
|
||||
urlpatterns = [
|
||||
# url(r'^$', Index.as_view(), name='index'),
|
||||
url(r'^(?P<slug>[-\w]+)/$', EventView.as_view(), name='event'),
|
||||
url(r'^(?P<slug>[-\w]+)/calendar$', EventCalendar.as_view(), name='calendar'),
|
||||
url(r'^(?P<slug>[-\w]+)/s/(?P<username>[-\w]+)/$', EventViewStaff.as_view(), name='event-staff'),
|
||||
url(r'^(?P<slug>[-\w]+)/calendar/$', EventCalendar.as_view(), name='calendar'),
|
||||
url(r'^activity/(?P<pk>[0-9]+)/$', ActivityView.as_view(),
|
||||
name='activity'),
|
||||
url(r'^activity/(?P<pk>[0-9]+)/enrol/$',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.views.generic import TemplateView, DetailView, View
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.http import JsonResponse, HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
@ -7,6 +8,8 @@ from django.urls import reverse
|
|||
from .models import Event, Activity
|
||||
from equipment.models import EquipmentAttribution
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class Index(TemplateView):
|
||||
template_name = "event/index.html"
|
||||
|
@ -38,6 +41,24 @@ class EventView(LoginRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
class EventViewStaff(LoginRequiredMixin, DetailView):
|
||||
model = Event
|
||||
template_name = 'event/event.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
user = User.objects.get(username=self.kwargs['username'])
|
||||
event = self.object
|
||||
context['staffuser'] = user
|
||||
context['activities'] = (user.in_perm_activities
|
||||
.filter(event=event)
|
||||
.order_by('beginning')
|
||||
.prefetch_related(
|
||||
'tags', 'places', 'staff', 'parent')
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
class ActivityView(LoginRequiredMixin, DetailView):
|
||||
model = Activity
|
||||
template_name = 'event/activity.html'
|
||||
|
|
Loading…
Add table
Reference in a new issue