mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Add flow for composing an alert without a template
We think that in some cases alerts will be composed in the moment, and therefore making people first create a template is: - not a good use of their time - adding some conceptual complexity which they don’t need This commit makes it possible to type some words and have them go straight into the `content` field in the database. In the future we might want to progressively enhance the radio buttons so they show on the same page (like we do with the grey buttons on the templates page).
This commit is contained in:
@@ -13,6 +13,8 @@ from app.main import main
|
||||
from app.main.forms import (
|
||||
BroadcastAreaForm,
|
||||
BroadcastAreaFormWithSelectAll,
|
||||
BroadcastTemplateForm,
|
||||
NewBroadcastForm,
|
||||
SearchByNameForm,
|
||||
)
|
||||
from app.models.broadcast_message import BroadcastMessage, BroadcastMessages
|
||||
@@ -71,6 +73,53 @@ def get_broadcast_dashboard_partials(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/new-broadcast', methods=['GET', 'POST'])
|
||||
@user_has_permissions('send_messages')
|
||||
@service_has_permission('broadcast')
|
||||
def new_broadcast(service_id):
|
||||
form = NewBroadcastForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.use_template:
|
||||
return redirect(url_for(
|
||||
'.choose_template',
|
||||
service_id=current_service.id,
|
||||
))
|
||||
return redirect(url_for(
|
||||
'.write_new_broadcast',
|
||||
service_id=current_service.id,
|
||||
))
|
||||
|
||||
return render_template(
|
||||
'views/broadcast/new-broadcast.html',
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/write-new-broadcast', methods=['GET', 'POST'])
|
||||
@user_has_permissions('send_messages')
|
||||
@service_has_permission('broadcast')
|
||||
def write_new_broadcast(service_id):
|
||||
form = BroadcastTemplateForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
broadcast_message = BroadcastMessage.create_from_content(
|
||||
service_id=current_service.id,
|
||||
content=form.template_content.data,
|
||||
reference=form.name.data,
|
||||
)
|
||||
return redirect(url_for(
|
||||
'.preview_broadcast_areas',
|
||||
service_id=current_service.id,
|
||||
broadcast_message_id=broadcast_message.id,
|
||||
))
|
||||
|
||||
return render_template(
|
||||
'views/broadcast/write-new-broadcast.html',
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/new-broadcast/<uuid:template_id>')
|
||||
@user_has_permissions('send_messages')
|
||||
@service_has_permission('broadcast')
|
||||
|
||||
Reference in New Issue
Block a user