def business(dbsession, full_estimation, default_business_type): from autonomie.models.project.business import Business business = Business(name="business", business_type=default_business_type) business.estimations = [full_estimation] dbsession.add(business) dbsession.flush() full_estimation.business_type_id = default_business_type.id full_estimation.businesses = [business] dbsession.merge(full_estimation) return business
def gen_business(self): """ Generate a business based on this Task :returns: A new business instance :rtype: :class:`autonomie.models.project.business.Business` """ business = Business( name=self.name, project_id=self.project_id, business_type_id=self.business_type_id, ) DBSESSION().add(business) DBSESSION().flush() business.populate_indicators() logger.debug(u"Business has id {}".format(business.id)) business.file_requirement_service.populate(business) self.business_id = business.id DBSESSION().merge(self) return business
def func(req_type="mandatory", validation=False, tasks=[], project=None): business_node = Business( file_requirements=[], business_type_id=btypes['default'].id, tasks=tasks, project=project, ) mk_business_type_file_types( ftypes['ftype1'], btypes['default'], 'business', req_type, validation ) dbsession.add(business_node) dbsession.flush() SaleFileRequirementService.populate(business_node) return business_node
def is_used(self): """ Check if there is a project using this specific type """ query = Business.query().filter_by(business_type_id=self.id) return DBSESSION().query(query.exists()).scalar()