當前位置: 首頁>>代碼示例>>Python>>正文


Python user.User類代碼示例

本文整理匯總了Python中autonomie.models.user.User的典型用法代碼示例。如果您正苦於以下問題:Python User類的具體用法?Python User怎麽用?Python User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了User類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: adduser

def adduser(dbsession):
    user = User(login='test_forms_user',
                lastname='lastname__éé',
                firstname='firstname__éé')
    user.set_password(u"Tést$!Pass")
    dbsession.add(user)
    dbsession.flush()
    return user
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:8,代碼來源:test_forms_user.py

示例2: test_role

def test_role(dbsession):
    a = User(**TEST1)
    assert a.is_admin()
    assert not a.is_manager()
    a = User(**TEST2)
    assert a.is_manager()
    assert not a.is_admin()
    a = User(**TEST3)
    assert a.is_contractor()
    assert not a.is_admin()
開發者ID:yledoare,項目名稱:autonomie,代碼行數:10,代碼來源:test_models_user.py

示例3: test_role

 def test_role(self):
     a = User(**TEST1)
     self.assertTrue(a.is_admin())
     self.assertFalse(a.is_manager())
     a = User(**TEST2)
     self.assertTrue(a.is_manager())
     self.assertFalse(a.is_admin())
     a = User(**TEST3)
     self.assertTrue(a.is_contractor())
     self.assertFalse(a.is_admin())
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:10,代碼來源:test_models_user.py

示例4: test_account

 def test_account(self):
     a = User(**TEST1)
     a.set_password('pwd')
     self.assertTrue(a.auth("pwd"))
     strange = "#;\'\\\" $25; é ö ô è à ù"
     a.set_password(strange)
     self.assertFalse(a.auth("pwd"))
     self.assertTrue(a.auth(strange))
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:8,代碼來源:test_models_user.py

示例5: add_user

def add_user(login, password, group, firstname="", lastname=""):
    user = User(login=login, firstname=firstname, lastname=lastname)
    user.set_password(password)

    user.primary_group = group

    session = DBSESSION()
    session.add(user)

    session.flush()

    group_name = GROUPS[group]
    print "Added %s: %s/%s" % (group_name, login, password)

    return user
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:15,代碼來源:fake_database.py

示例6: get_user_choices

def get_user_choices():
    """
        Return the a list of values for the contractor autocomplete widget
    """
    choices = [(0, u'Tous les entrepreneurs')]
    choices.extend([(unicode(user.id),
                     u"{0} {1}".format(user.lastname, user.firstname),)
                        for user in User.query().all()])
    return choices
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:9,代碼來源:holiday.py

示例7: unique_login

def unique_login(node, value):
    """
        Test login unicity against database
    """
    result = User.query(only_active=False).filter_by(login=value).first()
    if result:
        message = u"Le login '{0}' n'est pas disponible.".format(
                                                            value)
        raise colander.Invalid(node, message)
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:9,代碼來源:user.py

示例8: test_gen_cancelinvoice_payment

def test_gen_cancelinvoice_payment(dbsession, invoice):
    user = User.query().first()
    project = Project.query().first()
    invoice.project = project
    invoice.owner = user
    invoice.statusPersonAccount = user
    invoice.record_payment(mode="c", amount=1500)
    cinv = invoice.gen_cancelinvoice(user)
    assert len(cinv.lines) ==  len(invoice.lines) + len(invoice.discounts) + 1
    assert cinv.lines[-1].cost == 1500
開發者ID:w3bcr4ft,項目名稱:autonomie,代碼行數:10,代碼來源:test_invoice.py

示例9: test_company_index

 def test_company_index(self):
     avatar = User.get(3)
     self.config.add_route('company', '/company/{cid}')
     self.config.add_static_view('static', 'autonomie:static')
     request = self.get_csrf_request()
     request._user = avatar
     request.user = avatar
     request.context = avatar.companies[0]
     response = company_index(request)
     self.assertEqual(avatar.companies[0].name, response['company'].name )
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:10,代碼來源:test_company.py

示例10: test_company_index

def test_company_index(config, content, get_csrf_request_with_db):
    from autonomie.views.company import company_index
    avatar = User.query().first()
    config.add_route('company', '/company/{cid}')
    config.add_static_view('static', 'autonomie:static')
    request = get_csrf_request_with_db()
    request._user = avatar
    request.user = avatar
    request.context = avatar.companies[0]
    response = company_index(request)
    assert avatar.companies[0].name == response['company'].name
開發者ID:w3bcr4ft,項目名稱:autonomie,代碼行數:11,代碼來源:test_company.py

示例11: test_gen_cancelinvoice_payment

 def test_gen_cancelinvoice_payment(self):
     user = User.query().first()
     project = Project.query().first()
     inv = self.getOne()
     inv.project = project
     inv.owner = user
     inv.statusPersonAccount = user
     inv.record_payment(mode="c", amount=1500)
     cinv = inv.gen_cancelinvoice(user)
     self.assertEqual(len(cinv.lines),
                       len(inv.lines) + len(inv.discounts) + 1)
     self.assertEqual(cinv.lines[-1].cost, 1500)
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:12,代碼來源:test_invoice.py

示例12: add_admin

def add_admin(arguments, env):
    """
        Add an admin user to the database
    """
    login = get_value(arguments, 'user', 'admin.majerti')
    password = get_value(arguments, 'pwd', get_pwd())
    firstname = get_value(arguments, 'firstname', 'Admin')
    lastname = get_value(arguments, 'lastname', 'Majerti')
    email = get_value(arguments, 'email', '[email protected]')
    user = User(login=login,
                firstname=firstname,
                primary_group=1,  #is an admin
                lastname=lastname,
                email=email
            )
    user.set_password(password)
    db = DBSESSION()
    db.add(user)
    db.flush()
    print u"Creating account %s with password %s" % (login, unicode(password))
    return user
開發者ID:w3bcr4ft,項目名稱:autonomie,代碼行數:21,代碼來源:add_admin.py

示例13: auth

def auth(form, value):
    """
        Check the login/password content
    """
    log.debug(u" * Authenticating")
    login = value.get('login')
    log.debug(u"   +  Login {0}".format(login))
    password = value.get('password')
    result = User.query().filter_by(login=login).first()
    if not result or not result.auth(password):
        log.debug(u"    - Authentication Error")
        message = u"Erreur d'authentification"
        exc = colander.Invalid(form, message)
        exc['password'] = message
        raise exc
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:15,代碼來源:user.py

示例14: upgrade

def upgrade():
    logger = logging.getLogger("alembic.migrate_code_compta")
    op.add_column("company", sa.Column("code_compta", sa.String(30), default=0))
    dbsession = DBSESSION()
    for user in User.query():
        code_compta = user.code_compta
        companies = user.companies
        if code_compta not in [u"0", None, u""]:
            if len(companies) == 1:
                company = companies[0]
                company.code_compta = code_compta
                dbsession.merge(company)
            else:
                logger.warn(u"User {0} has a code_compta and multiple \
companies".format(user.id))
開發者ID:mike-perdide,項目名稱:autonomie,代碼行數:15,代碼來源:1_6_migrate_code_com_29299007fe7d.py

示例15: test_gen_cancelinvoice

def test_gen_cancelinvoice(dbsession, invoice):
    user = User.query().first()
    project = Project.query().first()
    invoice.project = project
    invoice.owner = user
    invoice.statusPersonAccount = user
    dbsession.add(invoice)
    dbsession.flush()
    cinv = invoice.gen_cancelinvoice(user)
    dbsession.add(cinv)
    dbsession.flush()

    assert cinv.name == "Avoir 1"
    assert cinv.total_ht() == -1 * invoice.total_ht()
    today = datetime.date.today()
    assert cinv.taskDate == today
開發者ID:w3bcr4ft,項目名稱:autonomie,代碼行數:16,代碼來源:test_invoice.py


注:本文中的autonomie.models.user.User類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。