mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-31 03:39:19 -04:00
Work in progress, all tests passing and implemented mocks for services_dao.
This commit is contained in:
@@ -8,11 +8,11 @@ from app.main.forms import AddServiceForm
|
||||
@main.route("/add-service", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def add_service():
|
||||
# TODO fix up this
|
||||
# TODO fix up this
|
||||
form = AddServiceForm(services_dao.find_all_service_names)
|
||||
if form.validate_on_submit():
|
||||
user = users_dao.get_user_by_id(session['user_id'])
|
||||
services_dao.insert_new_service(form.service_name.data, user)
|
||||
return redirect(url_for('.dashboard', service_id=123))
|
||||
service_id = services_dao.insert_new_service(form.service_name.data, user)
|
||||
return redirect(url_for('main.service_dashboard', service_id=service_id))
|
||||
else:
|
||||
return render_template('views/add-service.html', form=form)
|
||||
|
||||
@@ -8,7 +8,7 @@ from ._jobs import jobs
|
||||
|
||||
@main.route("/services/<int:service_id>/dashboard")
|
||||
@login_required
|
||||
def dashboard(service_id):
|
||||
def service_dashboard(service_id):
|
||||
try:
|
||||
service = get_service_by_id(service_id)
|
||||
except HTTPError as e:
|
||||
@@ -17,7 +17,7 @@ def dashboard(service_id):
|
||||
else:
|
||||
raise e
|
||||
return render_template(
|
||||
'views/dashboard.html',
|
||||
'views/service_dashboard.html',
|
||||
jobs=jobs,
|
||||
free_text_messages_remaining=560,
|
||||
spent_this_month='0.00',
|
||||
|
||||
@@ -10,31 +10,31 @@ def index():
|
||||
|
||||
@main.route("/register-from-invite")
|
||||
@login_required
|
||||
def registerfrominvite():
|
||||
def register_from_invite():
|
||||
return render_template('views/register-from-invite.html')
|
||||
|
||||
|
||||
@main.route("/verify-mobile")
|
||||
@login_required
|
||||
def verifymobile():
|
||||
def verify_mobile():
|
||||
return render_template('views/verify-mobile.html')
|
||||
|
||||
|
||||
@main.route("/services/<int:service_id>/send-email")
|
||||
@login_required
|
||||
def sendemail(service_id):
|
||||
def send_email(service_id):
|
||||
return render_template('views/send-email.html')
|
||||
|
||||
|
||||
@main.route("/services/<int:service_id>/check-email")
|
||||
@login_required
|
||||
def checkemail(service_id):
|
||||
def check_email(service_id):
|
||||
return render_template('views/check-email.html')
|
||||
|
||||
|
||||
@main.route("/services/<int:service_id>/manage-users")
|
||||
@login_required
|
||||
def manageusers(service_id):
|
||||
def manage_users(service_id):
|
||||
return render_template('views/manage-users.html', service_id=service_id)
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ messages = [
|
||||
|
||||
@main.route("/services/<int:service_id>/jobs")
|
||||
@login_required
|
||||
def showjobs(service_id):
|
||||
def view_jobs(service_id):
|
||||
return render_template(
|
||||
'views/jobs.html',
|
||||
jobs=jobs,
|
||||
@@ -57,7 +57,7 @@ def showjobs(service_id):
|
||||
|
||||
@main.route("/services/<int:service_id>/jobs/<job_id>")
|
||||
@login_required
|
||||
def showjob(service_id, job_id):
|
||||
def view_job(service_id, job_id):
|
||||
|
||||
# TODO the uploaded file name could be part of job definition
|
||||
# so won't need to be passed on from last view via session
|
||||
@@ -86,7 +86,7 @@ def showjob(service_id, job_id):
|
||||
|
||||
@main.route("/services/<int:service_id>/jobs/<job_id>/notification/<string:notification_id>")
|
||||
@login_required
|
||||
def shownotification(service_id, job_id, notification_id):
|
||||
def view_notification(service_id, job_id, notification_id):
|
||||
return render_template(
|
||||
'views/notification.html',
|
||||
message=[
|
||||
|
||||
@@ -128,4 +128,4 @@ def confirm_delete(service_id):
|
||||
service_id=service_id
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.dashboard', service_id=service_id))
|
||||
return redirect(url_for('.service_dashboard', service_id=service_id))
|
||||
|
||||
@@ -43,7 +43,7 @@ message_templates = [
|
||||
|
||||
@main.route("/services/<int:service_id>/sms/send", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def sendsms(service_id):
|
||||
def send_sms(service_id):
|
||||
form = CsvUploadForm()
|
||||
if form.validate_on_submit():
|
||||
try:
|
||||
@@ -53,7 +53,7 @@ def sendsms(service_id):
|
||||
filename)
|
||||
csv_file.save(filepath)
|
||||
_check_file(csv_file.filename, filepath)
|
||||
return redirect(url_for('.checksms',
|
||||
return redirect(url_for('.check_sms',
|
||||
service_id=service_id,
|
||||
recipients=filename))
|
||||
except (IOError, ValueError) as e:
|
||||
@@ -63,7 +63,7 @@ def sendsms(service_id):
|
||||
if isinstance(e, ValueError):
|
||||
flash(str(e))
|
||||
os.remove(filepath)
|
||||
return redirect(url_for('.sendsms', service_id=service_id))
|
||||
return redirect(url_for('.send_sms', service_id=service_id))
|
||||
|
||||
return render_template('views/send-sms.html',
|
||||
message_templates=message_templates,
|
||||
@@ -73,7 +73,7 @@ def sendsms(service_id):
|
||||
|
||||
@main.route("/services/<int:service_id>/sms/check", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def checksms(service_id):
|
||||
def check_sms(service_id):
|
||||
if request.method == 'GET':
|
||||
filename = request.args.get('recipients')
|
||||
if not filename:
|
||||
@@ -100,10 +100,10 @@ def checksms(service_id):
|
||||
# TODO when job is created record filename in job itself
|
||||
# so downstream pages can get the original filename that way
|
||||
session[upload_id] = filename
|
||||
return redirect(url_for('main.showjob', service_id=service_id, job_id=upload_id))
|
||||
return redirect(url_for('main.view_job', service_id=service_id, job_id=upload_id))
|
||||
except:
|
||||
flash('There as a problem saving the file')
|
||||
return redirect(url_for('.checksms', recipients=filename))
|
||||
return redirect(url_for('.check_sms', recipients=filename))
|
||||
|
||||
|
||||
def _check_file(filename, filepath):
|
||||
|
||||
@@ -8,12 +8,12 @@ from app.main.forms import (
|
||||
|
||||
|
||||
@main.route("/user-profile")
|
||||
def userprofile():
|
||||
def user_profile():
|
||||
return render_template('views/user-profile.html')
|
||||
|
||||
|
||||
@main.route("/user-profile/name", methods=['GET', 'POST'])
|
||||
def userprofile_name():
|
||||
def user_profile_name():
|
||||
|
||||
form = ChangeNameForm()
|
||||
|
||||
@@ -26,11 +26,11 @@ def userprofile_name():
|
||||
form_field=form.new_name
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile'))
|
||||
return redirect(url_for('.user_profile'))
|
||||
|
||||
|
||||
@main.route("/user-profile/email", methods=['GET', 'POST'])
|
||||
def userprofile_email():
|
||||
def user_profile_email():
|
||||
|
||||
form = ChangeEmailForm()
|
||||
|
||||
@@ -43,11 +43,11 @@ def userprofile_email():
|
||||
form_field=form.email_address
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile_email_authenticate'))
|
||||
return redirect(url_for('.user_profile_email_authenticate'))
|
||||
|
||||
|
||||
@main.route("/user-profile/email/authenticate", methods=['GET', 'POST'])
|
||||
def userprofile_email_authenticate():
|
||||
def user_profile_email_authenticate():
|
||||
|
||||
form = ConfirmPasswordForm()
|
||||
|
||||
@@ -56,14 +56,14 @@ def userprofile_email_authenticate():
|
||||
'views/user-profile/authenticate.html',
|
||||
thing='email address',
|
||||
form=form,
|
||||
back_link=url_for('.userprofile_email')
|
||||
back_link=url_for('.user_profile_email')
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile_email_confirm'))
|
||||
return redirect(url_for('.user_profile_email_confirm'))
|
||||
|
||||
|
||||
@main.route("/user-profile/email/confirm", methods=['GET', 'POST'])
|
||||
def userprofile_email_confirm():
|
||||
def user_profile_email_confirm():
|
||||
|
||||
form = ConfirmEmailForm()
|
||||
|
||||
@@ -74,11 +74,11 @@ def userprofile_email_confirm():
|
||||
thing='email address'
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile'))
|
||||
return redirect(url_for('.user_profile'))
|
||||
|
||||
|
||||
@main.route("/user-profile/mobile-number", methods=['GET', 'POST'])
|
||||
def userprofile_mobile_number():
|
||||
def user_profile_mobile_number():
|
||||
|
||||
form = ChangeMobileNumberForm()
|
||||
|
||||
@@ -91,11 +91,11 @@ def userprofile_mobile_number():
|
||||
form_field=form.mobile_number
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile_mobile_number_authenticate'))
|
||||
return redirect(url_for('.user_profile_mobile_number_authenticate'))
|
||||
|
||||
|
||||
@main.route("/user-profile/mobile-number/authenticate", methods=['GET', 'POST'])
|
||||
def userprofile_mobile_number_authenticate():
|
||||
def user_profile_mobile_number_authenticate():
|
||||
|
||||
form = ConfirmPasswordForm()
|
||||
|
||||
@@ -104,14 +104,14 @@ def userprofile_mobile_number_authenticate():
|
||||
'views/user-profile/authenticate.html',
|
||||
thing='mobile number',
|
||||
form=form,
|
||||
back_link=url_for('.userprofile_mobile_number_confirm')
|
||||
back_link=url_for('.user_profile_mobile_number_confirm')
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile_mobile_number_confirm'))
|
||||
return redirect(url_for('.user_profile_mobile_number_confirm'))
|
||||
|
||||
|
||||
@main.route("/user-profile/mobile-number/confirm", methods=['GET', 'POST'])
|
||||
def userprofile_mobile_number_confirm():
|
||||
def user_profile_mobile_number_confirm():
|
||||
|
||||
form = ConfirmMobileNumberForm()
|
||||
|
||||
@@ -122,11 +122,11 @@ def userprofile_mobile_number_confirm():
|
||||
thing='mobile number'
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile'))
|
||||
return redirect(url_for('.user_profile'))
|
||||
|
||||
|
||||
@main.route("/user-profile/password", methods=['GET', 'POST'])
|
||||
def userprofile_password():
|
||||
def user_profile_password():
|
||||
|
||||
form = ChangePasswordForm()
|
||||
|
||||
@@ -136,4 +136,4 @@ def userprofile_password():
|
||||
form=form
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.userprofile'))
|
||||
return redirect(url_for('.user_profile'))
|
||||
|
||||
Reference in New Issue
Block a user