Project

General

Profile

« Previous | Next » 

Revision b0e22743

Added by Jérôme Schneider over 12 years ago

Fix #1877: add appoinment edition

  • calebasse/agenda/templates/agenda/index.html: add appoinment edition * calebasse/agenda/urls.py: add agenda/.../update-rdv * calebasse/agenda/views.py: add UpdateAppointmentView * calebasse/static/js/calebasse.agenda.js: refactoring and add
    appoinment edition

View differences:

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

Also available in: Unified diff