Vision des events différenciée

This commit is contained in:
R1kM 2015-04-17 18:38:44 +02:00
parent 20dc665fec
commit ed2fafe61a
8 changed files with 28 additions and 1 deletions

View file

@ -1,8 +1,10 @@
from django.conf.urls import patterns, url
from calendrier.views import EventUpdate
urlpatterns = patterns('calendrier.views',
url(r'^new$', 'create_event'),
url(r'^$', 'home'),
url(r'^edition/(?P<pk>\d+)$', EventUpdate.as_view()),
url(r'(?P<pYear>\d+)/(?P<pMonth>\d+)/(?P<id>\d+)/?', 'view_event'),
url(r'(?P<pYear>\d+)/(?P<pMonth>\d+)/?$', 'calendar'),
url(r'(?P<id>\d+)/?', 'view_eventbis'),

View file

@ -2,6 +2,8 @@ from django.shortcuts import render
from calendrier.forms import EventForm
from calendrier.models import Event
from django.utils.safestring import mark_safe
from django.views.generic import UpdateView
from django.core.urlresolvers import reverse_lazy
from partitions.decorators import chef_required
from calendrier.calend import EventCalendar
@ -21,6 +23,8 @@ def calendar(request, pYear, pMonth):
lCalendarFromMonth = datetime(lYear, lMonth, 1)
lCalendarToMonth = datetime(lYear, lMonth, monthrange(lYear, lMonth)[1])
lEvents = Event.objects.filter(date__gte=lCalendarFromMonth, date__lte=lCalendarToMonth, calendrier=True)
if request.user.is_authenticated():
lEvents = Event.objects.filter(date__gte=lCalendarFromMonth, date__lte=lCalendarToMonth)
lCalendar = EventCalendar(lEvents).formatmonth(lYear, lMonth)
lPreviousYear = lYear
lPreviousMonth = lMonth - 1
@ -83,4 +87,12 @@ def create_event(request):
form = EventForm()
return render(request, "calendrier/create.html", locals())
class EventUpdate(UpdateView):
model = Event
template_name = "calendrier/update.html"
form_class = EventForm
success_url = reverse_lazy(home)
# Create your views here.

Binary file not shown.

View file

@ -16,7 +16,7 @@
<td width="20%" align="left">
&lt;&lt; <a href="/calendar/{{PreviousYear}}/{{PreviousMonth}}/">{{PreviousMonthName|frenchmonth}} {{PreviousYear}}</a>
</td>
<td width="20%" align="center"><a href="/calendar">Today</a></td>
<td width="20%" align="center"><a href="/calendar">Aujourd'hui</a></td>
<td width="20%" align="right">
<a href="/calendar/{{NextYear}}/{{NextMonth}}/">{{NextMonthName|frenchmonth}} {{NextYear}}</a> &gt;&gt;
</td>

View file

@ -0,0 +1,10 @@
{% extends "base.html" %}
{% block titre %}Modification{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Enregistrer" />
</form>
{% endblock %}

View file

@ -3,6 +3,9 @@
{% block titre %}{{ nom }}{% endblock %}
{% block content %}
{% if user.profile.is_chef %}
<p><a href="/calendar/edition/{{ev.id}}">Modifier l'événement</a></p>
{% endif %}
<p>{{ nom }}</p>
<p>{{ev.date}}</p>
<p>{{ev.debut }}