diff --git a/calendrier/__pycache__/urls.cpython-34.pyc b/calendrier/__pycache__/urls.cpython-34.pyc index b18916f..e9573fb 100644 Binary files a/calendrier/__pycache__/urls.cpython-34.pyc and b/calendrier/__pycache__/urls.cpython-34.pyc differ diff --git a/calendrier/__pycache__/views.cpython-34.pyc b/calendrier/__pycache__/views.cpython-34.pyc index fc826e0..5ae82eb 100644 Binary files a/calendrier/__pycache__/views.cpython-34.pyc and b/calendrier/__pycache__/views.cpython-34.pyc differ diff --git a/calendrier/urls.py b/calendrier/urls.py index 68f06f3..7f74d90 100644 --- a/calendrier/urls.py +++ b/calendrier/urls.py @@ -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\d+)$', EventUpdate.as_view()), url(r'(?P\d+)/(?P\d+)/(?P\d+)/?', 'view_event'), url(r'(?P\d+)/(?P\d+)/?$', 'calendar'), url(r'(?P\d+)/?', 'view_eventbis'), diff --git a/calendrier/views.py b/calendrier/views.py index 24bba22..a567515 100644 --- a/calendrier/views.py +++ b/calendrier/views.py @@ -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. diff --git a/db.sqlite3 b/db.sqlite3 index b9f15ee..dcbfef0 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/templates/calendrier/home.html b/templates/calendrier/home.html index 6b7c57d..147464c 100644 --- a/templates/calendrier/home.html +++ b/templates/calendrier/home.html @@ -16,7 +16,7 @@ << {{PreviousMonthName|frenchmonth}} {{PreviousYear}} - Today + Aujourd'hui {{NextMonthName|frenchmonth}} {{NextYear}} >> diff --git a/templates/calendrier/update.html b/templates/calendrier/update.html new file mode 100644 index 0000000..8f4561b --- /dev/null +++ b/templates/calendrier/update.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% block titre %}Modification{% endblock %} + +{% block content %} +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} diff --git a/templates/calendrier/view_event.html b/templates/calendrier/view_event.html index d1a736b..114e98e 100644 --- a/templates/calendrier/view_event.html +++ b/templates/calendrier/view_event.html @@ -3,6 +3,9 @@ {% block titre %}{{ nom }}{% endblock %} {% block content %} +{% if user.profile.is_chef %} +

Modifier l'événement

+{% endif %}

{{ nom }}

{{ev.date}}

{{ev.debut }}