• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python account.Account类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_account

  def create_account(cls, name=None):
    if not name:
      name = cls.DEFAULT_COMPANY_NAME

    account = Account(name=name)
    account.put()
    return account
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:7,代码来源:testing.py


示例2: setUp

    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()  # Prevent data from leaking between tests

        self.account = Account.get_or_insert(
            "123",
            email="[email protected]",
            registered=True)
        self.account.put()

        self.account_banned = Account.get_or_insert(
            "456",
            email="[email protected]",
            registered=True,
            shadow_banned=True,
        )
        self.account_banned.put()

        event = Event(id="2016test", name="Test Event", event_short="Test Event", year=2016, event_type_enum=EventType.OFFSEASON)
        event.put()
        self.match = Match(id="2016test_f1m1", event=ndb.Key(Event, "2016test"), year=2016, comp_level="f", set_number=1, match_number=1, alliances_json='')
        self.match.put()
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:25,代码来源:test_suggestion_creator.py


示例3: test_data_delete

def test_data_delete():
  from models.account import Account
  from models.project import Project
  from models.report import Report
  from models.variable import Variable
  
  roles = {
    'administrator':[], 
    'privileged_manager':[], 
    'manager':[], 
    'privileged_member':[], 
    'member':[], 
  }
  rolesVariable = Variable.query.filter_by(name='roles', scope='permissions').first()
  roles.update(rolesVariable.value or {})
  
  for account in [account for account in Account.all() if account.id.startswith('test.')]:
    for role_id, members in roles.items():
      if account.id in members:
        roles[role_id].remove(account.id)
    Account.delete(account.id)
    flash('account deleted: '+str(account))
  
  rolesVariable.value = roles
  rolesVariable.save()
  
  for project in [project for project in Project.all() if project.id.startswith('TEST/')]:
    Project.delete(project.id)
    flash('project deleted: '+str(project))
  
  return redirect(url_for('test_data_index'))
开发者ID:timur-glushan,项目名称:tt,代码行数:31,代码来源:data.py


示例4: install_account_data

def install_account_data():
  """Create all the required accounts if not defined"""
  from application import db
  from models.account import Account, Group
  
  accountList = [
    {
      'alias': 'timur.glushan',
      'first_name': 'Timur',
      'last_name': 'Glushan',
      'email': '[email protected]',
      'info': None,
      'group': Group.query.filter_by(alias='administrator').first()
    }
  ]
  
  for accountItem in accountList:
    account = Account.query.filter_by(alias=accountItem['alias']).first()
    if not account:
      account = Account()
      account.alias = accountItem['alias']
      account.first_name = accountItem['first_name']
      account.last_name = accountItem['last_name']
      account.email = accountItem['email']
      account.info = accountItem['info']
      account.group = accountItem['group']
      account.save()
开发者ID:timur-glushan,项目名称:tt,代码行数:27,代码来源:account.py


示例5: loginUser

    def loginUser(self):
        self.testbed.setup_env(
            user_email="[email protected]",
            user_id="123",
            user_is_admin='0',
            overwrite=True)

        Account.get_or_insert(
            "123",
            email="[email protected]",
            registered=True)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:11,代码来源:test_suggest_apiwrite_controller.py


示例6: TestMatchSuggestionAccepter

class TestMatchSuggestionAccepter(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()  # Prevent data from leaking between tests

        self.testbed.init_taskqueue_stub(root_path=".")

        self.account = Account(
            email="[email protected]",
        )
        self.account.put()

        self.suggestion = Suggestion(
            author=self.account.key,
            contents_json="{\"youtube_videos\":[\"123456\"]}",
            target_key="2012ct_qm1",
            target_model="match"
        )
        self.suggestion.put()

        self.event = Event(
          id="2012ct",
          event_short="ct",
          year=2012,
          event_type_enum=EventType.REGIONAL,
        )
        self.event.put()

        self.match = Match(
            id="2012ct_qm1",
            alliances_json="""{"blue": {"score": -1, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": -1, "teams": ["frc69", "frc571", "frc176"]}}""",
            comp_level="qm",
            event=self.event.key,
            year=2012,
            set_number=1,
            match_number=1,
            team_key_names=[u'frc69', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073'],
            youtube_videos=["abcdef"]
        )
        self.match.put()

    def tearDown(self):
        self.testbed.deactivate()

    def test_accept_suggestions(self):
        MatchSuggestionAccepter.accept_suggestion(self.match, self.suggestion)

        match = Match.get_by_id("2012ct_qm1")
        self.assertTrue("abcdef" in match.youtube_videos)
        self.assertTrue("123456" in match.youtube_videos)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:53,代码来源:test_match_suggestion_accepter.py


示例7: transactions

def transactions():
    """List transactions"""

    v = request.values.get

    page = int(v('page', 1))

    account_id = Account.authorize(v('api_key'))
    if not account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    account = Account.query.get(account_id)

    res = Transaction.query.filter_by(account_id= account_id)
    res = res.order_by(Transaction.create_date.desc()).paginate(page, 15, False)

    return jsonify({
        'page':         res.page,
        'pages':        res.pages,
        'per_page':     res.per_page,
        'total':        res.total,
        'has_next':     res.has_next,
        'has_prev':     res.has_prev,
        'transactions': [trans.public_data() for trans in res.items]
    })
开发者ID:lyonbros,项目名称:faxrobot,代码行数:25,代码来源:accounts.py


示例8: remove_card

def remove_card():
    """Removes stored credit card info from the account"""

    from datetime import datetime
    import json
    import stripe

    stripe.api_key = os.environ.get('STRIPE_SECRET_KEY')

    account_id = Account.authorize(request.values.get('api_key'))
    if not account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    account = Account.query.get(account_id)

    if account.stripe_token and account.stripe_card:
        try:
            customer = stripe.Customer.retrieve(account.stripe_token)
            customer.sources.retrieve(account.stripe_card).delete()
        except:
            pass # oh well, whatever. fuck it.

    account.stripe_token = None
    account.stripe_card = None
    account.last4 = None
    account.auto_recharge = 0
    account.mod_date = datetime.now()
    db.session.commit()

    return jsonify(account.public_data())
开发者ID:lyonbros,项目名称:faxrobot,代码行数:30,代码来源:accounts.py


示例9: listActiveAccounts

 def listActiveAccounts(cls):
   from models.account import Account
   
   return Account.query\
     .filter(~Account.status.in_(Account._r(Account.STATUS_DELETED)))\
     .order_by(Account.first_name, Account.last_name, Account.alias)\
     .all()
开发者ID:timur-glushan,项目名称:tt,代码行数:7,代码来源:account.py


示例10: givePermission

 def givePermission(self):
     account = Account.get_or_insert(
         "123",
         email="[email protected]",
         registered=True)
     account.permissions.append(AccountPermissions.MUTATE_DATA)
     account.put()
开发者ID:DNGros,项目名称:the-blue-alliance,代码行数:7,代码来源:test_suggestions_review_permission_checks.py


示例11: delete

def delete():
    """Delete an incoming fax"""

    from library.mailer import email_admin
    from boto.s3.connection import S3Connection
    from boto.s3.key import Key

    v = request.values.get

    access_key = v('access_key')
    account_id = Account.authorize(v('api_key'))

    if not account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    faxes = IncomingFax.query.filter_by(access_key = access_key)
    fax = faxes.first()

    db.session.delete(fax)
    db.session.commit()

    try:
        conn = S3Connection(os.environ.get('AWS_ACCESS_KEY'),
                            os.environ.get('AWS_SECRET_KEY'))
        bucket = conn.get_bucket(os.environ.get('AWS_S3_BUCKET'))
        k = Key(bucket)
        k.key ='incoming/' + access_key + '/fax.pdf'
        k.delete()
    except:
        email_admin("AWS S3 connect fail for fax deletion: %s" % access_key)

    return jsonify({"success": True})
开发者ID:lyonbros,项目名称:faxrobot,代码行数:32,代码来源:incoming.py


示例12: list

def list():
    """List faxes"""

    v = request.values.get

    account_id = Account.authorize(v('api_key'))
    if not account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    try:
        page = int(v('page', 1))
        if page < 1:
            raise
    except:
        return jsonify(api_error('INCOMING_BAD_PAGINATION_VALUE')), 400


    faxes = IncomingFax.query.filter_by(account_id= account_id)
    faxes = faxes.order_by(IncomingFax.create_date.desc()).paginate(page, 20,
            False)

    return jsonify({
        'page':     faxes.page,
        'pages':    faxes.pages,
        'per_page': faxes.per_page,
        'total':    faxes.total,
        'has_next': faxes.has_next,
        'has_prev': faxes.has_prev,
        'faxes':    [fax.public_data() for fax in faxes.items]
    })
开发者ID:lyonbros,项目名称:faxrobot,代码行数:30,代码来源:incoming.py


示例13: get

    def get(self):
        self._require_admin()

        self.template_values['memcache_stats'] = memcache.get_stats()

        # Gets the 5 recently created users
        users = Account.query().order(-Account.created).fetch(5)
        self.template_values['users'] = users

        # Retrieves the number of pending suggestions
        video_suggestions = Suggestion.query().filter(Suggestion.review_state == Suggestion.REVIEW_PENDING).count()
        self.template_values['video_suggestions'] = video_suggestions

        # version info
        try:
            fname = os.path.join(os.path.dirname(__file__), '../../version_info.json')

            with open(fname, 'r') as f:
                data = json.loads(f.read().replace('\r\n', '\n'))

            self.template_values['git_branch_name'] = data['git_branch_name']
            self.template_values['build_time'] = data['build_time']

            commit_parts = re.split("[\n]+", data['git_last_commit'])
            self.template_values['commit_hash'] = commit_parts[0].split(" ")
            self.template_values['commit_author'] = commit_parts[1]
            self.template_values['commit_date'] = commit_parts[2]
            self.template_values['commit_msg'] = commit_parts[3]

        except Exception, e:
            logging.warning("version_info.json parsing failed: %s" % e)
            pass
开发者ID:chrismarra,项目名称:the-blue-alliance,代码行数:32,代码来源:admin_main_controller.py


示例14: setUp

    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub(root_path=".")

        self.account = Account(email="[email protected]")
        self.account.put()

        self.suggestion = Suggestion(
            author=self.account.key,
            contents_json='{"youtube_videos":["123456"]}',
            target_key="2012ct_qm1",
            target_model="match",
        )
        self.suggestion.put()

        self.event = Event(id="2012ct", event_short="ct", year=2012, event_type_enum=EventType.REGIONAL)
        self.event.put()

        self.match = Match(
            id="2012ct_qm1",
            alliances_json="""{"blue": {"score": -1, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": -1, "teams": ["frc69", "frc571", "frc176"]}}""",
            comp_level="qm",
            event=self.event.key,
            game="frc_2012_rebr",
            set_number=1,
            match_number=1,
            team_key_names=[u"frc69", u"frc571", u"frc176", u"frc3464", u"frc20", u"frc1073"],
            youtube_videos=["abcdef"],
        )
        self.match.put()
开发者ID:dewdn2,项目名称:the-blue-alliance,代码行数:33,代码来源:test_match_suggestion_accepter.py


示例15: test_permissions_all_accounts_groups

def test_permissions_all_accounts_groups():
  from models.account import Account
  
  title = 'Testing | Permissions | Listed per-account-role permissions'
  
  data = '<table class="table" width="100%">'
  employees = [employee for employee in Account.all()]
  roles = g._var(name='roles', scope='permissions', default={}).keys()
  data = data + '<tr>'
  data = data + '<th>&nbsp;</th>'
  for role in roles:
    data = data + '<th>'+role+'</th>'
  data = data + '</tr>'
  
  for employee in employees:
    data = data + '<tr>'
    data = data + '<th>'+employee+'</th>'
    for role in roles:
      is_permitted = app.access('role', account=employee, role_id=role)
      data = data + (is_permitted and '<td class="alert alert-success">yes</td>' or '<td class="alert alert-danger">no</td>')
    data = data + '</tr>'
  
  data = data + '</table>'
  data = Markup(data)
  
  return render_template( 'test/index.html', title=title, data=data )
开发者ID:timur-glushan,项目名称:tt,代码行数:26,代码来源:permissions.py


示例16: listActiveReports

 def listActiveReports(cls, start_date=None, end_date=None, accounts=None, components=None):
   from models.account import Account
   from models.project import Project, Component
   from models.report import Report
   
   query = Report.query\
     .filter(~Report.status.in_(Report._r(Report.STATUS_DELETED)))\
     .join(Report.account)\
     .filter(~Account.status.in_(Account._r(Account.STATUS_DELETED)))\
     .join(Report.component, aliased=True)\
     .filter(~Component.status.in_(Component._r(Component.STATUS_DELETED)))\
     .join(Report.project, aliased=True)\
     .filter(~Project.status.in_(Project._r(Project.STATUS_DELETED)))
   
   if start_date:
     query = query.filter(Report.due_date>=start_date)
   if end_date:
     query = query.filter(Report.due_date<=end_date)
   if accounts:
     query = query.filter(Report.account_id.in_(accounts))
   if components:
     query = query.filter(Report.component_id.in_(components))
   
   query = query.order_by(Account.first_name, Account.last_name, Account.alias, Report.due_date, Report.created)
   
   return query.all()
开发者ID:timur-glushan,项目名称:tt,代码行数:26,代码来源:report.py


示例17: list

def list():
    """List faxes"""

    v = request.values.get

    account_id = Account.authorize(v('api_key'))
    if not account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    try:
        page = int(v('page', 1))
        if page < 1:
            raise
    except:
        return jsonify(api_error('JOBS_BAD_PAGINATION_VALUE')), 400

    if v('filter'):
        jobs = Job.query.filter_by(account_id= account_id, status= v('filter'))
    else:
        jobs = Job.query.filter_by(account_id= account_id)
    jobs = jobs.order_by(Job.create_date.desc()).paginate(page, 20, False)

    return jsonify({
        'page':     jobs.page,
        'pages':    jobs.pages,
        'per_page': jobs.per_page,
        'total':    jobs.total,
        'has_next': jobs.has_next,
        'has_prev': jobs.has_prev,
        'jobs':     [job.public_data() for job in jobs.items]
    })
开发者ID:objcguy,项目名称:faxrobot,代码行数:31,代码来源:jobs.py


示例18: find_one

 def find_one(cls, collection, field, value):
     if collection == 'customers':
         return Customer.fromjson(cls.db[collection].find_one({field: value}))
     if collection == 'prepaids':
         return Prepaid.fromjson(cls.db[collection].find_one({field: value}))
     if collection == 'postpaids':
         return Postpaid.fromjson(cls.db[collection].find_one({field: value}))
     if collection == 'setups':
         return Setup.fromjson(cls.db[collection].find_one({field: value}))
     if collection == 'how_to_pays':
         return HowToPay.fromjson(cls.db[collection].find_one({field: value}))
     if collection == 'how_to_topups':
         return HowToTopup.fromjson(cls.db[collection].find_one({field: value}))
     if collection == 'accounts':
         account = cls.db[collection].find_one({field: value})
         if account is not None:
             return Account.fromjson(cls.find_by_id('customers', account['customer']), cls.find_by_id('prepaids', account['package']), account)
         else:
             return None
     if collection == 'bills':
         bill = cls.db[collection].find({field: value}).sort('payment_date', -1)[0]
         if bill is not None:
             return Bill.fromjson(bill, cls.find_by_id('customers', bill['customer']), cls.find_by_id('postpaids', bill['package']))
         else:
             return None
开发者ID:thanakorn,项目名称:speech_recognition_callcenter,代码行数:25,代码来源:database.py


示例19: get

    def get(self):
        self._require_admin()

        self.template_values['memcache_stats'] = memcache.get_stats()
        self.template_values['databasequery_stats'] = {
            'hits': sum(filter(None, [memcache.get(key) for key in DatabaseQuery.DATABASE_HITS_MEMCACHE_KEYS])),
            'misses': sum(filter(None, [memcache.get(key) for key in DatabaseQuery.DATABASE_MISSES_MEMCACHE_KEYS]))
        }

        # Gets the 5 recently created users
        users = Account.query().order(-Account.created).fetch(5)
        self.template_values['users'] = users

        self.template_values['suggestions_count'] = Suggestion.query().filter(
            Suggestion.review_state == Suggestion.REVIEW_PENDING).count()

        # version info
        try:
            fname = os.path.join(os.path.dirname(__file__), '../../version_info.json')

            with open(fname, 'r') as f:
                data = json.loads(f.read().replace('\r\n', '\n'))

            self.template_values['git_branch_name'] = data['git_branch_name']
            self.template_values['build_time'] = data['build_time']

            commit_parts = re.split("[\n]+", data['git_last_commit'])
            self.template_values['commit_hash'] = commit_parts[0].split(" ")
            self.template_values['commit_author'] = commit_parts[1]
            self.template_values['commit_date'] = commit_parts[2]
            self.template_values['commit_msg'] = commit_parts[3]

        except Exception, e:
            logging.warning("version_info.json parsing failed: %s" % e)
            pass
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:35,代码来源:admin_main_controller.py


示例20: restart

def restart(access_key):
    """Restarts a failed job"""

    account_id = Account.authorize(request.values.get('api_key'))

    jobs = Job.query.filter_by(access_key = access_key)
    job = jobs.first()
    
    if job == None or not account_id or not account_id == job.account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    if not job.failed:
        return jsonify(api_error('JOBS_NOT_RESTARTABLE')), 400

    if job.data_deleted:
        return jsonify(api_error('JOBS_DATA_DELETED')), 400

    ip = fix_ip(request.headers.get('x-forwarded-for', request.remote_addr))

    job.ip_address = ip
    job.failed = 0
    job.fail_code = 0
    job.status = 'queued'
    db.session.commit()
    redis_conn = Redis.from_url(os.environ.get('REDIS_URI'))
    q = Queue(connection=redis_conn)
    q.enqueue_call(func=send_fax, args=(job.id,), timeout=600)

    return jsonify(job.public_data())
开发者ID:objcguy,项目名称:faxrobot,代码行数:29,代码来源:jobs.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api_auth_access.ApiAuthAccess类代码示例发布时间:2022-05-27
下一篇:
Python User.User类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap