Project

General

Profile

« Previous | Next » 

Revision 1f9e881e

Added by Benjamin Dauvergne over 12 years ago

agenda: fix event deletion

View differences:

calebasse/agenda/templates/agenda/ajax-worker-tab.html
28 28
         {% else %}
29 29
           <button title="Éditer un événement" class="edit-event icon-edit" data-event-id="{{ appointment.event_id }}">
30 30
         {% endif %}
31
        <button class="remove-appointment icon-remove-sign" title="Supprimer un rendez-vous" data-event-id="{{ appointment.event_id }}" data-rdv="{{ appointment.title }}"></button>
31
        <button class="remove-appointment icon-remove-sign" title="Supprimer un rendez-vous" data-url="{% url 'delete-event' service=service date=date pk=appointment.event_id %}" data-rdv="{{ appointment.title }}"></button>
32 32
        {% endif %}
33 33
   </span>
34 34
  </h3>
calebasse/agenda/templates/agenda/ressources.html
74 74
                  {% else %}
75 75
                    <button title="Éditer un événement" class="edit-event icon-edit" data-event-id="{{ appointment.event_id }}">
76 76
                  {% endif %}
77
                 <button class="remove-appointment icon-remove-sign" title="Supprimer un rendez-vous" data-event-id="{{ appointment.event_id }}" data-rdv="{{ appointment.title }}"></button>
77
                  <button class="remove-appointment icon-remove-sign" title="Supprimer un rendez-vous" data-url="{% url 'delete-event' date=date service=service pk=appointment.event_id %}" data-rdv="{{ appointment.title }}"></button>
78 78
                 {% endif %}
79 79
            </span>
80 80
           </h3>
calebasse/agenda/urls.py
1 1
from django.conf.urls import url, patterns, include
2 2

  
3 3
from calebasse.cbv import TemplateView
4
from django.views.decorators.csrf import csrf_exempt
4 5

  
5 6
from views import (redirect_today, AgendaHomepageView, NewAppointmentView,
6 7
        NewEventView, AgendaServiceActivityView, UpdateAppointmentView,
7 8
        UpdateEventView, AgendaServiceActValidationView, AutomatedValidationView,
8 9
        UnlockAllView, AgendasTherapeutesView, JoursNonVerrouillesView,
9
        RessourcesView, AjaxWorkerTabView, AjaxWorkerDisponibilityColumnView)
10
        RessourcesView, AjaxWorkerTabView, AjaxWorkerDisponibilityColumnView,
11
        DeleteEventView)
10 12

  
11 13
agenda_patterns = patterns('',
12 14
            url(r'^$',
......
25 27
            url(r'^update-event/(?P<pk>\d+)$',
26 28
                UpdateEventView.as_view(),
27 29
                name='update-event'),
30
            url(r'^delete-event/(?P<pk>\d+)$',
31
                csrf_exempt(DeleteEventView.as_view()),
32
                name='delete-event'),
28 33
            url(r'^activite-du-service/$',
29 34
                AgendaServiceActivityView.as_view(
30 35
                    template_name='agenda/service-activity.html'),
calebasse/agenda/views.py
4 4

  
5 5
from django.db.models import Q
6 6
from django.shortcuts import redirect
7
from django.http import HttpResponseRedirect
7
from django.http import HttpResponseRedirect, HttpResponse
8 8

  
9 9
from calebasse.cbv import TemplateView, CreateView, UpdateView
10 10
from calebasse.agenda.models import Event, EventType, EventWithAct
......
198 198
        kwargs['service'] = self.service
199 199
        return kwargs
200 200

  
201
class DeleteEventView(TodayOccurrenceMixin, cbv.DeleteView):
202
    model = Event
203
    success_url = '..'
204

  
205
    def delete(self, request, *args, **kwargs):
206
        super(DeleteEventView, self).delete(request, *args, **kwargs)
207
        return HttpResponse(status=204)
201 208

  
202 209
class AgendaServiceActValidationView(TemplateView):
203 210
    template_name = 'agenda/act-validation.html'
calebasse/static/js/calebasse.agenda.js
26 26
          if (r == true)
27 27
          {
28 28
            $.ajax({
29
              url: '/api/event/' + $(this).data('event-id') + '/',
29
              url: $(this).data('url'),
30 30
              type: 'DELETE',
31 31
              success: function(data) {
32 32
                  window.location.reload(true);

Also available in: Unified diff