本文整理汇总了Python中users.User.getReactions方法的典型用法代码示例。如果您正苦于以下问题:Python User.getReactions方法的具体用法?Python User.getReactions怎么用?Python User.getReactions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.getReactions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: managereactions_page
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import getReactions [as 别名]
def managereactions_page():
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.config = app.config
user.get('uid', verify, g.rdb_conn)
data = startData(user)
data['active'] = 'dashboard'
data['url'] = '/dashboard/reactions/'
data['js_bottom'] = [ 'member/reactions.js' ]
tmpl = 'member/reactions.html'
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
pass
data['reactions'] = user.getReactions(g.rdb_conn)
if len(data['reactions']) < 1:
data['reacts'] = False
else:
data['reacts'] = True
page = render_template(tmpl, data=data)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
示例2: dashboard_page
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import getReactions [as 别名]
def dashboard_page():
''' Dashboard: Generate the Welcome/Status page for the dashboard '''
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
data = startData(user)
data['active'] = 'dashboard'
data['url'] = '/dashboard'
data['js_bottom'].append("member/screen-o-death.js")
data['js_bottom'].append("member/screen-o-death-chart.js")
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
page = render_template('member/mod-subscription.html', data=data)
else:
data['monitors'] = user.getMonitors(g.rdb_conn)
data['reactions'] = user.getReactions(g.rdb_conn)
data['monevents'] = user.getEvents(g.rdb_conn)
data['moneventsnum'] = len(data['monevents'])
data['monstats'] = {'true': 0,
'unknown': 0,
'false': 0}
for key in data['monitors'].keys():
if "true" in data['monitors'][key]['status']:
data['monstats']['true'] = data[
'monstats']['true'] + 1
elif "false" in data['monitors'][key]['status']:
data['monstats']['false'] = data['monstats']['false'] + 1
else:
data['monstats']['unknown'] = data[
'monstats']['unknown'] + 1
# If there are no monitors print a welcome message
if len(data['monitors']) < 1 and len(data['reactions']) < 1:
data['welcome'] = True
else:
data['welcome'] = False
if len(data['monitors']) < 1:
data['mons'] = False
else:
data['mons'] = True
if len(data['reactions']) < 1:
data['reacts'] = False
else:
data['reacts'] = True
from generalforms import subscribe
form = subscribe.AddPackForm(request.form)
page = render_template(
'member/screen-o-death.html', data=data, form=form)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
示例3: monitors_page
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import getReactions [as 别名]
def monitors_page():
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.config = app.config
user.get('uid', verify, g.rdb_conn)
data = startData(user)
data['active'] = 'dashboard'
data['url'] = '/dashboard/monitors/'
data['monitor_list'] = app.config['MONITORS']
tmpl = 'monitors/index.html'
data['js_bottom'] = ['monitors/monitorlist.js',]
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
pass
data['monitors'] = user.getMonitors(g.rdb_conn)
data['reactions'] = user.getReactions(g.rdb_conn)
# If there are no monitors print a welcome message
if len(data['monitors']) < 1 and len(data['reactions']) < 1:
data['welcome'] = True
else:
data['welcome'] = False
if len(data['monitors']) < 1:
data['mons'] = False
else:
data['mons'] = True
if len(data['reactions']) < 1:
data['reacts'] = False
else:
data['reacts'] = True
page = render_template(tmpl, data=data)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
示例4: addcheck_page
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import getReactions [as 别名]
def addcheck_page(cname):
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
data = startData(user)
data['active'] = 'dashboard'
data['url'] = '/dashboard/monitors/' + cname
tmpl = 'monitors/' + cname + '.html'
data['js_bottom'] = ['monitors/monitorlist.js', 'monitors/base.js', 'monitors/' + cname + '.js']
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
# Get list of reactions and validate that there are some
data['reactions'] = user.getReactions(g.rdb_conn)
# Proces the form
cform = __import__(
"monitorforms." + cname, globals(), locals(), ['CheckForm'], -1)
form = cform.CheckForm(request.form)
if form.__contains__("timer"):
form.timer.choices = data['choices']
reactchoices = []
for key in data['reactions'].keys():
reactchoices.append(
(data['reactions'][key]['id'],
data['reactions'][key]['name']))
form.reactions.choices = reactchoices
if request.method == 'POST':
if form.validate():
monitor = Monitor()
monitor.name = form.name.data
monitor.ctype = cname
monitor.uid = user.uid
monitor.status = "queued"
monitor.url = None
tmpdata = {}
for item in form.__iter__():
tmpdata[item.name] = item.data
monitor.data = tmpdata
# Check if the user already exceeds their limit
if monitor.count(user.uid, g.rdb_conn) < data['limit']:
# Create the monitor if all checks out
results = monitor.createMonitor(g.rdb_conn)
else:
results = "toomany"
if results == "exists":
print("/dashboard/monitors/{0} - \
Monitor already exists".format(cname))
flash('{0} seems to already exist. \
Try using a different name.'.format(
monitor.name), 'danger')
elif results is False:
print("/dashboard/monitors/{0} - \
Monitor creation failed".format(cname))
flash('Could not create monitor.', 'danger')
elif results == 'toomany':
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Too many health checks',
1)
flash('You have too many monitors. \
Please upgrade your plan or clean \
up old ones.', 'danger')
print("/dashboard/monitors/{0} - \
Monitor creation failed: toomany".format(cname))
else:
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Monitor Added', 1)
print("/dashboard/monitors/%s - \
Monitor creation successful") % cname
flash('Monitor "{0}" successfully added.'.format(
monitor.name), 'success')
newmonitor = Monitor()
newmonitor.get(results, g.rdb_conn)
if newmonitor.uid == user.uid:
data['monitor'] = {
'cid': newmonitor.cid,
'name': newmonitor.name,
'uid': newmonitor.uid,
'ctype': newmonitor.ctype,
'url': newmonitor.url,
'data': newmonitor.data
}
else:
print("/dashboard/monitors/{0} - \
Monitor creation failed: Form invalid".format(cname))
flash('Form is not valid.', 'danger')
page = render_template(tmpl, data=data, form=form)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
示例5: editcheck_page
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import getReactions [as 别名]
def editcheck_page(cname, cid):
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
data = startData(user)
data['active'] = 'dashboard'
data['url'] = '/dashboard/edit-monitors/' + cname + "/" + cid
tmpl = 'monitors/' + cname + '.html'
data['edit'] = True
data['js_bottom'] = ['monitors/base.js', 'monitors/' + cname + '.js']
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
# Get list of reactions and validate that there are some
data['reactions'] = user.getReactions(g.rdb_conn)
# Proces the form
cform = __import__(
"monitorforms." + cname, globals(), locals(), ['CheckForm'], -1)
form = cform.CheckForm(request.form)
oldmonitor = Monitor()
oldmonitor.get(cid, g.rdb_conn)
if oldmonitor.uid == user.uid:
data['monitor'] = {
'cid': oldmonitor.cid,
'name': oldmonitor.name,
'uid': oldmonitor.uid,
'ctype': oldmonitor.ctype,
'url': oldmonitor.url,
'data': oldmonitor.data
}
# Check if the form contains the timer SelectField
if form.__contains__("timer"):
form.timer.choices = data['choices']
reactchoices = []
reactdefaults = []
for key in data['reactions'].keys():
reactchoices.append(
(data['reactions'][key]['id'],
data['reactions'][key]['name']))
if data['reactions'][key]['id'] in \
data['monitor']['data']['reactions']:
reactdefaults.append(data['reactions'][key]['id'])
form.reactions.choices = reactchoices
for item in form.__iter__():
if item.type == "SelectField" or\
item.type == "SelectMultipleField":
item.default = data['monitor']['data'][item.name]
if request.method == 'POST':
if form.validate():
monitor = Monitor()
monitor.cid = cid
monitor.name = form.name.data
monitor.ctype = cname
monitor.uid = user.uid
monitor.status = "queued"
monitor.url = oldmonitor.url
tmpdata = {}
for item in form.__iter__():
tmpdata[item.name] = item.data
if item.type == "SelectField" or\
item.type == "SelectMultipleField":
item.default = item.data
monitor.data = tmpdata
data['monitor'] = {
'cid': monitor.cid,
'name': monitor.name,
'uid': monitor.uid,
'ctype': monitor.ctype,
'url': monitor.url,
'data': monitor.data
}
reactdefaults = data['monitor']['data']['reactions']
# Check if the user already exceeds their limit
if oldmonitor.uid == user.uid:
# Create the monitor if all checks out
results = monitor.editMonitor(g.rdb_conn)
else:
results = "NotYours"
print("/dashboard/edit-monitors/{0} - \
Monitor edit failed: not users".format(cname))
flash("This Monitor doesn't appear to be yours.",
'danger')
if results == "exists":
print("/dashboard/edit-monitors/{0} - \
Monitor edit failed: exists".format(cname))
flash('This monitor seems to already exist. \
Try using a different name.', 'danger')
elif results is False:
print("/dashboard/edit-monitors/{0} - Monitor \
edit failed: unknown reason".format(cname))
flash('Could not edit monitor.', 'danger')
elif results == 'toomany':
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Too many health checks',
#.........这里部分代码省略.........