class PhaseAddFormView(BaseFormView): title = u"Ajouter un dossier au projet" schema = PhaseSchema() def submit_success(self, appstruct): model = Phase() model.project_id = self.context.id merge_session_with_post(model, appstruct) self.dbsession.add(model) self.dbsession.flush() redirect = self.request.route_path("project", id=model.project_id, _query={'phase': model.id}) return HTTPFound(redirect)
def get_phase_add_form(request): """ Return a form object for phase add :param obj request: The pyramid request object :returns: A form :rtype: class:`deform.Form` """ schema = PhaseSchema().bind(request=request) form = Form( schema, buttons=(submit_btn, ), action=request.current_route_path(_query={'action': 'addphase'}), ) return form
class PhaseEditFormView(BaseFormView): title = u"Édition du dossier" schema = PhaseSchema() def before(self, form): form.set_appstruct(self.context.appstruct()) def submit_success(self, appstruct): merge_session_with_post(self.context, appstruct) self.dbsession.merge(self.context) redirect = self.request.route_path( "project", id=self.context.project_id, ) return HTTPFound(redirect)
def _get_phase_add_form(self): """ Return a form object for phase add :param obj request: The pyramid request object :returns: A form :rtype: class:`deform.Form` """ schema = PhaseSchema().bind(request=self.request) form = Form( schema, buttons=(submit_btn, ), action=self.request.route_path(PROJECT_ITEM_ROUTE, id=self.context.id, _query={'action': 'addphase'}), ) return form