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


Python utils.create_user函数代码示例

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


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

示例1: setUp

 def setUp(self):
     cache.clear()
     self.user = utils.create_user()
     self.user2 = utils.create_user()
     self.category = utils.create_category()
     self.topic = utils.create_topic(self.category, user=self.user2)
     self.topic2 = utils.create_topic(self.category)
开发者ID:AlienTechs,项目名称:Spirit,代码行数:7,代码来源:tests_user.py

示例2: setUp

    def setUp(self):
        check_permissions()
        self.username = "antonio"
        create_user(self.username)

        self.browser = Browser()
        self.browser.visit(self.live_server_url)
开发者ID:CulturePlex,项目名称:festos,代码行数:7,代码来源:test_user.py

示例3: add_user

def add_user():
    form = request.form
    try:
        utils.create_user(username=form['username'], password=form['password'], \
            role=form['role'], active=True)
        flash(messages.USER_CREATED, 'success')
    except Exception, e:
        flash('{0} {1}'.format(messages.NEW_USER_ERROR, e), 'error')
开发者ID:ehazlett,项目名称:site_templates,代码行数:8,代码来源:application.py

示例4: test_do_notify

    def test_do_notify(self):
        # first create 3 user here
        user1 = utils.create_user('[email protected]')
        user2 = utils.create_user('[email protected]')
        user3 = utils.create_user('[email protected]')

        # clear inbox to delete all activate emails
        self.clear_inbox()

        old_datetime = datetime(2000, 1, 1).replace(tzinfo=tz)

        s1 = user1.setting
        s1.notify = True
        s1.timezone = '11.0'
        s1.preferhour = 1
        s1.nexttime = old_datetime
        s1.save()

        s2 = user2.setting
        s2.notify = True
        s2.timezone = '-9.0'
        s2.preferhour = 8
        s2.nexttime = old_datetime
        s2.save()

        s3 = user3.setting
        s3.notify = True
        s3.timezone = '8.0'
        s3.preferhour = 22
        s3.nexttime = datetime(2100, 1, 1).replace(tzinfo=tz)  # future time
        s3.save()

        tasks.do_notify()

        # check result
        today = datetime.utcnow().replace(tzinfo=timezone.utc)

        mails1 = self.recv_mail(user1)
        self.assertEqual(len(mails1), 1)
        subject = mails1[0].get('Subject')
        t1 = today + timedelta(hours=11)
        self.assertIn("%s %d" % (t1.strftime('%b'), t1.day), subject)
        # check next timestamp
        nexttime = Setting.objects.get(user=user1).nexttime
        self.assertTrue(old_datetime.toordinal() < nexttime.toordinal())

        mails2 = self.recv_mail(user2)
        self.assertEqual(len(mails2), 1)
        subject = mails2[0].get('Subject')
        t2 = today + timedelta(hours=-9)
        self.assertIn("%s %d" % (t2.strftime('%b'), t2.day), subject)

        # user3 should not recv notify mail
        mails3 = self.recv_mail(user3)
        self.assertEqual(len(mails3), 0)
开发者ID:oneyoung,项目名称:longhi,代码行数:55,代码来源:tasks.py

示例5: test_add_user

 def test_add_user(self):
     try:
         utils.create_user(
             self.client, 'test123', 'test123',
             '[email protected]', self.p1.id,
             self.d1.id)
     except:
         self.fail('Unexpected exception raised: '
                   'utils.create_user('
                   'self.client, \'test123\', \'test123\','
                   '\'[email protected]\', self.p1.id,'
                   'self.d1.id)')
开发者ID:rodrigods,项目名称:keystone-policy-tests,代码行数:12,代码来源:cloud_admin_tests.py

示例6: create

def create(request):
  values = {}
  if request.META["REQUEST_METHOD"] == "POST":
    valid, error = utils.check_auth_token(request.POST['username'])
    if valid:
      utils.create_user(request.POST['username'], request.POST['password'], request.POST['google_wave_address'])
      values['user_created'] = True
    else:
      values['token_failed'] = True
      values['error'] = error
  if 'user_created' not in values:
    values['token'] = utils.create_token()
  return render_to_response('create.html', values)
开发者ID:scottferg,项目名称:sa-auto-adder,代码行数:13,代码来源:views.py

示例7: setUp

 def setUp(self):
     cache.clear()
     self.user = utils.create_user()
     self.user2 = utils.create_user()
     self.category = utils.create_category()
     self.topic = utils.create_topic(self.category)
     self.comment = utils.create_comment(topic=self.topic)
     self.topic_notification = TopicNotification.objects.create(user=self.user, topic=self.topic,
                                                                comment=self.comment, is_active=True,
                                                                action=COMMENT, is_read=True)
     self.topic_notification2 = TopicNotification.objects.create(user=self.user2, topic=self.topic,
                                                                 comment=self.comment, is_active=True,
                                                                 action=COMMENT, is_read=True)
开发者ID:AlienTechs,项目名称:Spirit,代码行数:13,代码来源:tests_topic_notification.py

示例8: login

def login():
    from werkzeug.security import check_password_hash
    from werkzeug.security import generate_password_hash

    username = bleach.clean(request.form['username'], tags=[])
    password = request.form['password']
    if not username:
        return redirect('/error/empty_user')

    if 'login-button' in request.form:
        """Attempts to log the user in"""

        user = db['users'].find_one(username=username)
        if user is None:
            return redirect('/error/invalid_credentials')

        if check_password_hash(user['password'], password):
            session_login(username)
            #return redirect('/competitions')
            return redirect('/competition/1')

    if 'register-button' in request.form:
        """Attempts to register a new user"""

        shell_username = sanitize_name(username)

        user_found = db['users'].find_one(username=username)
        shell_found = db['users'].find_one(shell_username=shell_username)
        if user_found or shell_found:
            return redirect('/error/already_registered')

        admin = False
        userCount = db['users'].count()

        #if no users, make first user admin
        if userCount == 0:
            admin = True

        new_user = dict(username=username, password=generate_password_hash(password), admin=admin, shell_username=shell_username)
        db['users'].insert(new_user)

        create_user(shell_username, password)

        # Set up the user id for this session
        session_login(username)

        #return redirect('/competitions')
        return redirect('/competition/1')

    return redirect('/error/invalid_credentials')
开发者ID:IMEplusplus,项目名称:tinyctf-platform,代码行数:50,代码来源:server.py

示例9: setup

def setup():
    if not utils.needs_user():
        return flask.redirect(flask.url_for('login'))
    error = None
    if flask.request.method == 'POST':
        username = flask.request.form['username']
        password = flask.request.form['password']
        password_confirm = flask.request.form['password_confirm']
        if password == password_confirm:
            utils.create_user(username, password)
            flask.flash('User Created')
            return flask.redirect(flask.url_for('login'))
        error = "passwords do not match"
    return flask.render_template('setup.j2', error=error)
开发者ID:Ryex,项目名称:i2c-alarmpy,代码行数:14,代码来源:web.py

示例10: setUp

 def setUp(self):
     fss.remove_tree(settings.MEDIA_ROOT)
     check_permissions()
     set_site(self.live_server_url)
     
     self.browser = Browser()
     self.browser.visit(self.live_server_url)
     
     login_url = settings.LOGIN_URL
     self.browser.click_link_by_partial_href(login_url)
     
     username = 'antonio'
     password = 'antonio'
     create_user(username)
     login(
         self.browser,
         username,
         password,
     )
     
     upload_url = reverse('documents.views.add_document')
     self.browser.click_link_by_partial_href(upload_url)
     
     source = 'local'
     docfile = get_abs_path('doctest.pdf')
     language = 'eng'
     public = True
     title = 'test'
     notes = 'test notes'
     upload(
         self.browser,
         source,
         docfile,
         language,
         public,
         title,
         notes,
     )
     
     self.browser.is_element_not_present_by_value('ready', 10)
     
     tag = 'tag'
     add_tag(
         self.browser,
         tag,
     )
     
     self.tag = tag
     self.tag_obj = get_tag(tag)
开发者ID:CulturePlex,项目名称:festos,代码行数:49,代码来源:test_tag.py

示例11: _test_metadata

    def _test_metadata(self, expected_exception, status, reason,
                       how_many_messages=0):
        from dropbox.rest import ErrorResponse

        class client(object):

            def __init__(self, status, reason):
                self.status = status
                self.reason = reason

            def metadata(self, path):
                class http_resp(object):
                    status = self.status
                    reason = self.reason

                    @staticmethod
                    def read():
                        return ''
                raise ErrorResponse(http_resp)

        user = create_user()
        service = self._getOUT(user)
        service.client = client(status, reason)
        request = testing.DummyRequest()
        self.setUpPyramid(request=request)

        with self.assertRaises(expected_exception):
            service.list('/')
        sent_messages = self.mail_stub.get_sent_messages(to=user.email)
        self.assertEqual(len(sent_messages), how_many_messages)
开发者ID:jbking,项目名称:netprintbox,代码行数:30,代码来源:test_service.py

示例12: _test_session_error

    def _test_session_error(self, method_name, *args):
        from dropbox.rest import ErrorResponse
        from netprintbox.exceptions import BecomePendingUser
        from netprintbox.settings import SYSADMIN_ADDRESS

        class FakeClient(object):
            def __getattr__(self, name):
                class http_resp(object):
                    status = 401
                    reason = 'Unauthorized'

                    @staticmethod
                    def read():
                        return ''
                raise ErrorResponse(http_resp)

        user = create_user()
        service = self._getOUT(user)
        service.client = FakeClient()
        request = testing.DummyRequest()
        self.setUpPyramid(request=request)

        self.assertFalse(user.is_pending)
        with self.assertRaises(BecomePendingUser):
            getattr(service, method_name)(*args)
        self.assertTrue(user.is_pending)
        sent_messages = self.mail_stub.get_sent_messages(to=user.email)
        self.assertEqual(len(sent_messages), 1)
        message = sent_messages[0]
        message_body = str(message.body)

        self.assertIn(request.route_url('authorize'), message_body)
        self.assertIn(SYSADMIN_ADDRESS, message.sender)
开发者ID:jbking,项目名称:netprintbox,代码行数:33,代码来源:test_service.py

示例13: test_treat_errors_on_netprint_sync

    def test_treat_errors_on_netprint_sync(self):
        user = create_user()
        file_info = create_file_info(user, path=u'/A4/テスト.doc')

        service = self._getOUT(user)

        class dropbox(object):
            @staticmethod
            def list(path, recursive=None):
                root_dir = app_dir()
                for dir in root_dir['contents']:
                    if dir['path'] == u'/A4':
                        a4_dir = dir
                        break
                else:
                    self.fail('No A4 directory')
                a4_dir['contents'].append(
                        create_dropbox_item(
                            path=file_info.path))
                return root_dir

        class netprint(object):
            @staticmethod
            def list():
                return [create_netprint_item(
                            name=file_info.as_netprint_name(True),
                            error=True)]

        service.dropbox = dropbox
        service.netprint = netprint
        service.sync()
开发者ID:jbking,项目名称:netprintbox,代码行数:31,代码来源:test_service.py

示例14: setUp

 def setUp(self):
     """Setting up test."""
     self.server_url = self.conf_get("main", "url")
     self.email = "fl_testing%[email protected]" % (uuid.uuid4().hex)
     self.password = "password"
     self.username = create_user(self.email, self.password, self)
     self.setBasicAuth(self.username, self.password)
开发者ID:tallowen,项目名称:funk-smoke,代码行数:7,代码来源:test_Smoke.py

示例15: test_ascii_password

 def test_ascii_password(self):
     for password in chunked_ascii():
         self.email = "fl_testing%[email protected]" % (uuid.uuid4().hex)
         self.password = password
         self.username = create_user(self.email, self.password, self)
         self.setBasicAuth(self.username, self.password)
         basic_sync(self.email, self.password, self)
开发者ID:tallowen,项目名称:funk-smoke,代码行数:7,代码来源:test_Smoke.py


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