def add_company(self, name, user): """ Add a company 'name' in the database ( set its goal by default ) """ log.info(u"Adding company : %s" % name) company = Company() company.name = name company.goal = u"Entreprise de {0}".format(format_account(user)) company.contribution = self.request.config.get('contribution_cae') company = self.dbsession.merge(company) self.dbsession.flush() return company
def _add_company(self, name, user): """ Add a company 'name' in the database ( set its goal by default ) """ logger.info(u"Adding company : %s" % name) company = Company() company.name = name company.goal = u"Entreprise de {0}".format( format_account(user, reverse=False)) company.contribution = self.request.config.get('contribution_cae') company = self.dbsession.merge(company) self.dbsession.flush() return company
def add_company(user, company_name, goal=""): company = Company() company.name = company_name company.goal = goal or u"Entreprise de %s" % user.login user.companies.append(company) session = DBSESSION() session.add(company) session.flush() print "Added company for %s: %s" % (user.login, company_name) return company