Project

General

Profile

« Previous | Next » 

Revision 5feec0ab

Added by Jérôme Schneider over 10 years ago

agenda: test if a eventwithact exists before trying to update it

Closes #4051

View differences:

calebasse/agenda/views.py
23 23
from calebasse.actes.validation import (automated_validation, unlock_all_acts_of_the_day)
24 24
from calebasse import cbv
25 25

  
26
from forms import (NewAppointmentForm, NewEventForm, UpdatePeriodicAppointmentForm,
26
from calebasse.agenda.forms import (NewAppointmentForm, NewEventForm, UpdatePeriodicAppointmentForm,
27 27
        DisablePatientAppointmentForm, UpdateAppointmentForm,
28 28
        UpdateEventForm, PeriodicEventsSearchForm)
29 29

  
......
50 50
                act.save()
51 51
                act.set_state(state_name, request.user)
52 52
        except Act.DoesNotExist:
53
            pass
53
            logger.warning('agenda homepage acte_id %d not found' % acte_id)
54 54
        return HttpResponseRedirect('#acte-frame-'+acte_id)
55 55

  
56 56
    def get_context_data(self, **kwargs):
calebasse/api.py
3 3
from tastypie.authorization import Authorization
4 4
from tastypie.resources import ModelResource
5 5
from calebasse.actes.models import Act
6
from calebasse.agenda.models import Event
6
from calebasse.agenda.models import Event, EventWithAct
7 7
from calebasse.dossiers.models import PatientRecord, PatientAddress
8 8

  
9 9

  
......
26 26
            obj = obj.today_occurrence(date)
27 27
        return obj
28 28

  
29
class EventWithActRessource(ModelResource):
30
    class Meta:
31
        queryset = EventWithAct.objects.all()
32
        resource_name = 'eventwithact'
33
        authorization = Authorization()
34

  
29 35
class PatientRecordRessource(ModelResource):
30 36
    class Meta:
31 37
        queryset = PatientRecord.objects.all()
......
46 52

  
47 53
patientaddress_ressource = PatientAddressRessource()
48 54
event_resource = EventResource()
55
eventwithact_resource = EventWithActRessource()
49 56
patientrecord_resource = PatientRecordRessource()
50 57
act_ressource = ActRessource()
51 58

  
calebasse/static/js/calebasse.absences.js
17 17
            url += action;
18 18
    }
19 19
    $("#holiday-dlg").load(url,
20
                           function() {
21
                               $(this).dialog({title: params.title,
22
                                               width: params.width,
23
                                               buttons: [{text: params.button_close,
24
                                                          click: function() {
25
                                                              $(this).dialog('close');
26
                                                              $(selector).attr('style', original_color);
27
                                                          }},{text: params.button_confirm,
28
                                                              click: function(){
29
                                                                  $.ajax({url: url,
30
                                                                          type: 'post',
31
                                                                          data: $('#holiday-dlg form').serialize(),
32
                                                                         }
33
                                                                        ).done(on_success)
34
                                                              }}]});
35
                           })
20
        function() {
21
          $(this).dialog({title: params.title,
22
            width: params.width,
23
          buttons: [{text: params.button_close,
24
            click: function() {
25
              $(this).dialog('close');
26
              $(selector).attr('style', original_color);
27
            }},{text: params.button_confirm,
28
              click: function(){
29
                $.ajax({url: url,
30
                  type: 'post',
31
                data: $('#holiday-dlg form').serialize(),
32
                }
33
                ).done(on_success)
34
              }}]});
35
        })
36 36
};
37 37

  
38 38
function add_holiday(worker, url) {
......
106 106

  
107 107
function delete_group_holiday(holiday) {
108 108
    delete_holiday(null, holiday, group_url);
109
};
109
};
calebasse/static/js/calebasse.agenda.js
115 115
          event_dialog(new_appointment_url, 'Nouveau rendez-vous', '850px', 'Ajouter');
116 116
      });
117 117
      $(base).find('.edit-appointment').click(function() {
118
          event_dialog("/" + service + "/agenda/" + current_date + "/update-rdv/" + $(this).data('event-id') , 'Modifier rendez-vous', '850px', 'Modifier');
119
          return false;
118
        id = $(this).data("event-id");
119
        $.getJSON("/api/v1/eventwithact/" + id + "/?format=json")
120
          .done(function () {
121
            event_dialog("/" + service + "/agenda/" + current_date + "/update-rdv/" + id,
122
              'Modifier rendez-vous', '850px', 'Modifier');
123
          })
124
         .fail(function() {
125
            window.location.reload(true);
126
            $('.messages').html("Le rendez-vous n'existe plus");
127
            return false;
128
         });
129
        return false;
120 130
      });
121 131
      $(base).find('.newevent').click(function() {
122 132
          var participants = new Array();
calebasse/urls.py
5 5
from urls_utils import decorated_includes
6 6

  
7 7
from calebasse.api import (act_ressource, event_resource,
8
        patientrecord_resource, patientaddress_ressource)
8
        eventwithact_resource, patientrecord_resource,
9
        patientaddress_ressource)
9 10
from tastypie.api import Api
10 11

  
11 12
admin.autodiscover()
......
13 14
v1_api = Api(api_name="v1")
14 15
v1_api.register(act_ressource)
15 16
v1_api.register(event_resource)
17
v1_api.register(eventwithact_resource)
16 18
v1_api.register(patientaddress_ressource)
17 19
v1_api.register(patientrecord_resource)
18 20

  

Also available in: Unified diff