本文整理汇总了Python中flask.ext.login.current_user.id方法的典型用法代码示例。如果您正苦于以下问题:Python current_user.id方法的具体用法?Python current_user.id怎么用?Python current_user.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.ext.login.current_user
的用法示例。
在下文中一共展示了current_user.id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: searchnotif
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def searchnotif():
notification = models.Notification(user_id=current_user.id,
fulltxt=True,
vendor=escape(request.json['searchquery']),
product='',
version='')
# Checking Integrity Before Insert #
if models.Notification.query.filter_by(user_id=notification.user_id,
vendor=notification.vendor,
fulltxt=notification.fulltxt).first() is None:
models.db.session.add(notification)
models.db.session.commit()
flash('Notification Successfully Created.', 'success')
syslog.syslog(syslog.LOG_DEBUG, "New notification created by: " + current_user.email)
return redirect(url_for("notif.notiftab"))
else:
flash('Notification Already existing.', 'warning')
syslog.syslog(syslog.LOG_ERR, "Notification Already existing: " + current_user.email)
return redirect(url_for("notif.notiftab"))
示例2: verify_player
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def verify_player(payload):
s = get_serializer()
try:
user_id, aga_id = s.loads(payload)
except BadSignature:
current_app.logger.info('Verify called with invalid paylod')
abort(404)
if user_id != current_user.id:
current_app.logger.warn("Verify called for id %s, but wrong user answered, %s" % (user_id, current_user))
abort(404)
aga_info = get_aga_info(aga_id)
if aga_info is None:
current_app.logger.warn("Could not fetch AGA info for aga_id %s" % aga_id)
abort(404)
name = aga_info.get('full_name', '')
update_user_info(user_id, aga_id, name)
msg = 'Linked account with AGA #%s' % aga_id
current_app.logger.info(msg)
return redirect(url_for('ratings.myaccount'))
示例3: upuser
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def upuser(userid):
if current_user.id == userid or current_user.role == '0':
form = UserEditForm()
if form.validate_on_submit():
user = users.query.filter_by(id=userid).first()
if user is not None and user.verify_password(form.oldpassword.data):
user.password = form.password.data
db.session.add(user)
db.session.commit()
flash(u'密码更改成功!')
return render_template('useredit.html',form=form)
user = users.query.filter_by(id=userid).first()
form.username.data = user.username
form.name.data = user.name
return render_template('useredit.html',form=form)
else:
abort(403)
示例4: resource_with_id
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def resource_with_id(id):
"""
Returns a resource from the database or aborts with a
404 Not Found if it was not found.
Args:
id: The ID of the resource to retrieve.
Returns:
The specified resource.
"""
result = rad.resourceservice.search(
limit=1,
search_params={
'id': id,
'visible': True,
'is_approved': True
})
if result:
return result[0]
else:
abort(404)
示例5: news_item
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def news_item(news_id):
"""
Displays a single news post.
Args:
news_id: The ID of the news post to show.
Returns:
A templated resource information page (via news-item.html).
This template is provided with the following variables:
news: The news post to display.
"""
news_post = db.session.query(News). \
filter(News.id == news_id). \
filter(News.visible == True). \
first()
if news_post is None:
abort(404)
return render_template('news-item.html', news=news_post)
示例6: transcribe
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def transcribe(id = None, model = None):
if id is not None:
recording = recordings_model.get_recording(id)
backlink = request.args.get('next') or url_for('transcribe', model = recording.model)
if model is not None:
recording = recordings_model.get_random_recording(model)
backlink = url_for('transcribe', model = model)
return render_template('transcribe.html', recording=recording, backlink=backlink)
示例7: save_transcription
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def save_transcription():
flash('Recording was successfully transcribed')
recordings_model.add_transcription(
current_user.get_id(),
request.form['id'],
request.form['transcription'],
'native_speaker' in request.form,
'offensive_language' in request.form,
'not_a_speech' in request.form
)
return redirect(request.form['backlink'])
示例8: transcriptions
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def transcriptions(id):
return render_template('transcriptions.html', recording=recordings_model.get_recording(id))
示例9: accept_transcription
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def accept_transcription(recording, transcription):
recordings_model.set_transcription(recording, transcription)
return redirect(url_for('transcriptions', id = recording))
示例10: kaldi_worker
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def kaldi_worker():
return render_template('kaldi_worker.html', worker = {"id": None})
示例11: save_worker_description
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def save_worker_description():
if request.form.get('run_on_marathon', False):
url = os.environ.get("MARATHON_URL", None)
login = os.environ.get("MARATHON_LOGIN", None)
password = os.environ.get("MARATHON_PASSWORD", None)
config = {
"id": request.form["id"],
"model_url": request.form["model_url"],
"cpu": request.form["cpu"],
"mem": request.form["mem"],
"master_addr": os.environ.get("MASTER_ADDR", None),
"recordings_saver_addr": os.environ.get("RECORDINGS_SAVER_ADDR", None)
}
if not run_worker_on_marathon(url, login, password, config):
flash('Worker wasn\'t started successfully')
return redirect(url_for('kaldi_worker'))
flash('Worker\'s description was successfully saved')
worker_types_model.edit_worker(
request.form['id'],
request.form['name'],
request.form['description'],
request.form.getlist("lm-id[]"),
request.form.getlist("lm-name[]")
)
return redirect(url_for('worker_types'))
示例12: login_google
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def login_google(token, userinfo, **params):
login_user(users_model.upsert_user(userinfo))
identity = Identity(userinfo['id'])
identity_changed.send(app, identity = identity)
return redirect(url_for('index'))
示例13: load_user
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def load_user(id):
return users_model.get_user(id)
示例14: on_identity_loaded
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def on_identity_loaded(sender, identity):
identity.user = current_user
if hasattr(current_user, 'id'):
identity.provides.add(UserNeed(current_user.id))
if hasattr(current_user, 'admin') and current_user.admin:
identity.provides.add(RoleNeed('admin'))
示例15: notiftab
# 需要导入模块: from flask.ext.login import current_user [as 别名]
# 或者: from flask.ext.login.current_user import id [as 别名]
def notiftab():
jnotif = []
dic = {}
limit = request.args.get('limit')
offset = request.args.get('offset')
sort = request.args.get('sort')
order = request.args.get('order')
if order == 'desc':
notif_list = models.Notification.query.filter_by(user_id=current_user.id).order_by(desc(sort)).limit(
limit).offset(offset).all()
else:
notif_list = models.Notification.query.filter_by(user_id=current_user.id).order_by(sort).limit(limit).offset(
offset).all()
num = models.Notification.query.filter_by(user_id=current_user.id).count()
for notif in notif_list:
dnotif = {'id': notif.id,
'fulltxt': notif.fulltxt,
'vendor': notif.vendor,
'product': notif.product,
'version': notif.version
}
jnotif.append(dnotif)
dic['total'] = num
dic['rows'] = jnotif
return jsonify(dic)