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


Python User.config方法代码示例

本文整理汇总了Python中users.User.config方法的典型用法代码示例。如果您正苦于以下问题:Python User.config方法的具体用法?Python User.config怎么用?Python User.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在users.User的用法示例。


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

示例1: test_password_hashing_is_random

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
 def test_password_hashing_is_random(self):
     # Ensure that a password salt/hash is random
     user_one = User()
     user_one.config = app.config
     user_two = User()
     user_two.config = app.config
     password_one = user_one.createPass("test")
     password_two = user_two.createPass("test")
     self.assertTrue(password_one != password_two)
开发者ID:Runbook,项目名称:runbook,代码行数:11,代码来源:test_user.py

示例2: test_check_password

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
 def test_check_password(self):
     # Ensure given password is correct after unhashing
     user = User()
     user.config = app.config
     user = user.get('username', '[email protected]', g.rdb_conn)
     self.assertTrue(user.checkPass('password456', g.rdb_conn))
     self.assertFalse(user.checkPass('wrong!', g.rdb_conn))
开发者ID:Runbook,项目名称:runbook,代码行数:9,代码来源:test_user.py

示例3: managereactions_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def managereactions_page():
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        data['url'] = '/dashboard/reactions/'
        data['js_bottom'] = [ 'member/reactions.js' ]
        tmpl = 'member/reactions.html'
        # Check Users Status
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            tmpl = 'member/mod-subscription.html'
        else:
            pass
        data['reactions'] = user.getReactions(g.rdb_conn)
        if len(data['reactions']) < 1:
            data['reacts'] = False
        else:
            data['reacts'] = True
        page = render_template(tmpl, data=data)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:30,代码来源:views.py

示例4: confirm_email

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def confirm_email(token):
    verify = verifyLogin(app.config["SECRET_KEY"], app.config["COOKIE_TIMEOUT"], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get("uid", verify, g.rdb_conn)
        if user.confirmed:
            flash("Account already confirmed. Thank you.", "success")
            return redirect(url_for("member.dashboard_page"))
        else:
            try:
                email = confirm_token(token)
                if user.email == email[0]:
                    r.table("users").get(verify).update({"confirmed": True}).run(g.rdb_conn)
                    flash("You have confirmed your account. Thanks!", "success")
                    return redirect(url_for("member.dashboard_page"))
                else:
                    flash("The confirmation link is invalid.", "danger")
                    return redirect(url_for("user.login_page"))
            except:
                flash("The confirmation link is invalid or has expired.", "danger")
                return redirect(url_for("user.login_page"))
    else:
        flash("Please Login.", "warning")
        return redirect(url_for("user.login_page"))
开发者ID:pathcl,项目名称:runbook,代码行数:27,代码来源:views.py

示例5: test_initial_permissions

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
 def test_initial_permissions(self):
     # Ensure initial permissions are set correctly
     user = User()
     user.config = app.config
     user_test = user.get('username', '[email protected]', g.rdb_conn)
     self.assertTrue(user_test.acttype == "lite-v2")
     self.assertFalse(user_test.acttype == "pro")
开发者ID:Runbook,项目名称:runbook,代码行数:9,代码来源:test_user.py

示例6: delcheck_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def delcheck_page(cid):
    '''
    Dashboard Delete Checks:
    This will delete health checks via the url parameters
    '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        if user.status != "active":
            pass
        else:

            # Delete the Monitor
            monitor = Monitor(cid)
            monitor.config = app.config
            monitor.get(cid, g.rdb_conn)
            result = monitor.deleteMonitor(user.uid, cid, g.rdb_conn)
            if result:
                print("/dashboard/delete-checks - Delete successful")
                flash('Health Check was successfully deleted.', 'success')
            else:
                print("/dashboard/delete-checks - Delete failed")
                flash('Health Check was not deleted', 'danger')
    return redirect(url_for('member.dashboard_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:29,代码来源:views.py

示例7: dashboard_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def dashboard_page():
    ''' Dashboard: Generate the Welcome/Status page for the dashboard '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        data['url'] = '/dashboard'
        data['js_bottom'].append("member/screen-o-death.js")
        data['js_bottom'].append("member/screen-o-death-chart.js")
        data['js_bottom'].append("member/monitors.js")
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            page = render_template('member/mod-subscription.html', data=data)
        else:

            data['monitors'] = user.getMonitors(g.rdb_conn)
            data['reactions'] = user.getReactions(g.rdb_conn)
            data['monevents'] = user.getEvents(g.rdb_conn)
            data['moneventsnum'] = len(data['monevents'])
            data['monstats'] = {'true': 0,
                                'unknown': 0,
                                'false': 0}
            for key in data['monitors'].keys():
                if "true" in data['monitors'][key]['status']:
                    data['monstats']['true'] = data[
                        'monstats']['true'] + 1
                elif "false" in data['monitors'][key]['status']:
                    data['monstats']['false'] = data['monstats']['false'] + 1
                else:
                    data['monstats']['unknown'] = data[
                        'monstats']['unknown'] + 1

            # If there are no monitors print a welcome message
            if len(data['monitors']) < 1:
                data['welcome'] = True
                data['mons'] = False
            else:
                data['welcome'] = False
                data['mons'] = True

            if len(data['reactions']) < 1:
                data['reacts'] = False
            else:
                data['reacts'] = True

            from generalforms import subscribe
            form = subscribe.AddPackForm(request.form)
            page = render_template(
                'member/screen-o-death.html', data=data, form=form)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:59,代码来源:views.py

示例8: signup

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def signup():
    """
    User Sign up page: Very basic email + password
    sign up form that will also login users.
    """
    # Data is used throughout for the jinja2 templates
    data = {"active": "signup", "loggedin": False}  # Sets the current page  # Don't show the logout link

    # Define the SignupForm
    form = SignupForm(request.form)
    # Validate and then create userdata
    if request.method == "POST":
        if form.validate():
            # Take form data
            email = form.email.data
            password = form.password.data
            company = form.company.data
            contact = form.contact.data
            userdata = {"username": email, "email": email, "password": password, "company": company, "contact": contact}

            # Create user
            user = User()
            user.config = app.config
            result = user.createUser(userdata, g.rdb_conn)
            # Check results for success or failure
            if result == "exists":
                flash("User already exists.", "danger")
            elif result is not False:
                try:
                    stathat.ez_count(app.config["STATHAT_EZ_KEY"], app.config["ENVNAME"] + " User Signup", 1)
                except:
                    pass
                print("/signup - New user created")
                cdata = cookies.genCdata(result, app.config["SECRET_KEY"])
                data["loggedin"] = True
                flash("You are signed up.", "success")

                # Generate confirmation token
                generate_confirmation_token(email, result, time.time())

                # Build response
                resp = make_response(redirect(url_for("member.dashboard_page")))
                timeout = int(time.time()) + int(app.config["COOKIE_TIMEOUT"])
                # Set the cookie secure as best as possible
                resp.set_cookie("loggedin", cdata, expires=timeout, httponly=True)
                return resp
        else:
            stathat.ez_count(app.config["STATHAT_EZ_KEY"], app.config["ENVNAME"] + " False User Signup", 1)
            print("/signup - False user creation")
            flash("Form is not valid.", "danger")

    # Return Signup Page
    return render_template("user/signup.html", data=data, form=form)
开发者ID:pathcl,项目名称:runbook,代码行数:55,代码来源:views.py

示例9: modsub_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def modsub_page():
    '''Dashboard Modify Subscription:
    This will allow a user to modify their subscription and account plan
    '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        data['url'] = '/dashboard/mod-subscription'
        data['uid'] = user.uid
        tmpl = 'member/mod-subscription.html'
        data['js_bottom'].append('forms/subscribe.js')
        form = []
        from generalforms import subscribe

        payment = __import__("payments." + user.payments, globals(),
                             locals(), ['Payments'], -1)

        subscription = payment.Payments(user=user, config=app.config, rdb=g.rdb_conn)
        if request.method == "POST":
            if data['upgraded'] is True:
                result = subscription.adjust(request)
            else:
                result = subscription.create(request)

            if result is True:
                if data['upgraded'] is True:
                    flash('Adjustment to subscription successful', 'success')
                else:
                    data['upgraded'] = True
                    flash('Successfully Subscribed!', 'success')
                newdata = startData(user)
                data['limit'] = newdata['limit']
                data['rlimit'] = newdata['rlimit']
                data['acttype'] = newdata['acttype']
                data['subplans'] = newdata['subplans']
                data['cost'] = newdata['cost']
                data['subscription'] = newdata['subscription']
            else:
                flash('Unable to adjust subscription please notify support', 'danger')
        if data['upgraded'] is True:
            form = subscribe.AddPackForm(request.form)
        page = render_template(tmpl, data=data, form=form)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:53,代码来源:views.py

示例10: test_correct_login

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
 def test_correct_login(self):
     # Ensure login behaves correctly with correct credentials
     with self.client:
         self.client.post(
             '/login',
             data=dict(email="[email protected]", password="password456"),
             follow_redirects=True
         )
         user = User()
         user.config = app.config
         user = user.get('username', '[email protected]', g.rdb_conn)
         active = user.is_active('[email protected]', g.rdb_conn)
         self.assertTrue(user.email == "[email protected]")
         self.assertTrue(active)
开发者ID:Runbook,项目名称:runbook,代码行数:16,代码来源:test_user.py

示例11: test_registered_user_time_attribue

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
 def test_registered_user_time_attribue(self):
     # Ensure that a registered user has creation_time attribute
     with self.client:
         response = self.client.post('/signup', data=dict(
             email='[email protected]',
             company="test",
             contact="test",
             password='test_user',
             confirm='test_user'
         ), follow_redirects=True)
         self.assertEqual(response.status_code, 200)
         user = User()
         user.config = app.config
         user = user.get('username', '[email protected]', g.rdb_conn)
         self.assertTrue(user.creation_time)
开发者ID:Runbook,项目名称:runbook,代码行数:17,代码来源:test_user.py

示例12: test_validate_confirmation_token_invalid

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
 def test_validate_confirmation_token_invalid(self):
     # Ensure invalid token cannot be successfully confirmed in the views
     with self.client:
         self.client.post('/login', data=dict(
             email='[email protected]', password='password456'
         ), follow_redirects=True)
         response = self.client.get(
             '/confirm/incorrect', follow_redirects=True)
         user = User()
         user.config = app.config
         user = user.get('username', '[email protected]', g.rdb_conn)
         self.assertFalse(user.confirmed)
         self.assertEqual(response.status_code, 200)
         self.assertIn('Login', response.data)
         self.assertIn('The confirmation link is invalid or has expired.',
                       response.data)
开发者ID:Runbook,项目名称:runbook,代码行数:18,代码来源:test_user.py

示例13: test_get_by_id

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
 def test_get_by_id(self):
     # Ensure id is correct for the current/logged in user
     with self.client:
         response = self.client.post('/login', data=dict(
             email='[email protected]', password='password456'
         ), follow_redirects=True)
         print response
         logged_in_user_id = verifyLogin(
             app.config['SECRET_KEY'],
             app.config['COOKIE_TIMEOUT'],
             request.cookies
         )
         user = User()
         user.config = app.config
         user_id = user.getUID('[email protected]', g.rdb_conn)
         self.assertTrue(logged_in_user_id == user_id)
开发者ID:Runbook,项目名称:runbook,代码行数:18,代码来源:test_user.py

示例14: login_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def login_page():
    ''' User login page: This is a basic login page'''
    data = {
        'active': 'login',
        'loggedin': False
    }

    # Define and Validate the form
    form = LoginForm(request.form)
    if request.method == "POST":
        if form.validate():
            email = form.email.data
            password = form.password.data

            # Start user definition
            user = User()
            user.config = app.config
            if user.get('username', email, g.rdb_conn):
                result = user.checkPass(password, g.rdb_conn)
                if result is True:
                    data['loggedin'] = True
                    print("/login - User login successful")
                    flash('You are logged in.', 'success')
                    # Start building response
                    resp = make_response(
                        redirect(url_for('member.dashboard_page')))
                    cdata = cookies.genCdata(
                        user.uid, app.config['SECRET_KEY'])
                    timeout = int(time.time()) + \
                        int(app.config['COOKIE_TIMEOUT'])
                    # Set cookie as securely as possible
                    resp.set_cookie(
                        'loggedin', cdata, expires=timeout, httponly=True)
                    print("Setting cookie")
                    return resp
                else:
                    print("/login - User login error: wrong password")
                    flash('Password does not seem valid.', 'danger')
            else:
                print("/login - User login error: invalid user")
                flash('Uhh... User not found.', 'danger')
        else:
            print("/login - User login error: invalid form")
            flash('Form is not valid.', 'danger')

    # Return Login Page
    return render_template('user/login.html', data=data, form=form)
开发者ID:madflojo,项目名称:cloudroutes-service,代码行数:49,代码来源:views.py

示例15: viewhistory_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import config [as 别名]
def viewhistory_page(cid, start, limit):
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        data['url'] = '/dashboard/view-history/' + cid
        tmpl = 'monitors/view-history.html'
        # Check Users Status
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            tmpl = 'member/mod-subscription.html'
        else:
            monitor = Monitor()
            monitor.config = app.config
            monitor.get(cid, g.rdb_conn)
            if monitor.uid == user.uid:
                data['monitor'] = {
                    'cid': monitor.cid,
                    'name': monitor.name,
                    'ctype': monitor.ctype,
                    'uid': monitor.uid,
                    'data': monitor.data
                }
                chktime = time.time() - float(data['dataret'])
                data['monitor-history-count'] = monitor.history(
                    method="count", time=chktime, rdb=g.rdb_conn)
                data['monitor-history'] = monitor.history(
                    method="mon-history", time=chktime,
                    start=int(start), limit=int(limit), rdb=g.rdb_conn)
                data['monitor-history-paging'] = []
                data['monitor-history-paging-start'] = int(start)
                cur = 0
                while cur < data['monitor-history-count'] - 200:
                    cur = cur + 200
                    data['monitor-history-paging'].append(cur)
            else:
                flash('This monitor does not belong to your user.', 'warning')
        page = render_template(tmpl, data=data)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:48,代码来源:views.py


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