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


Python User.all方法代码示例

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


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

示例1: init_QA

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
def init_QA():
    is_student_exist = False
    is_lecturer_exist = False
    qa_student = User(username='qa_student', name='Student QA', avatar_url='http://ava.com', email='[email protected]',
                   isLecturer=False, accessToken='student_token_', seToken='_QA_TOKEN_TEST_STUDENT')
    qa_lecturer = User(username='qa_lecturer', name='Student QA', avatar_url='http://ava.com', email='[email protected]',
                   isLecturer=True, accessToken='student_token_', seToken='_QA_TOKEN_TEST_LECTURER')
    query = User.all().filter('username =', qa_student.username)
    for u in query.run():
        is_student_exist = True
        u.isLecturer = qa_student.isLecturer
        u.seToken = qa_student.seToken
        u.campuses_id_list = []
        u.classes_id_list = []
        db.put(u)

    query = User.all().filter('username =', qa_lecturer.username)
    for u in query.run():
        is_lecturer_exist = True
        u.isLecturer = qa_lecturer.isLecturer
        u.seToken = qa_lecturer.seToken
        u.campuses_id_list = []
        u.classes_id_list = []
        db.put(u)

    if not is_lecturer_exist:
        db.put(qa_lecturer)
    if not is_student_exist:
        db.put(qa_student)

    return Response(status=200)
开发者ID:jce-il,项目名称:SE-Hub,代码行数:33,代码来源:API.py

示例2: send_activation

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
def send_activation(token):
    """
    <span class="card-title">This Method Will Send An Email To The User - To Confirm his Account</span>
    <br>
    <b>Route Parameters</b><br>
        - token: 'seToken'<br>
    <br>
    <b>Payload</b><br>
     - JSON object <i>Example</i>
     <br>
     <code>{email: '[email protected]'}</code>
    <br>
    <br>
    <b>Response</b>
    <br>
    200 - Email Sent - No Response<br>
    400 - Bad Request<br>
    403 - Invalid Token<br>
    """
    if not request.data:
        return bad_request()
    payload = json.loads(request.data)
    if not is_user_token_valid(token):
        return forbidden("Not A Valid Token!")

    query = User.all()
    query.filter('seToken =', token)
    for u in query.run(limit=1):
        try:
            send_validation_email(token=token, name=u.username, email=payload["email"])
        except Exception:
            return bad_request()

        return Response(status=200)
开发者ID:jce-il,项目名称:SE-Hub,代码行数:36,代码来源:API.py

示例3: get_user_by_token

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
def get_user_by_token(token):
    query = User.all()
    query.filter("seToken = ", token)

    for u in query.run(limit = 1):
        return u
    return None
开发者ID:jce-il,项目名称:SE-Hub,代码行数:9,代码来源:Validation_Utils.py

示例4: get

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
 def get(self, uuid=None):
     ''' Get a specific user or all users '''
     if uuid is None:
         response = json.dumps([user.to_dict() for user in User.all()])
     else:
         user = User.by_uuid(uuid)
         if user is not None:
             response = user.to_dict()
         else:
             self.set_status(BAD_REQUEST)
             response = {"error": "User not found"}
     self.write(response)
开发者ID:fun-alex-alex2006hw,项目名称:Sonar-Server,代码行数:14,代码来源:AdminHandlers.py

示例5: getUserByToken

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
def getUserByToken(token):
    """
    <span class="card-title">>This Call will return a user by a given token</span>
    <br>
    <b>Route Parameters</b><br>
        - seToken: 'seToken'
    <br>
    <br>
    <b>Payload</b><br>
     - NONE
    <br>
    <br>
    <b>Response</b>
    <br>
    200 - JSON Example:<br>
    <code>
        {<br>
        'username': 'DarkLord',<br>
        'name': 'Darth Vader',<br>
        'email': '[email protected],<br>
        'isLecturer': 'True',<br>
        'seToken': 'xxxxxx-xxxxx-xxxxx-xxxxxx',<br>
        'avatar_url': 'http://location.git.com/somthing'<br>
        'isFirstLogin': False,<br>
        'campuses_id_list': [{<br>
                            'master_user_id': 111,<br>
                            'id': 5629499534213120,<br>
                            'email_ending': "@post.jce.ac.il",<br>
                            'avatar_url': "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg",<br>
                            'title': "JCE"
            }],<br>
        'courses_id_list': ['a','b','c']<br>
        }
    </code>
    <br>
    403 - No User Found
    """
    if token is None:
        return no_content("Token Is Empty, No User Found")

    query = User.all()
    query.filter("seToken =", token)

    for u in query.run(limit=5):
        for index, c in enumerate(u.campuses_id_list):
            c = json.loads(Campus.get_by_id(int(c)).to_JSON())
            u.campuses_id_list[index] = c

        return Response(response=u.to_JSON(),
                        status=200,
                        mimetype="application/json")  # Real response!

    return no_content("No User Found")
开发者ID:jce-il,项目名称:SE-Hub,代码行数:55,代码来源:UserRoutes.py

示例6: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
 def post(self):
     arg_username = self.request.get('username')
     arg_password = self.request.get('password')
     hashed_pass = hash_password(arg_password)
     existing_user = User.all().filter('username = ', arg_username).get()
     if existing_user is None:
         user = User(username=arg_username, hashed_pass=hashed_pass).put()
         return self.redirect("/")
     else:
         context = {
             'exists':True
         }
         return self.response.out.write(render_template('signup.html', context))
开发者ID:bahar,项目名称:movie-collection,代码行数:15,代码来源:SignupHandler.py

示例7: existing_avatars

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
def existing_avatars(dir):
    avatars = []
    if dir == "team":
        from models.Team import Team
        teams = Team.all()
        for team in teams:
            if team.avatar is not None and len(team.members) > 0:
                avatars.append(team.avatar)
    else:
        from models.User import User
        users = User.all()
        for user in users:
            if user.avatar is not None:
                avatars.append(user.avatar)
    return avatars
开发者ID:moloch--,项目名称:RootTheBox,代码行数:17,代码来源:XSSImageCheck.py

示例8: get_new_avatar

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
def get_new_avatar(dir, forceteam=False):
    avatar = default_avatar(dir)
    avatars = filter_avatars(dir)
    if len(avatars) == 0:
        return avatar
    if dir == 'team' or forceteam:
        from models.Team import Team
        cmplist = Team.all()
    elif dir == 'user':
        from models.User import User
        cmplist = User.all()
    else:
        from models.Box import Box
        cmplist = Box.all()
    dblist = []
    for item in cmplist:
        if item._avatar:
            dblist.append(item._avatar)
    for image in avatars:
        if not image in dblist:
            return image
    return avatars[randint(0, len(avatars)-1)]
开发者ID:moloch--,项目名称:RootTheBox,代码行数:24,代码来源:XSSImageCheck.py

示例9: get

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
 def get(self):
   arg_method = self.request.get('method')
   user = get_current_user()
   if user:
       grab_collections(user)
   
   templ_vars = { 'user':user }
   if not arg_method:
     return self.response.out.write(render_template('root.html', templ_vars))
   
   if arg_method == 'delete':
     arg_what = self.request.get('what')
     if not arg_what:
       return self.request.out.write('no what specified.')
     
     if arg_what == 'users':
       all_users = User.all()
       for user in all_users:
         user.delete()
       return self.redirect('/')
       
     if arg_what == 'collections':
       all_colls = MovieCollection.all()
       for col in all_colls:
         col.delete()
       return self.redirect('/')
     
     if arg_what == 'movies':
       movies = Movie.all()
       for movie in movies:
         movie.delete()
       return self.redirect('/')
     
     if arg_what == 'user_session':
         get_current_session().terminate()
         return self.redirect('/')
     return self.response.out.write(' no valid what')
   
   return self.response.out.write(' no valid method')
开发者ID:bahar,项目名称:movie-collection,代码行数:41,代码来源:RootHandler.py

示例10: oauth

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import all [as 别名]
def oauth(oauth_token):
    if oauth_token is None:
        return render_template("index.html", messages={'error': 'OAuth Fail'})
    try:
        response = requests.get("https://api.github.com/user?access_token=" + oauth_token)
        user_data = json.loads(response.content)
        response = requests.get("https://api.github.com/user/emails?access_token=" + oauth_token)
        userEmails = json.loads(response.content)
    except Exception:
        return "<h1>Max Retries connection To Github</h1><p>github has aborted connection due to to many retries. you need to wait</p>"

    resault = User.all()
    resault.filter("username =", str(user_data["login"]))

    print user_data["login"]

    for u in resault.run():
        print "Exists!!!"
        u.seToken = str(uuid.uuid4())
        u.accessToken = oauth_token
        u.put()
        return cookieMonster(u.seToken)

    tempName = ";"

    if 'email' in user_data:
        if user_data["email"] == "":
            for email in userEmails:
                if email["primary"] and email["verified"]:
                    tempEmail = email["email"]
    else:
        tempEmail = user_data["email"]

    user = User(username=user_data["login"], name=tempName, avatar_url=user_data["avatar_url"], email=tempEmail, isLecturer=False, accessToken=oauth_token, seToken=str(uuid.uuid4()))
    db.put(user)
    db.save
    return cookieMonster(user.seToken)
开发者ID:jce-il,项目名称:SE-Hub,代码行数:39,代码来源:API.py


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