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


Python User.get方法代码示例

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


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

示例1: detailhistory_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
def detailhistory_page(cid, hid):
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        data['url'] = '/dashboard/detail-history/' + hid
        tmpl = 'monitors/detail-history.html'
        # Check Users Status
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            tmpl = 'member/mod-subscription.html'
        else:
            monitor = Monitor()
            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
                }
                data['monitor-history'] = monitor.history(
                    method="detail-history", hid=hid, rdb=g.rdb_conn)
            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:rbramwell,项目名称:runbook,代码行数:36,代码来源:views.py

示例2: delcheck_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [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.get('uid', verify, g.rdb_conn)
        if user.status != "active":
            pass
        else:

            # Delete the Monitor
            monitor = Monitor(cid)
            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:rbramwell,项目名称:runbook,代码行数:27,代码来源:views.py

示例3: checkaction_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
def checkaction_page(cid, action):
  ''' 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.get('uid', verify, g.rdb_conn)
    if user.status != "active":
      pass
    else:
      
      ## Delete the Monitor
      monitor = Monitor(cid)
      monitor.get(cid, g.rdb_conn)
      if user.uid == monitor.uid:
        if action == "failed":
          monitor.healthcheck = "web-failed"
          result = monitor.webCheck(g.rdb_conn)
          print("/dashboard/action-checks - Manual monitor failure")
        elif action == "healthy":
          monitor.healthcheck = "web-healthy"
          print("/dashboard/action-checks - Manual monitor healthy")
          result = monitor.webCheck(g.rdb_conn)
        
        if result:
          print("/dashboard/action-checks - Manual monitor queued")
          flash('Health check status change is queued', 'success')
        else:
          print("/dashboard/action-checks - Manual monitor action failed")
          flash('Something went wrong. Could not modify health check', 'danger')
      else:
        print("/dashboard/action-checks - Manual monitor action failed: do not own")
        flash('It does not appear you own this health check', 'danger')

  return redirect(url_for('dashboard_page'))
开发者ID:mose,项目名称:cloudroutes-service,代码行数:36,代码来源:web.py

示例4: delreaction_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
def delreaction_page(rid):
    '''
    Dashboard Delete Domains:
    This will delete a domain based on url parameters
    '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.get('uid', verify, g.rdb_conn)
        if user.status != "active":
            pass
        else:

            appliedcount = 0
            results = r.table('monitors').filter(
                {'uid': user.uid}).run(g.rdb_conn)
            for x in results:
                if rid in x['data']['reactions']:
                    appliedcount = appliedcount + 1

            if appliedcount < 1:
                # Delete the Reaction
                reaction = Reaction(rid)
                result = reaction.deleteReaction(user.uid, rid, g.rdb_conn)
                if result:
                    flash('Reaction was successfully deleted.', 'success')
                else:
                    flash('Reaction was not deleted.', 'danger')
            else:
                flash('You must first detach this reaction \
                      from all monitors before deleting.', 'danger')
    return redirect(url_for('member.dashboard_page'))
开发者ID:dustinrc,项目名称:cloudroutes-service,代码行数:35,代码来源:views.py

示例5: managereactions_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [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

示例6: userpref_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
def userpref_page():
  ''' Dashbaord User Preferences: This will allow a user to change user preferences, i.e. Password '''
  verify = verifyLogin(app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
  if verify:
    user = User()
    user.get('uid', verify, g.rdb_conn)
    data = startData(user)
    data['active'] = 'dashboard'
    if user.status != "active":
      data['url'] = '/dashboard/mod-subscription'
      tmpl = 'mod-subscription.html'
    else:
      
      ## Start processing the change password form
      form = ChangePassForm(request.form)
      if request.method == 'POST':
        if form.validate():
          result = user.setPass(form.password.data, g.rdb_conn)
          if result:
            data['msg'] = "Password successfully changed"
            print("/dashboard/user-preferences - Password changed")
            data['error'] = False
          else:
            data['msg'] = "Password change was unsuccessful"
            print("/dashboard/user-preferences - Password change failed")
            data['error'] = True
      data['url'] = '/dashboard/user-preferences'
      tmpl = 'user-preferences.html'
    page = render_template(tmpl, data=data, form=form)
    return page
  else:
    return redirect(url_for('login_page'))
开发者ID:mose,项目名称:cloudroutes-service,代码行数:34,代码来源:web.py

示例7: confirm_email

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [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

示例8: confirm_email

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
def confirm_email(token):
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        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:madflojo,项目名称:cloudroutes-service,代码行数:29,代码来源:views.py

示例9: test_user_change_password

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
 def test_user_change_password(self):
     u = User.create(name='test', password='pass_1')
     u = User.get(User.name == 'test')
     u.set_password('pass_2')
     u.save()
     u = User.get(User.name == 'test')
     ok_(not u.verify_password('pass_1'))
     ok_(u.verify_password('pass_2'))
开发者ID:ael-code,项目名称:libreant,代码行数:10,代码来源:test_users.py

示例10: dashboard_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [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.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")
        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 and len(data['reactions']) < 1:
                data['welcome'] = True
            else:
                data['welcome'] = False

            if len(data['monitors']) < 1:
                data['mons'] = False
            else:
                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:dustinrc,项目名称:cloudroutes-service,代码行数:60,代码来源:views.py

示例11: get_user

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
def get_user(id=None, name=None):
    try:
        if id:
            return User.get(User.id==id)
        elif name:
            return User.get(User.name==name)
        else:
            raise ValueError('nither `id` or `name` was given')
    except User.DoesNotExist:
        raise NotFoundException("no user could be found with these attributes")
开发者ID:ael-code,项目名称:libreant,代码行数:12,代码来源:api.py

示例12: modsub_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [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

示例13: register

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [as 别名]
def register():

	try:
		data = request.json
		if ( data == None ):
			raise Exception()
	except:
		response = make_response(json.dumps({'register':'malformed'}), 400)
		response.headers["Content-Type"] = "application/json"
		return response
	else:
		data = dict(data)
		username = data.get('username', None)
		password = data.get('password', None)

	if ( username == None or password == None ):
		response = make_response(json.dumps({'register':'malformed'}), 400)
		response.headers["Content-Type"] = "application/json"
		return response

	elif ( User.get(username) != None ):
		response = make_response(json.dumps({'error':'username taken'}), 403)
		response.headers["Content-Type"] = "application/json"
		return response

	else:
		try:
			User(username, password)
			response = make_response(json.dumps({'register':'success'}), 200)
		except:
			response = make_response(json.dumps({'register':'fail'}), 500)
		response.headers["Content-Type"] = "application/json"
		return response
开发者ID:meety,项目名称:meety-server,代码行数:35,代码来源:server.py

示例14: test_check_password

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [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

示例15: test_initial_permissions

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import get [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


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