本文整理汇总了Python中app.user.models.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.user.models.User
的用法示例。
在下文中一共展示了User.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_post
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def edit_post():
user = User.get(User.id == current_user.get_id())
post_id = request.form["id"]
content = request.form["content"]
cleaned_markdown = clean_markdown(content)
html = markdown.markdown(cleaned_markdown)
result = user.edit_post(post_id, html)
return result
示例2: report
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def report():
form = BugReportForm()
if form.validate_on_submit():
# Do Stuff
description = form.description.data
user = User.get(User.id == current_user.get_id())
result = user.file_bug_report(description)
flash(result)
return redirect(url_for("home"))
return render_template("bugreport/report.html", form=form)
示例3: comment
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def comment():
form = CommentForm(request.form)
print(request.form)
if form.validate():
user = User.get(User.id == current_user.get_id())
comment_text = form.comment.data
post_id = form.post_id.data
result = user.comment(post_id, comment_text)
return result
return form.errors
示例4: user
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def user(username):
try:
other_user = User.get(User.username == username)
bio_form = BiographyForm()
user = User.get(User.id == current_user.get_id())
other_user_email = other_user.email
other_user_email_hash = gravatar_hash(other_user_email)
gravatar = "http://www.gravatar.com/avatar/{}?s=300".format(other_user_email_hash)
data = User.view_user(username)
is_pending = user.is_pending(username)
is_friend = user.is_friend(username)
if user.username == username:
own_page = True
else:
own_page = False
print("IS PENDING:", is_pending, "IS FRIEND:", is_friend)
return render_template("user.html", user=data, is_friend=is_friend, is_pending=is_pending, own_page=own_page, gravatar=gravatar, bio_form=bio_form)
except DoesNotExist:
return render_template("error.html", title="User does not exist.", description="Please make sure the url contains a valid username.")
示例5: add_post
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def add_post():
form = PostForm(request.form)
if form.validate():
user = User.get(User.id == current_user.get_id())
md = form.post.data
cleaned_markdown = clean_markdown(md)
html = markdown.markdown(cleaned_markdown)
result = user.create_post(html)
return result
else:
return form.errors
示例6: create_bio
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def create_bio():
form = BiographyForm(request.form)
if form.validate():
user = User.get(User.id == current_user.get_id())
md = form.biography.data
cleaned_markdown = clean_markdown(md)
html = markdown.markdown(cleaned_markdown)
result = user.create_bio(html)
return result
else:
return form.errors
示例7: send_message
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def send_message():
# get form
form = MessagingForm(request.form)
if form.validate():
# Send message
print("sending")
user = User.get(User.id == current_user.get_id())
result = user.send_message(form.recipient.data, form.body.data)
return result
else:
print(form.errors)
return "Validation Error."
示例8: get_post
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def get_post(cls, post_id):
post = Post.get(Post.id == post_id)
data = [post.user.username, post.timestamp.strftime("%H:%M %d/%m/%y"), post.content]
comment_query = Comment.select().where(Comment.post == post).order_by(Comment.timestamp.asc())
comments = []
for comment in comment_query:
print(comment.__dict__)
commenter = User.get(User.id == comment.user)
comment_data = [commenter.username, comment.timestamp.strftime("%H:%M %d/%m/%y"), comment.content]
comments.append(comment_data)
data.append(comments)
data.append(post.id)
return data
示例9: login
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def login():
form = LoginForm()
if form.validate_on_submit():
try:
user = User.get(User.email == form.email.data)
except DoesNotExist:
flash("Your email or password does not exist.")
else:
if check_password_hash(user.password, form.password.data):
login_user(user)
flash("You have been logged in.")
return redirect(url_for(".index"))
else:
flash("Your email or password does not exist.")
return render_template("login.html", form=form)
示例10: friend_request
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def friend_request():
username = request.form["username"]
print("USERNAME:", username)
user = User.get(User.id == current_user.get_id())
response = user.friend_request(username)
return response
示例11: delete_post
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def delete_post():
user = User.get(User.id == current_user.get_id())
post_id = request.form["id"]
result = user.delete_post(post_id)
return result
示例12: get_posts
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def get_posts():
offset = request.form["offset"]
user = User.get(User.id == current_user.get_id())
posts = json.dumps(user.get_posts(offset=int(offset)))
return posts
示例13: people
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def people():
user = User.get(User.id == current_user.get_id())
json_people = json.dumps([friend.username for friend in user.get_friends()])
return json_people
示例14: get_messages
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def get_messages():
user = User.get(User.id == current_user.get_id())
other = User.get(User.username == request.form["other"])
json_messages = json.dumps(user.get_messages(other))
return json_messages
示例15: view_friend_requests
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get [as 别名]
def view_friend_requests():
user = User.get(User.id == current_user.get_id())
requests = user.get_friend_requests()
return render_template("view_friend_requests.html", requests=requests)