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

Closes #4051
This commit is contained in:
Jérôme Schneider 2013-12-17 19:41:46 +01:00
parent 99ea283672
commit 5feec0abfd
5 changed files with 42 additions and 23 deletions

View File

@ -23,7 +23,7 @@ from calebasse.actes.models import Act, ValidationMessage
from calebasse.actes.validation import (automated_validation, unlock_all_acts_of_the_day)
from calebasse import cbv
from forms import (NewAppointmentForm, NewEventForm, UpdatePeriodicAppointmentForm,
from calebasse.agenda.forms import (NewAppointmentForm, NewEventForm, UpdatePeriodicAppointmentForm,
DisablePatientAppointmentForm, UpdateAppointmentForm,
UpdateEventForm, PeriodicEventsSearchForm)
@ -50,7 +50,7 @@ class AgendaHomepageView(TemplateView):
act.save()
act.set_state(state_name, request.user)
except Act.DoesNotExist:
pass
logger.warning('agenda homepage acte_id %d not found' % acte_id)
return HttpResponseRedirect('#acte-frame-'+acte_id)
def get_context_data(self, **kwargs):

View File

@ -3,7 +3,7 @@ import datetime
from tastypie.authorization import Authorization
from tastypie.resources import ModelResource
from calebasse.actes.models import Act
from calebasse.agenda.models import Event
from calebasse.agenda.models import Event, EventWithAct
from calebasse.dossiers.models import PatientRecord, PatientAddress
@ -26,6 +26,12 @@ class EventResource(ModelResource):
obj = obj.today_occurrence(date)
return obj
class EventWithActRessource(ModelResource):
class Meta:
queryset = EventWithAct.objects.all()
resource_name = 'eventwithact'
authorization = Authorization()
class PatientRecordRessource(ModelResource):
class Meta:
queryset = PatientRecord.objects.all()
@ -46,6 +52,7 @@ class ActRessource(ModelResource):
patientaddress_ressource = PatientAddressRessource()
event_resource = EventResource()
eventwithact_resource = EventWithActRessource()
patientrecord_resource = PatientRecordRessource()
act_ressource = ActRessource()

View File

@ -17,22 +17,22 @@ function action(url, worker, on, action, selector, original_color, highlight_col
url += action;
}
$("#holiday-dlg").load(url,
function() {
$(this).dialog({title: params.title,
width: params.width,
buttons: [{text: params.button_close,
click: function() {
$(this).dialog('close');
$(selector).attr('style', original_color);
}},{text: params.button_confirm,
click: function(){
$.ajax({url: url,
type: 'post',
data: $('#holiday-dlg form').serialize(),
}
).done(on_success)
}}]});
})
function() {
$(this).dialog({title: params.title,
width: params.width,
buttons: [{text: params.button_close,
click: function() {
$(this).dialog('close');
$(selector).attr('style', original_color);
}},{text: params.button_confirm,
click: function(){
$.ajax({url: url,
type: 'post',
data: $('#holiday-dlg form').serialize(),
}
).done(on_success)
}}]});
})
};
function add_holiday(worker, url) {
@ -106,4 +106,4 @@ function edit_group_holiday(holiday) {
function delete_group_holiday(holiday) {
delete_holiday(null, holiday, group_url);
};
};

View File

@ -115,8 +115,18 @@ function enable_events(base) {
event_dialog(new_appointment_url, 'Nouveau rendez-vous', '850px', 'Ajouter');
});
$(base).find('.edit-appointment').click(function() {
event_dialog("/" + service + "/agenda/" + current_date + "/update-rdv/" + $(this).data('event-id') , 'Modifier rendez-vous', '850px', 'Modifier');
return false;
id = $(this).data("event-id");
$.getJSON("/api/v1/eventwithact/" + id + "/?format=json")
.done(function () {
event_dialog("/" + service + "/agenda/" + current_date + "/update-rdv/" + id,
'Modifier rendez-vous', '850px', 'Modifier');
})
.fail(function() {
window.location.reload(true);
$('.messages').html("Le rendez-vous n'existe plus");
return false;
});
return false;
});
$(base).find('.newevent').click(function() {
var participants = new Array();

View File

@ -5,7 +5,8 @@ from django.contrib.auth.decorators import login_required
from urls_utils import decorated_includes
from calebasse.api import (act_ressource, event_resource,
patientrecord_resource, patientaddress_ressource)
eventwithact_resource, patientrecord_resource,
patientaddress_ressource)
from tastypie.api import Api
admin.autodiscover()
@ -13,6 +14,7 @@ admin.autodiscover()
v1_api = Api(api_name="v1")
v1_api.register(act_ressource)
v1_api.register(event_resource)
v1_api.register(eventwithact_resource)
v1_api.register(patientaddress_ressource)
v1_api.register(patientrecord_resource)