本文整理汇总了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)
示例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)
示例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
示例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)
示例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")
示例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))
示例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
示例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)]
示例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')
示例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)