Revision 3e9b47e9
Added by Benjamin Dauvergne about 13 years ago
| .gitignore | ||
|---|---|---|
|
calebasse.sqlite3
|
||
|
scripts/*/*/*.csv
|
||
|
scripts/*/*.json
|
||
|
scripts/*.csv
|
||
|
scripts/*.json
|
||
|
calebasse/calebasse.log
|
||
| calebasse/agenda/forms.py | ||
|---|---|---|
|
from ajax_select import make_ajax_field
|
||
|
from models import Event, EventWithAct, EventType
|
||
|
|
||
|
class NewAppointmentForm(forms.ModelForm):
|
||
|
class BaseForm(forms.ModelForm):
|
||
|
date = forms.DateField(label=u'Date', localize=True)
|
||
|
time = forms.TimeField(label=u'Heure de début')
|
||
|
duration = forms.CharField(label=u'Durée',
|
||
|
help_text=u'en minutes; vous pouvez utiliser la roulette de votre souris.')
|
||
|
|
||
|
participants = make_ajax_field(EventWithAct, 'participants', 'worker-or-group', True)
|
||
|
|
||
|
|
||
|
class NewAppointmentForm(BaseForm):
|
||
|
patient = make_ajax_field(EventWithAct, 'patient', 'patientrecord', False)
|
||
|
|
||
|
class Meta:
|
||
| ... | ... | |
|
)
|
||
|
|
||
|
|
||
|
class NewEventForm(forms.ModelForm):
|
||
|
|
||
|
class NewEventForm(BaseForm):
|
||
|
title = forms.CharField(label=u"Complément de l'intitulé", max_length=32, required=False)
|
||
|
date = forms.DateField(label=u'Date', localize=True)
|
||
|
time = forms.TimeField(label=u'Heure de début')
|
||
|
duration = forms.CharField(label=u'Durée',
|
||
|
help_text=u'en minutes; vous pouvez utiliser la roulette de votre souris.')
|
||
|
|
||
|
participants = make_ajax_field(Event, 'participants', 'worker-or-group', True)
|
||
|
|
||
|
class Meta:
|
||
|
model = Event
|
||
| calebasse/agenda/models.py | ||
|---|---|---|
|
def is_event_absence(self):
|
||
|
return False
|
||
|
|
||
|
RECURRENCE_DESCRIPTION = [
|
||
|
u'Tous les %s', #(1, None, None),
|
||
|
u'Un %s sur deux', #(2, None, None),
|
||
|
u'Un %s sur trois', #(3, None, None),
|
||
|
u'Un %s sur quatre', #(4, None, None),
|
||
|
u'Un %s sur cinq', #(5, None, None),
|
||
|
u'Le premier %s du mois', #(None, 0, None),
|
||
|
u'Le deuxième %s du mois', #(None, 1, None),
|
||
|
u'Le troisième %s du mois', #(None, 2, None),
|
||
|
u'Le quatrième %s du mois', #(None, 3, None),
|
||
|
u'Le dernier %s du mois', #(None, 4, None),
|
||
|
u'Les %s les semaines paires', #(None, None, 0),
|
||
|
u'Les %s les semaines impaires', #(None, None, 1)
|
||
|
]
|
||
|
|
||
|
WEEKDAY_DESRIPTION = [
|
||
|
u'lundi',
|
||
|
u'mardi',
|
||
|
u'mercredi',
|
||
|
u'jeudi',
|
||
|
u'vendredi',
|
||
|
u'samedi',
|
||
|
u'dimanche'
|
||
|
]
|
||
|
|
||
|
def recurrence_description(self):
|
||
|
'''Self description of this recurring event'''
|
||
|
if not self.recurrence_periodicity:
|
||
|
return None
|
||
|
parts = []
|
||
|
parts.append(self.RECURRENCE_DESCRIPTION[self.recurrence_periodicity] \
|
||
|
% self.WEEKDAY_DESRIPTION[self.recurrence_week_day])
|
||
|
if self.recurrence_end_date:
|
||
|
parts.append(u'du')
|
||
|
else:
|
||
|
parts.append(u'à partir du')
|
||
|
parts.append(self.start_datetime.strftime('%d/%m/%Y'))
|
||
|
if self.recurrence_end_date:
|
||
|
parts.append(u'au')
|
||
|
parts.append(self.recurrence_end_date.strftime('%d/%m/%Y'))
|
||
|
return u' '.join(parts)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.title
|
||
|
|
||
| calebasse/agenda/templates/agenda/appointment.html | ||
|---|---|---|
|
{{ form.non_field_errors }}
|
||
|
{{ form.start_datetime }}
|
||
|
{{ form.start_datetime.errors }}
|
||
|
<table id="new-appointment-table">
|
||
|
<tr>
|
||
|
<td {% if form.date.field.required %}class="required"{% endif %}>
|
||
|
<p class="datepicker">
|
||
|
{{ form.date.label_tag }}
|
||
|
{{ form.date|add_class:"datepicker-date" }}
|
||
|
{{ form.date.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
<td {% if form.time.field.required %}class="required"{% endif %}>
|
||
|
<p>
|
||
|
{{ form.time.label_tag }}
|
||
|
{{ form.time }}
|
||
|
{{ form.time.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
<td {% if form.duration.field.required %}class="required"{% endif %}>
|
||
|
<p>
|
||
|
{{ form.duration.label_tag }}
|
||
|
{{ form.duration|add_class:"mousewheel"|attr:"data-mousewheel-increment:5" }}
|
||
|
{{ form.duration.errors }}
|
||
|
<div>
|
||
|
{{ form.duration.help_text }}
|
||
|
</div>
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<p>
|
||
|
{{ form.room.label_tag }}
|
||
|
{{ form.room }}
|
||
|
{{ form.room.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td {% if form.participants.field.required %}class="required"{% endif %}>
|
||
|
<h4>{{ form.participants.label_tag }}</h4>
|
||
|
<div id="intervenants">
|
||
|
{{ form.participants }}
|
||
|
{{ form.participants.errors }}
|
||
|
</div>
|
||
|
</td>
|
||
|
<td {% if form.patient.field.required %}class="required"{% endif %}>
|
||
|
<h4>{{ form.patient.label_tag }}</h4>
|
||
|
{{ form.patient }}
|
||
|
{{ form.patient.errors }}
|
||
|
</td>
|
||
|
<td {% if form.act_type.field.required %}class="required"{% endif %}>
|
||
|
<h4>{{ form.act_type.label_tag }}</h4>
|
||
|
{{ form.act_type }}
|
||
|
{{ form.act_type.errors }}
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<table id="new-appointment-table">
|
||
|
<tr>
|
||
|
<td {% if form.date.field.required %}class="required"{% endif %}>
|
||
|
<p class="datepicker">
|
||
|
{{ form.date.label_tag }}
|
||
|
{{ form.date|add_class:"datepicker-date" }}
|
||
|
{{ form.date.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
<td {% if form.time.field.required %}class="required"{% endif %}>
|
||
|
<p>
|
||
|
{{ form.time.label_tag }}
|
||
|
{{ form.time }}
|
||
|
{{ form.time.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
<td {% if form.duration.field.required %}class="required"{% endif %}>
|
||
|
<p>
|
||
|
{{ form.duration.label_tag }}
|
||
|
{{ form.duration|add_class:"mousewheel"|attr:"data-mousewheel-increment:5" }}
|
||
|
{{ form.duration.errors }}
|
||
|
<div>
|
||
|
{{ form.duration.help_text }}
|
||
|
</div>
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<p>
|
||
|
{{ form.room.label_tag }}
|
||
|
{{ form.room }}
|
||
|
{{ form.room.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td {% if form.participants.field.required %}class="required"{% endif %}>
|
||
|
<h4>{{ form.participants.label_tag }}</h4>
|
||
|
<div id="intervenants">
|
||
|
{{ form.participants }}
|
||
|
{{ form.participants.errors }}
|
||
|
</div>
|
||
|
</td>
|
||
|
<td {% if form.patient.field.required %}class="required"{% endif %}>
|
||
|
<h4>{{ form.patient.label_tag }}</h4>
|
||
|
{{ form.patient }}
|
||
|
{{ form.patient.errors }}
|
||
|
</td>
|
||
|
<td {% if form.act_type.field.required %}class="required"{% endif %}>
|
||
|
<h4>{{ form.act_type.label_tag }}</h4>
|
||
|
{{ form.act_type }}
|
||
|
{{ form.act_type.errors }}
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<!-- <hr/>-->
|
||
|
<!-- <table id="new-appointment-table">-->
|
||
|
<!-- <tr>-->
|
||
|
<!-- <td {% if form.recurrence_periodicity.field.required %}class="required"{% endif %}>-->
|
||
|
<!-- <p>-->
|
||
|
<!-- {{ form.recurrence_periodicity.label_tag }}-->
|
||
|
<!-- {{ form.recurrence_periodicity }}-->
|
||
|
<!-- {{ form.recurrence_periodicity.errors }}-->
|
||
|
<!-- </p>-->
|
||
|
<!-- </td>-->
|
||
|
<!-- <td {% if form.recurrence_end_date.field.required %}class="required"{% endif %}>-->
|
||
|
<!-- <p class="datepicker">-->
|
||
|
<!-- {{ form.recurrence_end_date.label_tag }}-->
|
||
|
<!-- {{ form.recurrence_end_date|add_class:"datepicker-date" }}-->
|
||
|
<!-- {{ form.recurrence_end_date.errors }}-->
|
||
|
<!-- </p>-->
|
||
|
<!-- </td>-->
|
||
|
<!-- </tr>-->
|
||
|
<!-- </table>-->
|
||
|
<!-- <button>Configurer la périodicité</button> -->
|
||
|
{% if object.exception_to %}
|
||
|
<hr/>
|
||
|
<div>Occurence du {{object.exception_date}} de la série d'evènements {{ object.exception_to.recurrence_description|lower }}</div>
|
||
|
<button type="button" data-id="{{ object.exception_to.id }}" class="update-periodic-rdv">Éditer le rendez-vous périodique</button>
|
||
|
{% endif %}
|
||
| calebasse/agenda/templates/agenda/event.html | ||
|---|---|---|
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<hr/>
|
||
|
|
||
|
<table id="new-appointment-table">
|
||
|
<tr>
|
||
|
<td {% if form.recurrence_periodicity.field.required %}class="required"{% endif %}>
|
||
|
<p>
|
||
|
{{ form.recurrence_periodicity.label_tag }}
|
||
|
{{ form.recurrence_periodicity }}
|
||
|
{{ form.recurrence_periodicity.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
<td {% if form.recurrence_end_date.field.required %}class="required"{% endif %}>
|
||
|
<p class="datepicker">
|
||
|
{{ form.recurrence_end_date.label_tag }}
|
||
|
{{ form.recurrence_end_date|add_class:"datepicker-date" }}
|
||
|
{{ form.recurrence_end_date.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
{% if object.exception_to %}
|
||
|
<hr/>
|
||
|
<div>Occurence du {{object.exception_date}} de la série de rendez-vous {{ object.exception_to.recurrence_description|lower }}</div>
|
||
|
<button type="button" data-id="{{ object.exception_to.id }}" class="update-periodic-event">Éditer l'évènement périodique</button>
|
||
|
{% endif %}
|
||
| calebasse/agenda/templates/agenda/new-appointment.html | ||
|---|---|---|
|
<form action="{{ request.get_full_path}}" method="post">
|
||
|
{% csrf_token %}
|
||
|
{% include "agenda/appointment.html" %}
|
||
|
{% include "agenda/periodicity.html" %}
|
||
|
</form>
|
||
| calebasse/agenda/templates/agenda/new-event.html | ||
|---|---|---|
|
<form action="{{ request.get_full_path}}" method="post">
|
||
|
{% csrf_token %}
|
||
|
{% include "agenda/event.html" %}
|
||
|
{% include "agenda/periodicity.html" %}
|
||
|
</form>
|
||
| calebasse/agenda/templates/agenda/nouveau-rdv.html | ||
|---|---|---|
|
<form action="{{ request.get_full_path}}" method="post">
|
||
|
{% csrf_token %}
|
||
|
{% include "agenda/appointment.html" %}
|
||
|
</form>
|
||
| calebasse/agenda/templates/agenda/periodicity.html | ||
|---|---|---|
|
<hr/>
|
||
|
<table id="new-appointment-table">
|
||
|
<tr>
|
||
|
<td {% if form.recurrence_periodicity.field.required %}class="required"{% endif %}>
|
||
|
<p>
|
||
|
{{ form.recurrence_periodicity.label_tag }}
|
||
|
{{ form.recurrence_periodicity }}
|
||
|
{{ form.recurrence_periodicity.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
<td {% if form.recurrence_end_date.field.required %}class="required"{% endif %}>
|
||
|
<p class="datepicker">
|
||
|
{{ form.recurrence_end_date.label_tag }}
|
||
|
{{ form.recurrence_end_date }}
|
||
|
{{ form.recurrence_end_date.errors }}
|
||
|
</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
| calebasse/agenda/urls.py | ||
|---|---|---|
|
UpdateEventView, AgendaServiceActValidationView, AutomatedValidationView,
|
||
|
UnlockAllView, AgendasTherapeutesView, JoursNonVerrouillesView,
|
||
|
RessourcesView, AjaxWorkerTabView, AjaxWorkerDisponibilityColumnView,
|
||
|
DeleteEventView)
|
||
|
DeleteEventView, UpdatePeriodicEventView, UpdatePeriodicAppointmentView)
|
||
|
|
||
|
agenda_patterns = patterns('',
|
||
|
url(r'^$',
|
||
| ... | ... | |
|
url(r'^update-rdv/(?P<pk>\d+)$',
|
||
|
UpdateAppointmentView.as_view(),
|
||
|
name='update-rdv'),
|
||
|
url(r'^update-periodic-rdv/(?P<pk>\d+)$',
|
||
|
UpdatePeriodicAppointmentView.as_view(),
|
||
|
name='update-periodic-rdv'),
|
||
|
url(r'^new-event/$',
|
||
|
NewEventView.as_view(),
|
||
|
name='new-event'),
|
||
|
url(r'^update-event/(?P<pk>\d+)$',
|
||
|
UpdateEventView.as_view(),
|
||
|
name='update-event'),
|
||
|
url(r'^update-periodic-event/(?P<pk>\d+)$',
|
||
|
UpdatePeriodicEventView.as_view(),
|
||
|
name='update-periodic-event'),
|
||
|
url(r'^delete-event/(?P<pk>\d+)$',
|
||
|
validator_only(csrf_exempt(DeleteEventView.as_view())),
|
||
|
name='delete-event'),
|
||
| 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'
|
||
|
|
||
| calebasse/static/js/calebasse.agenda.js | ||
|---|---|---|
|
});
|
||
|
return false;
|
||
|
});
|
||
|
$(base).on('click', '.update-periodic-rdv', function () {
|
||
|
$('.ui-dialog-content').dialog('destroy');
|
||
|
$('.ui-dialog-content').empty();
|
||
|
generic_ajaxform_dialog('update-periodic-rdv/' + $(this).data('id'),
|
||
|
'Modifier un rendez-vous périodique', '#ajax-dlg', '800px', 'Modifier');
|
||
|
});
|
||
|
$(base).on('click', '.update-periodic-event', function () {
|
||
|
$('.ui-dialog-content').dialog('destroy');
|
||
|
$('.ui-dialog-content').empty();
|
||
|
generic_ajaxform_dialog('update-periodic-event/' + $(this).data('id'),
|
||
|
'Modifier un évènement périodique', '#ajax-dlg', '800px', 'Modifier');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function reorder_disponibility_columns() {
|
||
Also available in: Unified diff
agenda: add editing of periodic events