Revision 3e9b47e9
Added by Benjamin Dauvergne about 13 years ago
| calebasse/agenda/views.py | ||
|---|---|---|
|
from calebasse.actes.validation import (automated_validation, unlock_all_acts_of_the_day)
|
||
|
from calebasse import cbv
|
||
|
|
||
|
from forms import (NewAppointmentForm, NewEventForm, UpdateAppointmentForm, UpdateEventForm)
|
||
|
from forms import (NewAppointmentForm, NewEventForm,
|
||
|
UpdateAppointmentForm, UpdateEventForm)
|
||
|
|
||
|
|
||
|
def redirect_today(request, service):
|
||
|
'''If not date is given we redirect on the agenda for today'''
|
||
|
return redirect('agenda', date=datetime.date.today().strftime('%Y-%m-%d'),
|
||
|
service=service)
|
||
|
|
||
|
class AgendaHomepageView(TemplateView):
|
||
|
|
||
|
class AgendaHomepageView(TemplateView):
|
||
|
template_name = 'agenda/index.html'
|
||
|
|
||
|
def post(self, request, *args, **kwargs):
|
||
| ... | ... | |
|
|
||
|
return context
|
||
|
|
||
|
class AgendaServiceActivityView(TemplateView):
|
||
|
|
||
|
class AgendaServiceActivityView(TemplateView):
|
||
|
template_name = 'agenda/service-activity.html'
|
||
|
|
||
|
def get_context_data(self, **kwargs):
|
||
| ... | ... | |
|
class NewAppointmentView(cbv.ReturnToObjectMixin, cbv.ServiceFormMixin, CreateView):
|
||
|
model = EventWithAct
|
||
|
form_class = NewAppointmentForm
|
||
|
template_name = 'agenda/nouveau-rdv.html'
|
||
|
template_name = 'agenda/new-appointment.html'
|
||
|
success_url = '..'
|
||
|
|
||
|
def get_initial(self):
|
||
| ... | ... | |
|
kwargs['service'] = self.service
|
||
|
return kwargs
|
||
|
|
||
|
|
||
|
class TodayOccurrenceMixin(object):
|
||
|
def get_object(self, queryset=None):
|
||
|
o = super(TodayOccurrenceMixin, self).get_object(queryset)
|
||
|
return o.today_occurrence(self.date)
|
||
|
|
||
|
class UpdateAppointmentView(TodayOccurrenceMixin, UpdateView):
|
||
|
|
||
|
class BaseAppointmentView(UpdateView):
|
||
|
model = EventWithAct
|
||
|
form_class = UpdateAppointmentForm
|
||
|
template_name = 'agenda/update-rdv.html'
|
||
|
success_url = '..'
|
||
|
|
||
|
def get_initial(self):
|
||
|
initial = super(UpdateView, self).get_initial()
|
||
|
initial = super(BaseAppointmentView, self).get_initial()
|
||
|
initial['start_datetime'] = self.date
|
||
|
initial['date'] = self.object.start_datetime.date()
|
||
|
initial['time'] = self.object.start_datetime.time()
|
||
| ... | ... | |
|
return initial
|
||
|
|
||
|
def get_form_kwargs(self):
|
||
|
kwargs = super(UpdateAppointmentView, self).get_form_kwargs()
|
||
|
kwargs = super(BaseAppointmentView, self).get_form_kwargs()
|
||
|
kwargs['service'] = self.service
|
||
|
return kwargs
|
||
|
|
||
|
|
||
|
class UpdateAppointmentView(TodayOccurrenceMixin, BaseAppointmentView):
|
||
|
pass
|
||
|
|
||
|
|
||
|
class UpdatePeriodicAppointmentView(BaseAppointmentView):
|
||
|
form_class = NewAppointmentForm
|
||
|
template_name = 'agenda/new-appointment.html'
|
||
|
|
||
|
|
||
|
class NewEventView(CreateView):
|
||
|
model = Event
|
||
|
form_class = NewEventForm
|
||
| ... | ... | |
|
return kwargs
|
||
|
|
||
|
|
||
|
class UpdateEventView(TodayOccurrenceMixin, UpdateView):
|
||
|
class BaseEventView(UpdateView):
|
||
|
model = Event
|
||
|
form_class = UpdateEventForm
|
||
|
template_name = 'agenda/update-event.html'
|
||
|
success_url = '..'
|
||
|
|
||
|
def get_initial(self):
|
||
|
initial = super(UpdateEventView, self).get_initial()
|
||
|
initial = super(BaseEventView, self).get_initial()
|
||
|
initial['start_datetime'] = self.date
|
||
|
initial['date'] = self.object.start_datetime.date()
|
||
|
initial['time'] = self.object.start_datetime.time()
|
||
| ... | ... | |
|
return initial
|
||
|
|
||
|
def get_form_kwargs(self):
|
||
|
kwargs = super(UpdateEventView, self).get_form_kwargs()
|
||
|
kwargs = super(BaseEventView, self).get_form_kwargs()
|
||
|
kwargs['service'] = self.service
|
||
|
return kwargs
|
||
|
|
||
|
|
||
|
class UpdateEventView(TodayOccurrenceMixin, BaseEventView):
|
||
|
pass
|
||
|
|
||
|
|
||
|
class UpdatePeriodicEventView(BaseEventView):
|
||
|
form_class = NewEventForm
|
||
|
template_name = 'agenda/new-event.html'
|
||
|
|
||
|
|
||
|
class DeleteEventView(TodayOccurrenceMixin, cbv.DeleteView):
|
||
|
model = Event
|
||
|
success_url = '..'
|
||
| ... | ... | |
|
super(DeleteEventView, self).delete(request, *args, **kwargs)
|
||
|
return HttpResponse(status=204)
|
||
|
|
||
|
|
||
|
class AgendaServiceActValidationView(TemplateView):
|
||
|
template_name = 'agenda/act-validation.html'
|
||
|
|
||
Also available in: Unified diff
agenda: add editing of periodic events