def _edit(self): appointment = Appointment.get(self.request.params.get('id')) form = AppointmentForm(self.request) if form.validate(): form.submit(appointment) return {'success_message': _(u'Saved'), 'response': appointment.id} else: return { 'error_message': _(u'Please, check errors'), 'errors': form.errors }
def _add(self): form = AppointmentForm(self.request) if form.validate(): appointment = form.submit() DBSession.add(appointment) DBSession.flush() return {'success_message': _(u'Saved'), 'response': appointment.id} else: return { 'error_message': _(u'Please, check errors'), 'errors': form.errors }
def _edit(self): appointment = Appointment.get(self.request.params.get('id')) form = AppointmentForm(self.request) if form.validate(): form.submit(appointment) return { 'success_message': _(u'Saved'), 'response': appointment.id } else: return { 'error_message': _(u'Please, check errors'), 'errors': form.errors }
def _add(self): form = AppointmentForm(self.request) if form.validate(): appointment = form.submit() DBSession.add(appointment) DBSession.flush() return { 'success_message': _(u'Saved'), 'response': appointment.id } else: return { 'error_message': _(u'Please, check errors'), 'errors': form.errors }