Project

General

Profile

« Previous | Next » 

Revision 5c66ef04

Added by Jérôme Schneider almost 12 years ago

agenda: add occurrences deletion

View differences:

calebasse/agenda/appointments.py
23 23
        self.service_name = None
24 24
        self.patient_record_id = None
25 25
        self.event_id = None
26
        self.occurrence_id = None
26 27
        self.service = None
27 28
        self.workers_initial = None
28 29
        self.weight = 0
......
39 40
    def init_from_occurrence(self, occurrence, service):
40 41
        """ """
41 42
        delta = occurrence.end_time - occurrence.start_time
43
        self.occurrence_id = occurrence.id
42 44
        self.length = delta.seconds / 60
43 45
        self.title = occurrence.title
44 46
        services = occurrence.event.services.all()
calebasse/agenda/templates/agenda/index.html
35 35
      }
36 36
      function delete_appointment(id, title)  {
37 37
          var r=confirm("Etes-vous sûr de vouloir supprimer le rendez-vous "+ title + " ?");
38
      } 
38
          if (r == true)
39
          {
40
              $.ajax({
41
                  url: '/api/occurrence/' + id + '/',
42
                  type: 'DELETE',
43
                  success: function(data) {
44
                      window.location.reload(true);
45
                  }
46
              });
47
          }
48
      }
39 49
  $(function() {
40 50
    $('#tabs').tabs();
41 51

  
......
236 246
         <a class="print" href="#">Imprimer</a>
237 247
         <div>
238 248
           {% for appointment in worker_agenda.appointments %}
239
           <h3 class="{{ appointment.type }} appointment"><span class="hour">{{ appointment.begin_hour }}</span>
249
           <h3 class="{{ appointment.type }} appointment">
250
             <span class="hour">{{ appointment.begin_hour }}</span>
240 251
             {% if appointment.title %} — {{ appointment.title }}  {% endif %}
241 252
             {% if appointment.length %} — {{ appointment.length }}m {% endif %}
242 253
             {% if appointment.workers_initial %} —{{ appointment.workers_initial }} {% endif %}
......
254 265
                 {% endif %}
255 266
                 {% if appointment.event_id %}
256 267
                 <button type="button"><img title="Editer un rendez-vous" src="{{ STATIC_URL }}images/accessories-text-editor.png"></button>
257
                 <button type="button" onclick="javascript:delete_appointment({{ appointment.event_id }}, '{{ appointment.title }}')"><img title="Supprimer un rendez-vous" src="{{ STATIC_URL }}images/list-remove.png"></button>
268
                 <button type="button"  onclick="javascript:delete_appointment({{ appointment.occurrence_id }}, '{{ appointment.title }}')"><img title="Supprimer un rendez-vous" src="{{ STATIC_URL }}images/list-remove.png"></button>
258 269
                 {% endif %}
259 270
            </span>
260 271
           </h3>
calebasse/api.py
1 1

  
2 2
from tastypie.authorization import DjangoAuthorization
3 3
from tastypie.resources import ModelResource
4
from calebasse.agenda.models import Event
4
from calebasse.agenda.models import Event, Occurrence
5 5

  
6 6

  
7 7
class EventResource(ModelResource):
......
9 9
            queryset = Event.objects.all()
10 10
            resource_name = 'event'
11 11
            authorization = DjangoAuthorization()
12

  
13
class OccurrenceResource(ModelResource):
14
        class Meta:
15
            queryset = Occurrence.objects.all()
16
            resource_name = 'occurrence'
17
            authorization = DjangoAuthorization()
calebasse/urls.py
5 5

  
6 6
from urls_utils import decorated_includes
7 7

  
8
from calebasse.api import EventResource
8
from calebasse.api import EventResource, OccurrenceResource
9 9

  
10 10
admin.autodiscover()
11 11

  
12 12
event_resource = EventResource()
13
occurrence_resource = OccurrenceResource()
13 14

  
14 15
service_patterns = patterns('',
15 16
    url(r'^$', 'calebasse.views.homepage', name='homepage'),
......
31 32
    (r'^$', redirect_to, { 'url': '/cmpp/' }),
32 33
    url(r'^admin/', include(admin.site.urls)),
33 34
    url(r'^accounts/', include('django.contrib.auth.urls')),
34
    url(r'^api/', decorated_includes(login_required, include(event_resource.urls))),
35
    url(r'^api/',
36
        decorated_includes(login_required, include(event_resource.urls))),
37
    url(r'^api/',
38
        decorated_includes(login_required, include(occurrence_resource.urls)),
39
        ),
35 40
    url(r'^(?P<service>[a-z-]+)/', decorated_includes(login_required,
36 41
        include(service_patterns))),
37 42
    url(r'^lookups/', include('ajax_select.urls')),

Also available in: Unified diff