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


Python users.User类代码示例

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


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

示例1: test_password_hashing_is_random

 def test_password_hashing_is_random(self):
     # Ensure that a password salt/hash is random
     user_one = User()
     user_two = User()
     password_one = user_one.createPass("test")
     password_two = user_two.createPass("test")
     self.assertTrue(password_one != password_two)
开发者ID:rbramwell,项目名称:runbook,代码行数:7,代码来源:test_user.py

示例2: confirm_email

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,代码行数:27,代码来源:views.py

示例3: detailhistory_page

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,代码行数:34,代码来源:views.py

示例4: delcheck_page

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,代码行数:25,代码来源:views.py

示例5: delreaction_page

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,代码行数:33,代码来源:views.py

示例6: checkaction_page

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,代码行数:34,代码来源:web.py

示例7: managereactions_page

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,代码行数:28,代码来源:views.py

示例8: userpref_page

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,代码行数:32,代码来源:web.py

示例9: test_initial_permissions

 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,代码行数:7,代码来源:test_user.py

示例10: test_check_password

 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,代码行数:7,代码来源:test_user.py

示例11: confirm_email

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,代码行数:25,代码来源:views.py

示例12: test_getRID_works

 def test_getRID_works(self):
     # Ensure that getRID() works as expected.
     timestamp = str(datetime.datetime.now())
     new_timestamp = timestamp.replace(":", "")
     with self.client:
         self.client.post(
             '/login',
             data=dict(email="[email protected]", password="password456"),
             follow_redirects=True
         )
         self.client.post(
             '/dashboard/reactions/enotify',
             data=dict(name=new_timestamp, trigger=1,
                       frequency=1, email="[email protected]",
                       send_true=True),
             follow_redirects=True
         )
         user = User()
         user_id = user.getUID('[email protected]', g.rdb_conn)
         get_reaction_id = Reaction()
         response = get_reaction_id.getRID(
             new_timestamp+':'+user_id, g.rdb_conn)
         results = r.table('reactions').filter(
             {'name': new_timestamp}).run(g.rdb_conn)
         for result in results:
             reaction_id = result['id']
             break
         self.assertEqual(response, reaction_id)
开发者ID:Runbook,项目名称:runbook,代码行数:28,代码来源:test_reactions.py

示例13: get_next_best_stations

def get_next_best_stations(phone_number):
    user = User(phone_number)

    stations = station_api.get_best_station(user.station_lat, user.station_lon)
    user.add_event("get_next_best_station")
    user.add_event("get_next_best_station_result", stations['second']['bike']['location_name'])

    return stations['second']
开发者ID:jdunlop,项目名称:txtbike,代码行数:8,代码来源:service.py

示例14: test_user_change_password

 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,代码行数:8,代码来源:test_users.py

示例15: delete

 def delete(self, user_id="__INVALID__"):
     
     # --- VALIDATION ----
     if user_id == "__INVALID__": 
         raise MethodNotAllowedError
         
     # --- DATA METHOD ---
     user_data = User()
     return user_data.delete(user_id)
开发者ID:AGoodnight,项目名称:generators,代码行数:9,代码来源:app.py


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