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