actes: fixing empty EventWithAct object while trying to create an act. Doctors
are forced to be Worker instances instead of People(which is its parent) Closes #4945
This commit is contained in:
parent
c14fdef967
commit
d3cfbd19d1
|
@ -8,6 +8,8 @@ from django.shortcuts import redirect
|
|||
|
||||
from calebasse.cbv import ListView, UpdateView, DeleteView
|
||||
from calebasse.agenda.views import NewAppointmentView
|
||||
from calebasse.agenda.models import EventWithAct
|
||||
from calebasse.agenda.forms import UpdateAppointmentForm, NewAppointmentForm
|
||||
|
||||
import copy
|
||||
import models
|
||||
|
@ -77,6 +79,8 @@ class ActListingView(ListView):
|
|||
class NewAct(NewAppointmentView):
|
||||
success_url = '.'
|
||||
success_msg = u'Acte enregistré avec succès.'
|
||||
model = EventWithAct
|
||||
form_class = UpdateAppointmentForm
|
||||
|
||||
def form_valid(self, form):
|
||||
result = super(NewAct, self).form_valid(form)
|
||||
|
|
|
@ -120,6 +120,7 @@ class UpdateAppointmentForm(NewAppointmentForm):
|
|||
appointment.clean()
|
||||
if commit:
|
||||
appointment.save()
|
||||
self.save_m2m()
|
||||
appointment.services = [self.service]
|
||||
return appointment
|
||||
|
||||
|
|
|
@ -515,7 +515,7 @@ class EventWithAct(Event):
|
|||
act.save = old_save
|
||||
old_save(*args, **kwargs)
|
||||
act.comment = self.description
|
||||
act.doctors = self.participants.select_subclasses()
|
||||
act.doctors = (participant.worker for participant in self.participants.all())
|
||||
last_validation_state = ActValidationState.objects.create(
|
||||
act=act, state_name='NON_VALIDE',
|
||||
author=self.creator, previous_state=None)
|
||||
|
|
|
@ -133,7 +133,7 @@ class AgendaServiceActivityView(TemplateView, cbv.ServiceViewMixin):
|
|||
return context
|
||||
|
||||
|
||||
class NewAppointmentView(cbv.ReturnToObjectMixin, cbv.ServiceFormMixin, CreateView):
|
||||
class NewAppointmentView(cbv.ServiceFormMixin, CreateView):
|
||||
model = EventWithAct
|
||||
form_class = NewAppointmentForm
|
||||
template_name = 'agenda/new-appointment.html'
|
||||
|
@ -150,17 +150,13 @@ class NewAppointmentView(cbv.ReturnToObjectMixin, cbv.ServiceFormMixin, CreateVi
|
|||
initial['duration'] = self.request.GET.get('duration')
|
||||
return initial
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(NewAppointmentView, self).get_form_kwargs()
|
||||
kwargs['service'] = self.service
|
||||
return kwargs
|
||||
|
||||
def get_success_url(self):
|
||||
return self.request.META.get('HTTP_REFERER', '..')
|
||||
|
||||
def form_valid(self, form):
|
||||
obj = super(NewAppointmentView, self).form_valid(form)
|
||||
messages.add_message(self.request, messages.INFO, self.success_msg)
|
||||
return super(NewAppointmentView, self).form_valid(form)
|
||||
return obj
|
||||
|
||||
|
||||
class TodayOccurrenceMixin(object):
|
||||
|
|
Reference in New Issue