本文整理汇总了Python中autonomie.models.company.Company.query方法的典型用法代码示例。如果您正苦于以下问题:Python Company.query方法的具体用法?Python Company.query怎么用?Python Company.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autonomie.models.company.Company
的用法示例。
在下文中一共展示了Company.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_company_by_code
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
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()
示例2: gen_companies
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
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
示例3: submit_success
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
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"))
示例4: get_company
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
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
示例5: get_companies
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
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
示例6: customer
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
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()
示例7: project
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
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()
示例8: belongs_to_company
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def belongs_to_company(filename):
"""
Check if a file belongs to a company
:param str filename: The filename we want to check
"""
try:
code_compta = get_code_compta(filename)
result = Company.query().filter(Company.code_compta==code_compta).count() > 0
except:
result = False
return result
示例9: submit_success
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def submit_success(self, appstruct):
for name in appstruct.get('companies', []):
company = Company.query().filter(Company.name == name).first()
if company is not None and \
company not in self.current_user.companies:
self.current_user.companies.append(company)
self.request.dbsession.merge(self.current_user)
url = self.request.route_path(
"/users/{id}/companies",
id=self.current_user.id,
)
return HTTPFound(url)
示例10: test_add
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def test_add(self, config, get_csrf_request_with_db):
from autonomie.views.company import CompanyAdd
config.add_route('company', 'company')
post = DATAS.copy()
req = get_csrf_request_with_db(post=post)
view = CompanyAdd(req)
view.__call__()
company = Company.query().filter_by(name=u"Compané $& test").first()
assert company is not None
assert company.goal == u"Be the best"
assert company.contribution == 80
示例11: test_user_id
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def test_user_id(self, config, get_csrf_request_with_db, user):
from autonomie.views.company import CompanyAdd
post = DATAS.copy()
post['user_id'] = str(user.id)
req = get_csrf_request_with_db(post=post)
req.referrer = "/test"
view = CompanyAdd(req)
view.__call__()
company = Company.query().filter_by(name=u"Compané $& test").first()
assert company is not None
assert user in company.employees
示例12: __call__
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def __call__(self):
"""
the stats view
"""
ret_dict = dict(title=u"Statistiques")
companies = Company.query([Company.id, Company.name]).all()
ret_dict['companies'] = companies
current_year = 2000
years = range(2000, datetime.date.today().year + 1)
ret_dict['years'] = years
if self.request.context.__name__ == 'company':
if 'year' in self.request.params:
try:
year = int(self.request.params['year'])
if year not in years:
raise ValueError
except:
year = 2000
current_year = year
company = self.request.context
projects = company.projects
customers = company.customers
invoices = []
estimations = []
for proj in projects:
invoices.extend(
[inv
for inv in proj.invoices
if inv.taskDate.year >= current_year]
)
estimations.extend(
[est
for est in proj.estimations
if est.taskDate.year >= current_year]
)
prospects = [cli
for cli in customers
if True not in [len(proj.invoices) > 0
for proj in cli.projects]]
#Return the stats
ret_dict['current_company'] = company
ret_dict['projects'] = projects
ret_dict['customers'] = customers
ret_dict['prospects'] = prospects
ret_dict['invoices'] = invoices
ret_dict['estimations'] = estimations
ret_dict['current_year'] = current_year
return ret_dict
示例13: test_come_from
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def test_come_from(self, config, get_csrf_request_with_db, user):
from autonomie.views.company import CompanyAdd
post = DATAS.copy()
post['come_from'] = "/test"
req = get_csrf_request_with_db(post=post)
req.referrer = "/test"
view = CompanyAdd(req)
result = view.__call__()
assert result.location == "/test"
company = Company.query().filter_by(name=u"Compané $& test").first()
assert company is not None
assert company.goal == u"Be the best"
assert company.contribution == 80
示例14: test_unique_ccode
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def test_unique_ccode(dbsession, content):
# A IMDD exists in the database for the company with id 1
company = Company.query().first()
company.__name__ = 'company'
validator = makeOne(company)
with pytest.raises(colander.Invalid):
validator('nutt', u'C001')
validator('nutt', u'C002')
company = Company(
name="company2",
goal="Company of user2",
phone='0457858586',
)
company.__name__ = 'company'
validator = makeOne(company)
validator('nutt', u'C001')
# In edit mode, no error is raised for the current_customer
customer = dbsession.query(Customer).first()
customer.__name__ = 'customer'
validator = makeOne(customer)
validator('nutt', u'C001')
示例15: query
# 需要导入模块: from autonomie.models.company import Company [as 别名]
# 或者: from autonomie.models.company.Company import query [as 别名]
def query(self):
return Company.query(active=False)