Make inbox page update using AJAX

Fairly self-explanatory. Uses the same pattern of breaking things up
into functions as the jobs page.
This commit is contained in:
Chris Hill-Scott
2017-07-07 15:51:59 +01:00
parent dc3f26a646
commit 5f6351762a
4 changed files with 90 additions and 39 deletions

View File

@@ -143,6 +143,23 @@ def monthly(service_id):
@user_has_permissions('view_activity', admin_override=True)
def inbox(service_id):
return render_template(
'views/dashboard/inbox.html',
partials=get_inbox_partials(service_id),
updates_url=url_for('.inbox_updates', service_id=service_id),
)
@main.route("/services/<service_id>/inbox.json")
@login_required
@user_has_permissions('view_activity', admin_override=True)
def inbox_updates(service_id):
return jsonify(get_inbox_partials(service_id))
def get_inbox_partials(service_id):
if 'inbound_sms' not in current_service['permissions']:
abort(403)
@@ -156,12 +173,12 @@ def inbox(service_id):
}:
messages_to_show.append(message)
return render_template(
'views/dashboard/inbox.html',
return {'messages': render_template(
'views/dashboard/_inbox_messages.html',
messages=messages_to_show,
count_of_messages=len(inbound_messages),
count_of_users=len(messages_to_show),
)
)}
def aggregate_usage(template_statistics, sort_key='count'):