当前位置: 首页>>代码示例>>Python>>正文


Python company.Company类代码示例

本文整理汇总了Python中autonomie.models.company.Company的典型用法代码示例。如果您正苦于以下问题:Python Company类的具体用法?Python Company怎么用?Python Company使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Company类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_company

 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
开发者ID:mike-perdide,项目名称:autonomie,代码行数:13,代码来源:user.py

示例2: company2

def company2(dbsession, user):
    from autonomie.models.company import Company
    company = Company(
        name=u"Company 2",
        email=u"[email protected]",
    )
    company.employees = [user]
    dbsession.add(company)
    dbsession.flush()
    user.companies = [company]
    user = dbsession.merge(user)
    dbsession.flush()
    return company
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:13,代码来源:test_base.py

示例3: other_company

def other_company(dbsession, other_user):
    from autonomie.models.company import Company
    company = Company(
        name=u"Company2",
        email=u"[email protected]",
        code_compta="0USER2",
    )
    company.employees = [other_user]
    dbsession.add(company)
    dbsession.flush()
    other_user.companies = [company]
    other_user = dbsession.merge(other_user)
    dbsession.flush()
    return company
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:14,代码来源:test_user.py

示例4: TestCompanyModel

class TestCompanyModel(BaseTestCase):
    def setUp(self):
        BaseTestCase.setUp(self)
        self.company = Company(name=u"Test", id=1)
        self.company.logo = dict(filename=u"logo.png")
        self.company.header = dict(filename=u"header.png")

    def test_get_path(self):
        self.assertEqual(self.company.get_path(), "company/1")
        self.assertEqual(self.company.get_logo_filepath(), "company/1/logo/logo.png")
        self.assertEqual(self.company.get_header_filepath(), "company/1/header/header.png")

    def test_get_company_id(self):
        self.assertEqual(self.company.get_company_id(), 1)
开发者ID:mike-perdide,项目名称:autonomie,代码行数:14,代码来源:test_models_company.py

示例5: _mk_company

 def _mk_company(name, email, code_compta):
     from autonomie.models.company import Company
     company = Company(
         name=name,
         email=email,
         code_compta=code_compta,
     )
     company.employees = [user]
     dbsession.add(company)
     dbsession.flush()
     user.companies = [company]
     dbsession.merge(user)
     dbsession.flush()
     return company
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:14,代码来源:conftest.py

示例6: add_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
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:15,代码来源:fake_database.py

示例7: gen_companies

    def gen_companies(self):
        """
        Generate companies as expected
        """
        from autonomie.models.company import Company
        companies = []
        for data in self.activity_companydatas:
            # Try to retrieve an existing company (and avoid duplicates)
            company = Company.query().filter(
                Company.name == data.name
            ).first()

            if company is None:
                company = Company(
                    name=data.name,
                    goal=data.title,
                    email=self.coordonnees_email1,
                    phone=self.coordonnees_tel,
                    mobile=self.coordonnees_mobile,
                )
                if data.activity is not None:
                    company.activities.append(data.activity)

            company.employees.append(self.user)
            companies.append(company)
        return companies
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:26,代码来源:userdatas.py

示例8: get_company_by_code

def get_company_by_code(code_compta):
    """
    Return the company associated to this code_compta
    :param str code_compta: The analytic code of the company to find
    """
    query = Company.query().filter(Company.code_compta==code_compta)
    return query.first()
开发者ID:w3bcr4ft,项目名称:autonomie,代码行数:7,代码来源:treasury_files.py

示例9: submit_success

    def submit_success(self, appstruct):
        """
            Insert config informations into database
        """
        # la table config étant un stockage clé valeur
        # le merge_session_with_post ne peut être utilisé
        dbdatas = Config.query().all()

        log.debug(u"Cae configuration submission")
        log.debug(appstruct)

        new_dbdatas = merge_config_datas(dbdatas, appstruct)
        for dbdata in new_dbdatas:
            log.debug(dbdata.name)
            if dbdata in dbdatas:
                self.dbsession.merge(dbdata)
            else:
                self.dbsession.add(dbdata)
            # If we set the contribution_cae value, we want it to be the default
            # for every company that has no contribution value set
            if dbdata.name == 'contribution_cae':
                for comp in Company.query():
                    if comp.contribution is None:
                        comp.contribution = dbdata.value
                        self.dbsession.merge(comp)
        self.dbsession.flush()
        self.request.session.flash(self.validation_msg)
        return HTTPFound(self.request.route_path("admin_cae"))
开发者ID:yledoare,项目名称:autonomie,代码行数:28,代码来源:admin.py

示例10: submit_success

 def submit_success(self, appstruct):
     """
     Edit the database entry and return redirect
     """
     user_id = appstruct.get("user_id")
     company = Company()
     company.activities = fetch_activities_objects(appstruct)
     company = merge_session_with_post(company, appstruct)
     if user_id is not None:
         user_account = User.get(user_id)
         if user_account is not None:
             company.employees.append(user_account)
     self.dbsession.add(company)
     self.dbsession.flush()
     message = u"L'entreprise '{0}' a bien été ajoutée".format(company.name)
     self.session.flash(message)
     return HTTPFound(self.request.route_path("company", id=company.id))
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:17,代码来源:company.py

示例11: upgrade

def upgrade():
    from autonomie.models.company import Company
    from autonomie.models.files import File
    from autonomie.models import DBSESSION
    from alembic.context import get_bind
    from autonomie.models.config import ConfigFiles

    for i in ('header_id', 'logo_id',):
        col = sa.Column(i, sa.Integer, sa.ForeignKey('file.id'))
        op.add_column('company', col)

    query = "select id, header, logo from company;"
    conn = get_bind()
    result = conn.execute(query)

    session = DBSESSION()

    for id_, header, logo in result:
        company = Company.get(id_)
        basepath = u"%scompany/%s" % (BASEFILEPATH, id_,)

        if header:
            header_path = u"%s/header/%s" % (basepath, header)
            try:
                file_datas = load_file_struct(header_path, header)
            except:
                print("Error while loading a header")
                print(id_)
                file_datas = None
            if file_datas:
                company.header = file_datas
                session.add(company.header_file)
                session.flush()

        if logo:
            logo_path = u"%s/logo/%s" % (basepath, logo)
            try:
                file_datas = load_file_struct(logo_path, logo)
            except:
                print("Error while loading a logo")
                print(id_)
                file_datas = None
            if file_datas:
                company.logo = file_datas
                company = session.merge(company)
                session.flush()

    filepath = u"%s/main/logo.png" % BASEFILEPATH
    if os.path.isfile(filepath):
        ConfigFiles.set('logo.png', load_file_struct(filepath, 'logo.png'))

    filepath = u"%s/main/accompagnement_header.png" % BASEFILEPATH
    if os.path.isfile(filepath):
        ConfigFiles.set(
            'accompagnement_header.png',
            load_file_struct(filepath, 'accompagnement_header.png')
        )
开发者ID:w3bcr4ft,项目名称:autonomie,代码行数:57,代码来源:2_3_1_2_3_1_header_and_logo_in_db_40c1f95213d0.py

示例12: get_company

 def get_company(self, name, user):
     """
         Return a company object, create a new one if needed
     """
     company = Company.query().filter(Company.name==name).first()
     #avoid creating duplicate companies
     if company is None:
         company = self.add_company(name, user)
     return company
开发者ID:mike-perdide,项目名称:autonomie,代码行数:9,代码来源:user.py

示例13: get_companies

def get_companies(request):
    """
        Retrieve the companies the current user has access to
    """
    companies = []
    if request.user.is_admin() or request.user.is_manager():
        companies = Company.query().all()
    else:
        companies = request.user.companies
    return companies
开发者ID:w3bcr4ft,项目名称:autonomie,代码行数:10,代码来源:menu.py

示例14: customer

def customer(config, content, get_csrf_request_with_db):
    config.add_route('customer', '/')
    request = get_csrf_request_with_db()
    comp = Company.query().first()
    comp.__name__ = 'company'
    request.context = comp
    request.user = get_user()
    view = CustomerAdd(request)
    view.submit_success(APPSTRUCT)
    return getOne()
开发者ID:w3bcr4ft,项目名称:autonomie,代码行数:10,代码来源:test_customer.py

示例15: project

def project(config, get_csrf_request_with_db):
    from autonomie.views.project import ProjectAdd
    config.add_route('project', '/')
    req = get_csrf_request_with_db()
    company = Company.query().first()
    company.__name__ = 'company'
    req.context = company
    view = ProjectAdd(req)
    appstruct = APPSTRUCT.copy()
    view.submit_success(appstruct)
    return getone()
开发者ID:w3bcr4ft,项目名称:autonomie,代码行数:11,代码来源:test_project.py


注:本文中的autonomie.models.company.Company类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。