Revision b0e22743
Added by Jérôme Schneider over 12 years ago
calebasse/agenda/templates/agenda/index.html | ||
---|---|---|
92 | 92 |
<img title="Un commentaire existe" src="{{ STATIC_URL }}images/emblem-documents.png"> |
93 | 93 |
{% endif %} |
94 | 94 |
{% if appointment.event_id %} |
95 |
<img title="Editer un rendez-vous" src="{{ STATIC_URL }}images/accessories-text-editor.png">
|
|
95 |
<img title="Editer un rendez-vous" class="edit-appointment" src="{{ STATIC_URL }}images/accessories-text-editor.png" data-occurrence-id="{{ appointment.occurrence_id }}">
|
|
96 | 96 |
<img class="remove-appointment" title="Supprimer un rendez-vous" src="{{ STATIC_URL }}images/list-remove.png" data-occurrence-id="{{ appointment.occurrence_id }}" data-rdv="{{ appointment.title }}"> |
97 | 97 |
{% endif %} |
98 | 98 |
</span> |
calebasse/agenda/urls.py | ||
---|---|---|
3 | 3 |
from calebasse.cbv import TemplateView |
4 | 4 |
|
5 | 5 |
from views import (redirect_today, AgendaHomepageView, NewAppointmentView, |
6 |
NewEventView, AgendaServiceActivityView, |
|
6 |
NewEventView, AgendaServiceActivityView, UpdateAppointmentView,
|
|
7 | 7 |
AgendaServiceActValidationView, AutomatedValidationView, UnlockAllView) |
8 | 8 |
|
9 | 9 |
|
... | ... | |
15 | 15 |
url(r'^nouveau-rdv/$', |
16 | 16 |
NewAppointmentView.as_view(), |
17 | 17 |
name='nouveau-rdv'), |
18 |
url(r'^update-rdv/(?P<id>\d+)$', |
|
19 |
UpdateAppointmentView.as_view(), |
|
20 |
name='update-rdv'), |
|
18 | 21 |
url(r'^new-event/$', |
19 | 22 |
NewEventView.as_view(), |
20 | 23 |
name='new-event'), |
calebasse/agenda/views.py | ||
---|---|---|
4 | 4 |
from django.shortcuts import redirect |
5 | 5 |
from django.http import HttpResponseRedirect |
6 | 6 |
|
7 |
from calebasse.cbv import TemplateView, CreateView |
|
7 |
from calebasse.cbv import TemplateView, CreateView, UpdateView
|
|
8 | 8 |
from calebasse.agenda.models import Occurrence, Event, EventType |
9 | 9 |
from calebasse.personnes.models import TimeTable |
10 | 10 |
from calebasse.actes.models import EventAct |
... | ... | |
134 | 134 |
def post(self, *args, **kwargs): |
135 | 135 |
return super(NewAppointmentView, self).post(*args, **kwargs) |
136 | 136 |
|
137 |
class UpdateAppointmentView(UpdateView): |
|
138 |
model = EventAct |
|
139 |
form_class = NewAppointmentForm |
|
140 |
template_name = 'agenda/nouveau-rdv.html' |
|
141 |
success_url = '..' |
|
142 |
|
|
143 |
def get_object(self, queryset=None): |
|
144 |
self.occurrence = Occurrence.objects.get(id=self.kwargs['id']) |
|
145 |
if self.occurrence.event.eventact: |
|
146 |
return self.occurrence.event.eventact |
|
147 |
|
|
148 |
def get_initial(self): |
|
149 |
initial = super(UpdateView, self).get_initial() |
|
150 |
initial['date'] = self.object.date.strftime("%Y-%m-%d") |
|
151 |
initial['time'] = self.occurrence.start_time.strftime("%H:%M") |
|
152 |
time = self.occurrence.end_time - self.occurrence.start_time |
|
153 |
if time: |
|
154 |
time = time.seconds / 60 |
|
155 |
else: |
|
156 |
time = 0 |
|
157 |
initial['duration'] = time |
|
158 |
initial['participants'] = self.object.participants.values_list('id', flat=True) |
|
159 |
return initial |
|
160 |
|
|
161 |
def post(self, *args, **kwargs): |
|
162 |
return super(UpdateAppointmentView, self).post(*args, **kwargs) |
|
163 |
|
|
164 |
|
|
137 | 165 |
class NewEventView(CreateView): |
138 | 166 |
model = Event |
139 | 167 |
form_class = NewEventForm |
calebasse/static/js/calebasse.agenda.js | ||
---|---|---|
34 | 34 |
} |
35 | 35 |
} |
36 | 36 |
|
37 |
function event_dialog(url, title, width, btn_text) { |
|
38 |
$('#rdv').load(url, |
|
39 |
function () { |
|
40 |
function onsuccess(response, status, xhr, form) { |
|
41 |
var parse = $(response); |
|
42 |
if ($('.errorlist', parse).length != 0) { |
|
43 |
$('#rdv').html(response); |
|
44 |
$('#rdv form').ajaxForm({ |
|
45 |
success: onsuccess, |
|
46 |
}); |
|
47 |
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'}); |
|
48 |
console.log('error'); |
|
49 |
} else { |
|
50 |
console.log('success'); |
|
51 |
window.location.reload(true); |
|
52 |
} |
|
53 |
} |
|
54 |
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'}); |
|
55 |
$('#id_description').attr('rows', '3'); |
|
56 |
$('#id_description').attr('cols', '30'); |
|
57 |
$('form', this).ajaxForm({ |
|
58 |
success: onsuccess |
|
59 |
}); |
|
60 |
$(this).dialog({title: title, |
|
61 |
width: width, |
|
62 |
buttons: [ { text: "Fermer", |
|
63 |
click: function() { $(this).dialog("close"); } }, |
|
64 |
{ text: btn_text, |
|
65 |
click: function() { $("#rdv form").submit(); } }]}); |
|
66 |
}); |
|
67 |
} |
|
68 |
|
|
37 | 69 |
(function($) { |
38 | 70 |
$(function() { |
39 | 71 |
$('#tabs').tabs(); |
... | ... | |
133 | 165 |
var participants = $('.person-item.active').map(function (i, v) { return $(v).data('worker-id'); }); |
134 | 166 |
var qs = $.param({participants: $.makeArray(participants), time: $(this).data('hour') }, true); |
135 | 167 |
var new_appointment_url = $(this).data('url') + "?" + qs; |
136 |
$('#rdv').load(new_appointment_url, |
|
137 |
function () { |
|
138 |
function onsuccess(response, status, xhr, form) { |
|
139 |
var parse = $(response); |
|
140 |
if ($('.errorlist', parse).length != 0) { |
|
141 |
$('#rdv').html(response); |
|
142 |
$('#rdv form').ajaxForm({ |
|
143 |
success: onsuccess, |
|
144 |
}); |
|
145 |
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'}); |
|
146 |
console.log('error'); |
|
147 |
} else { |
|
148 |
console.log('success'); |
|
149 |
window.location.reload(true); |
|
150 |
} |
|
151 |
} |
|
152 |
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'}); |
|
153 |
$('form', this).ajaxForm({ |
|
154 |
success: onsuccess |
|
155 |
}); |
|
156 |
$(this).dialog({title: 'Nouveau rendez-vous', |
|
157 |
width: '820px', |
|
158 |
buttons: [ { text: "Fermer", |
|
159 |
click: function() { $(this).dialog("close"); } }, |
|
160 |
{ text: "Ajouter", |
|
161 |
click: function() { $("#rdv form").submit(); } }]}); |
|
162 |
}); |
|
168 |
event_dialog(new_appointment_url, 'Nouveau rendez-vous', '820px', 'Ajouter'); |
|
163 | 169 |
}); |
164 |
$('.newrdv').click(function() { |
|
170 |
$('.edit-appointment').click(function() { |
|
171 |
event_dialog("update-rdv/" + $(this).data('occurrence-id') , 'Modifier rendez-vous', '820px', 'Modifier'); |
|
172 |
return false; |
|
173 |
}); |
|
174 |
$('.newevent').click(function() { |
|
165 | 175 |
var participants = $('.person-item.active').map(function (i, v) { return $(v).data('worker-id'); }); |
166 | 176 |
var qs = $.param({participants: $.makeArray(participants), time: $(this).data('hour') }, true); |
167 |
var new_appointment_url = $(this).data('url') + "?" + qs; |
|
168 |
$('#rdv').load(new_appointment_url, |
|
169 |
function () { |
|
170 |
function onsuccess(response, status, xhr, form) { |
|
171 |
var parse = $(response); |
|
172 |
if ($('.errorlist', parse).length != 0) { |
|
173 |
$('#rdv').html(response); |
|
174 |
$('#rdv form').ajaxForm({ |
|
175 |
success: onsuccess, |
|
176 |
}); |
|
177 |
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'}); |
|
178 |
console.log('error'); |
|
179 |
} else { |
|
180 |
console.log('success'); |
|
181 |
window.location.reload(true); |
|
182 |
} |
|
183 |
} |
|
184 |
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'}); |
|
185 |
$('#id_description').attr('rows', '3'); |
|
186 |
$('#id_description').attr('cols', '30'); |
|
187 |
$('form', this).ajaxForm({ |
|
188 |
success: onsuccess |
|
189 |
}); |
|
190 |
$(this).dialog({title: 'Nouvelle événement', |
|
191 |
width: '850px', |
|
192 |
buttons: [ { text: "Fermer", |
|
193 |
click: function() { $(this).dialog("close"); } }, |
|
194 |
{ text: "Ajouter", |
|
195 |
click: function() { $("#rdv form").submit(); } }]}); |
|
196 |
}); |
|
177 |
event_dialog($(this).data('url') + "?" + qs, 'Nouvelle événement', '850px', 'Ajouter'); |
|
197 | 178 |
}); |
198 |
}) |
|
179 |
});
|
|
199 | 180 |
})(window.jQuery) |
Also available in: Unified diff
Fix #1877: add appoinment edition
appoinment edition