本文整理汇总了Python中web.verifyLogin函数的典型用法代码示例。如果您正苦于以下问题:Python verifyLogin函数的具体用法?Python verifyLogin怎么用?Python verifyLogin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了verifyLogin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: delreaction_page
def delreaction_page(rid):
'''
Dashboard Delete Domains:
This will delete a domain based on url parameters
'''
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
if user.status != "active":
pass
else:
appliedcount = 0
results = r.table('monitors').filter(
{'uid': user.uid}).run(g.rdb_conn)
for x in results:
if rid in x['data']['reactions']:
appliedcount = appliedcount + 1
if appliedcount < 1:
# Delete the Reaction
reaction = Reaction(rid)
result = reaction.deleteReaction(user.uid, rid, g.rdb_conn)
if result:
flash('Reaction was successfully deleted.', 'success')
else:
flash('Reaction was not deleted.', 'danger')
else:
flash('You must first detach this reaction \
from all monitors before deleting.', 'danger')
return redirect(url_for('member.dashboard_page'))
开发者ID:dustinrc,项目名称:cloudroutes-service,代码行数:33,代码来源:views.py
示例2: delcheck_page
def delcheck_page(cid):
'''
Dashboard Delete Checks:
This will delete health checks via the url parameters
'''
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
if user.status != "active":
pass
else:
# Delete the Monitor
monitor = Monitor(cid)
monitor.get(cid, g.rdb_conn)
result = monitor.deleteMonitor(user.uid, cid, g.rdb_conn)
if result:
print("/dashboard/delete-checks - Delete successful")
flash('Health Check was successfully deleted.', 'success')
else:
print("/dashboard/delete-checks - Delete failed")
flash('Health Check was not deleted', 'danger')
return redirect(url_for('member.dashboard_page'))
开发者ID:rbramwell,项目名称:runbook,代码行数:25,代码来源:views.py
示例3: confirm_email
def confirm_email(token):
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
if user.confirmed:
flash('Account already confirmed. Thank you.', 'success')
return redirect(url_for('member.dashboard_page'))
else:
try:
email = confirm_token(token)
if user.email == email[0]:
r.table('users').get(verify).update(
{'confirmed': True}).run(g.rdb_conn)
flash('You have confirmed your account. Thanks!', 'success')
return redirect(url_for('member.dashboard_page'))
else:
flash('The confirmation link is invalid.', 'danger')
return redirect(url_for('user.login_page'))
except:
flash('The confirmation link is invalid or has expired.',
'danger')
return redirect(url_for('user.login_page'))
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
开发者ID:madflojo,项目名称:cloudroutes-service,代码行数:27,代码来源:views.py
示例4: detailhistory_page
def detailhistory_page(cid, hid):
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/detail-history/' + hid
tmpl = 'monitors/detail-history.html'
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
monitor = Monitor()
monitor.get(cid, g.rdb_conn)
if monitor.uid == user.uid:
data['monitor'] = {
'cid': monitor.cid,
'name': monitor.name,
'ctype': monitor.ctype,
'uid': monitor.uid,
'data': monitor.data
}
data['monitor-history'] = monitor.history(
method="detail-history", hid=hid, rdb=g.rdb_conn)
else:
flash('This monitor does not belong to your user.', 'warning')
page = render_template(tmpl, data=data)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
开发者ID:rbramwell,项目名称:runbook,代码行数:34,代码来源:views.py
示例5: managereactions_page
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'))
开发者ID:Runbook,项目名称:runbook,代码行数:28,代码来源:views.py
示例6: confirm_email
def confirm_email(token):
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)
if user.confirmed:
flash("Account already confirmed. Thank you.", "success")
return redirect(url_for("member.dashboard_page"))
else:
try:
email = confirm_token(token)
if user.email == email[0]:
r.table("users").get(verify).update({"confirmed": True}).run(g.rdb_conn)
flash("You have confirmed your account. Thanks!", "success")
return redirect(url_for("member.dashboard_page"))
else:
flash("The confirmation link is invalid.", "danger")
return redirect(url_for("user.login_page"))
except:
flash("The confirmation link is invalid or has expired.", "danger")
return redirect(url_for("user.login_page"))
else:
flash("Please Login.", "warning")
return redirect(url_for("user.login_page"))
开发者ID:pathcl,项目名称:runbook,代码行数:25,代码来源:views.py
示例7: dashboard_page
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'))
开发者ID:dustinrc,项目名称:cloudroutes-service,代码行数:58,代码来源:views.py
示例8: modsub_page
def modsub_page():
'''Dashboard Modify Subscription:
This will allow a user to modify their subscription and account plan
'''
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/mod-subscription'
data['uid'] = user.uid
tmpl = 'member/mod-subscription.html'
data['js_bottom'].append('forms/subscribe.js')
form = []
from generalforms import subscribe
payment = __import__("payments." + user.payments, globals(),
locals(), ['Payments'], -1)
subscription = payment.Payments(user=user, config=app.config, rdb=g.rdb_conn)
if request.method == "POST":
if data['upgraded'] is True:
result = subscription.adjust(request)
else:
result = subscription.create(request)
if result is True:
if data['upgraded'] is True:
flash('Adjustment to subscription successful', 'success')
else:
data['upgraded'] = True
flash('Successfully Subscribed!', 'success')
newdata = startData(user)
data['limit'] = newdata['limit']
data['rlimit'] = newdata['rlimit']
data['acttype'] = newdata['acttype']
data['subplans'] = newdata['subplans']
data['cost'] = newdata['cost']
data['subscription'] = newdata['subscription']
else:
flash('Unable to adjust subscription please notify support', 'danger')
if data['upgraded'] is True:
form = subscribe.AddPackForm(request.form)
page = render_template(tmpl, data=data, form=form)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:51,代码来源:views.py
示例9: test_get_by_id
def test_get_by_id(self):
# Ensure id is correct for the current/logged in user
with self.client:
response = self.client.post('/login', data=dict(
email='[email protected]', password='password456'
), follow_redirects=True)
print response
logged_in_user_id = verifyLogin(
app.config['SECRET_KEY'],
app.config['COOKIE_TIMEOUT'],
request.cookies
)
user = User()
user_id = user.getUID('[email protected]', g.rdb_conn)
self.assertTrue(logged_in_user_id == user_id)
开发者ID:rbramwell,项目名称:runbook,代码行数:15,代码来源:test_user.py
示例10: viewhistory_page
def viewhistory_page(cid, start, limit):
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/view-history/' + cid
tmpl = 'monitors/view-history.html'
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
monitor = Monitor()
monitor.config = app.config
monitor.get(cid, g.rdb_conn)
if monitor.uid == user.uid:
data['monitor'] = {
'cid': monitor.cid,
'name': monitor.name,
'ctype': monitor.ctype,
'uid': monitor.uid,
'data': monitor.data
}
chktime = time.time() - float(data['dataret'])
data['monitor-history-count'] = monitor.history(
method="count", time=chktime, rdb=g.rdb_conn)
data['monitor-history'] = monitor.history(
method="mon-history", time=chktime,
start=int(start), limit=int(limit), rdb=g.rdb_conn)
data['monitor-history-paging'] = []
data['monitor-history-paging-start'] = int(start)
cur = 0
while cur < data['monitor-history-count'] - 200:
cur = cur + 200
data['monitor-history-paging'].append(cur)
else:
flash('This monitor does not belong to your user.', 'warning')
page = render_template(tmpl, data=data)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:46,代码来源:views.py
示例11: checkaction_page
def checkaction_page(cid, action):
'''
Dashboard Update Checks:
This will update health checks via the url parameters
'''
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)
if user.status != "active":
pass
else:
# Update the Monitor
monitor = Monitor(cid)
monitor.config = app.config
monitor.get(cid, g.rdb_conn)
if user.uid == monitor.uid:
if action == "false":
monitor.healthcheck = "web-false"
result = monitor.webCheck(g.rdb_conn)
print("/dashboard/action-checks - Manual monitor failure")
elif action == "true":
monitor.healthcheck = "web-true"
print("/dashboard/action-checks - Manual monitor true")
result = monitor.webCheck(g.rdb_conn)
if result:
print("/dashboard/action-checks - Manual monitor queued")
flash('Health check status change is queued.', 'success')
else:
print("/dashboard/action-checks - \
Manual monitor action failed")
flash('Something went wrong. \
Could not modify health check.', 'danger')
else:
print("/dashboard/action-checks - \
Manual monitor action failed: do not own")
flash('It does not appear you own this health check.', 'danger')
return redirect(url_for('member.dashboard_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:42,代码来源:views.py
示例12: monitors_page
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'))
开发者ID:Runbook,项目名称:runbook,代码行数:42,代码来源:views.py
示例13: reactions_page
def reactions_page():
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/reactions/'
tmpl = 'reactions/index.html'
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
pass
page = render_template(tmpl, data=data)
return page
else:
return redirect(url_for('user.login_page'))
开发者ID:bshyong,项目名称:cloudroutes-service,代码行数:20,代码来源:views.py
示例14: userpref_page
def userpref_page():
'''
Dashbaord User Preferences:
This will allow a user to change user preferences, i.e. Password
'''
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'
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
# Start processing the change password form
form = ChangePassForm(request.form)
if request.method == 'POST':
if form.validate():
result = user.checkPass(form.old_password.data, g.rdb_conn)
if result:
update = user.setPass(form.password.data, g.rdb_conn)
if update:
print("/dashboard/user-preferences - Password changed")
flash('Password successfully changed.', 'success')
else:
print("/dashboard/user-preferences - \
Password change failed")
flash('Password change was unsuccessful.', 'danger')
else:
print("/login - User change password error: wrong old password")
flash('Old password does not seem valid.', 'danger')
data['url'] = '/dashboard/user-preferences'
tmpl = 'member/user-preferences.html'
page = render_template(tmpl, data=data, form=form)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
开发者ID:madflojo,项目名称:cloudroutes-service,代码行数:41,代码来源:views.py
示例15: userpref_page
def userpref_page():
'''
Dashbaord User Preferences:
This will allow a user to change user preferences, i.e. Password
'''
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'
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
# Start processing the change password form
form = ChangePassForm(request.form)
if request.method == 'POST':
if form.validate():
result = user.setPass(form.password.data, g.rdb_conn)
if result:
data['msg'] = "Password successfully changed"
print("/dashboard/user-preferences - Password changed")
data['error'] = False
else:
data['msg'] = "Password change was unsuccessful"
print("/dashboard/user-preferences - Password change failed")
data['error'] = True
data['url'] = '/dashboard/user-preferences'
tmpl = 'member/user-preferences.html'
page = render_template(tmpl, data=data, form=form)
return page
else:
return redirect(url_for('user.login_page'))
开发者ID:bshyong,项目名称:cloudroutes-service,代码行数:36,代码来源:views.py
示例16: addreaction_page
def addreaction_page(rname):
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/reactions/' + rname
tmpl = 'reactions/' + rname + '.html'
data['js_bottom'] = ['reactions/base.js', 'reactions/' + rname + '.js']
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
reform = __import__(
"reactionforms." + rname, globals(),
locals(), ['ReactForm'], -1)
form = reform.ReactForm(request.form)
if request.method == 'POST':
if form.validate():
reaction = Reaction()
reaction.name = form.name.data
reaction.trigger = form.trigger.data
reaction.frequency = form.frequency.data
reaction.uid = user.uid
reaction.rtype = rname
tmpdata = {}
for item in form.__iter__():
tmpdata[item.name] = item.data
reaction.data = tmpdata
if reaction.count(user.uid, g.rdb_conn) < data['rlimit']:
results = reaction.createReaction(g.rdb_conn)
else:
results = "toomany"
if results == "exists":
data['msg'] = "This reaction seems to already exist, try using a different name: %s" % reaction.name
print("/dashboard/reactions/%s - Reaction creation failed: exists") % rname
data['error'] = True
elif results == "edit noexists":
data['msg'] = "This reaction can not be edited as it does not exist: %s" % reaction.name
print("/dashboard/reactions/%s - Reaction edit failed: doesnt exist") % rname
data['error'] = True
elif results == "edit true":
data['msg'] = "Reaction successfully edited: %s" % reaction.name
print("/dashboard/reactions/%s - Reaction edit successful") % rname
data['error'] = False
elif results == "edit false":
data['msg'] = "Reaction not successfully edited: %s" % reaction.name
print("/dashboard/reactions/%s - Reaction edit failed: unknown") % rname
data['error'] = True
elif results == "toomany":
data['msg'] = "Could not create reaction: Too many reactions already created [%d]" % data['rlimit']
print("/dashboard/reactions/%s - Reaction creation failed: too many") % rname
data['error'] = True
elif results is False:
data['msg'] = "Could not create reaction"
print("/dashboard/reactions/%s - Reaction creation failed: unknown") % rname
data['error'] = True
else:
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Reaction Added', 1)
data['msg'] = 'Reaction "%s" successfully added' % reaction.name
print("/dashboard/reactions/%s - Reaction creation successful") % rname
data['error'] = False
else:
data['msg'] = "Form is not valid"
print("/dashboard/reactions/%s - Reaction creation failed: form invalid") % rname
data['error'] = True
page = render_template(tmpl, data=data, form=form)
return page
else:
return redirect(url_for('user.login_page'))
开发者ID:bshyong,项目名称:cloudroutes-service,代码行数:79,代码来源:views.py
示例17: addreaction_page
def addreaction_page(rname):
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/' + rname
tmpl = 'reactions/create.html'
data['js_bottom'] = ['reactions/base.js']
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
reform = __import__(
"reactionforms." + rname, globals(),
locals(), ['ReactForm'], -1)
form = reform.ReactForm(request.form)
if request.method == 'POST':
if form.validate():
reaction = Reaction()
reaction.config = app.config
reaction.name = form.name.data
reaction.trigger = form.trigger.data
reaction.frequency = form.frequency.data
reaction.uid = user.uid
reaction.rtype = rname
tmpdata = {}
for item in form.__iter__():
tmpdata[item.name] = item.data
reaction.data = tmpdata
if reaction.count(user.uid, g.rdb_conn) < data['rlimit']:
results = reaction.createReaction(g.rdb_conn)
else:
results = "toomany"
if results == "exists":
print("/dashboard/reactions/{0} - \
Reaction creation failed: exists".format(rname))
flash('{0} seems to already exist. Try using a \
different name.'.format(reaction.name), 'danger')
elif results == "edit noexists":
print("/dashboard/reactions/{0} - Reaction \
edit failed: doesn't exist".format(rname))
flash('{0} cannot be edited as it does not \
exist.'.format(reaction.name), 'danger')
elif results == "edit true":
print("/dashboard/reactions/{0} - \
Reaction edit successful".format(rname))
flash('Reaction successfully edited: {0}.'.format(
reaction.name), 'success')
elif results == "edit failed":
print("/dashboard/reactions/{0} - \
Reaction edit failed: unknown".format(rname))
flash('Reaction not successfully edited: {0}.'.format(
reaction.name), 'danger')
elif results == "toomany":
print("/dashboard/reactions/{0} - \
Reaction creation failed: too many".format(rname))
flash('Could not create reaction: \
Too many reactions already created.', 'danger')
elif results is False:
print("/dashboard/reactions/{0} - \
Reaction creation failed: unknown".format(rname))
flash('Could not create reaction.', 'danger')
else:
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Reaction Added', 1)
print("/dashboard/reactions/{0} - \
Reaction creation successful".format(rname))
flash('Reaction "{0}" successfully added.'.format(
reaction.name), 'success')
else:
print("/dashboard/reactions/{0} - \
Reaction creation failed: form invalid".format(rname))
flash('Form is not valid.', 'success')
page = render_template(tmpl, data=data, form=form)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
开发者ID:Runbook,项目名称:runbook,代码行数:88,代码来源:views.py
示例18: editreact_page
def editreact_page(rname, rid):
''' This is a generic edit page for reactions '''
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/edit-reactions/' + rname + '/' + rid
tmpl = 'reactions/create.html'
data['js_bottom'] = ['reactions/base.js', ]
data['edit'] = True
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
reform = __import__(
"reactionforms." + rname, globals(),
locals(), ['ReactForm'], -1)
form = reform.ReactForm(request.form)
reaction = Reaction()
reaction.config = app.config
# If Edit get information
reaction.get("rid", rid, g.rdb_conn)
if reaction.uid == user.uid:
data['reaction'] = {
'rid': reaction.rid,
'name': reaction.name,
'trigger': reaction.trigger,
'frequency': reaction.frequency,
'uid': reaction.uid,
'rtype': reaction.rtype,
'data': reaction.data
}
data['selects'] = []
for item in form.__iter__():
if item.type == "SelectField" or \
item.type == "SelectMultipleField":
item.default = data['reaction']['data'][item.name]
tmpl = 'reactions/create.html'
if request.method == 'POST':
if form.validate():
reaction2 = Reaction()
reaction2.config = app.config
reaction2.rid = reaction.rid
reaction2.name = form.name.data
reaction2.trigger = form.trigger.data
reaction2.frequency = form.frequency.data
reaction2.lastrun = reaction.lastrun
reaction2.uid = user.uid
reaction2.rtype = reaction.rtype
tmpdata = {}
for item in form.__iter__():
tmpdata[item.name] = item.data
if item.type == "SelectField" or\
item.type == "SelectMultipleField":
item.default = item.data
reaction2.data = tmpdata
data['reaction'] = {
'rid': reaction2.rid,
'name': reaction2.name,
'trigger': reaction2.trigger,
'frequency': reaction2.frequency,
'uid': reaction2.uid,
'rtype': reaction2.rtype,
'data': reaction2.data
}
if reaction.uid == user.uid:
results = reaction2.editReaction(g.rdb_conn)
else:
results = False
print("/dashboard/reactions/{0} - \
Reaction edit failed: not owner".format(rname))
flash("It doesn't appear that you own this reaction.",
'danger')
if results == "exists":
print("/dashboard/reactions/{0} - \
Reaction edit failed: exists".format(rname))
flash('This reaction seems to already exist. \
Try using a different name.', 'danger')
elif results == "edit noexists":
print("/dashboard/reactions/{0} - \
Reaction edit failed: exists".format(rname))
flash('This reaction can not be edited \
as it does not exist.', 'danger')
elif results == "edit true":
print("/dashboard/reactions/{0} - \
Reaction edit successful".format(rname))
flash('Reaction successfully edited.', 'success')
elif results == "edit failed":
print("/dashboard/reactions/{0} - \
Reaction edit failed: unknown".format(rname))
flash('Reaction not successfully edited.', 'danger')
elif results is False:
print("/dashboard/reactions/{0} - \
Reaction edit failed: unknown".format(rname))
#.........这里部分代码省略.........
开发者ID:Runbook,项目名称:runbook,代码行数:101,代码来源:views.py
示例19: modsub_page
def modsub_page():
'''Dashboard Modify Subscription:
This will allow a user to modify their subscription and account plan
'''
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/mod-subscription'
data['uid'] = user.uid
tmpl = 'member/mod-subscription.html'
data['js_bottom'].append('forms/subscribe.js')
form = []
headers = {
"content-type": "application/json",
"Authorization": app.config['ASSEMBLY_PRIVATE_KEY']
}
from generalforms import subscribe
if data['acttype'] == "Lite":
# Upgrade Users
if request.method == "POST" and \
"stripeToken" in request.form and "plan" in request.form:
stripeToken = request.form['stripeToken']
plan = request.form['plan']
if stripeToken:
result = None
monitor = Monitor()
payload = {
'email': user.email,
'quantity': monitor.count(user.uid, g.rdb_conn),
'card': stripeToken,
'plan': plan
}
json_payload = json.dumps(payload)
url = app.config['ASSEMBLY_PAYMENTS_URL'] + "/customers"
print ("Making request to %s") % url
try:
# Send Request to Assembly to create user and subscribe
# them to desired plan
result = requests.post(
url=url, headers=headers,
data=json_payload, verify=True)
except:
print("Critical Error making request to ASM Payments")
|
请发表评论