mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-21 00:23:53 -04:00
Merge branch 'master' into remove-stats-from-send
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Extra CSS overlaying elements
|
||||
|
||||
#global-header-bar {
|
||||
background-color: $red;
|
||||
background-color: $govuk-blue;
|
||||
}
|
||||
|
||||
#global-header {
|
||||
@@ -174,3 +174,8 @@ details summary {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.phase-banner-beta {
|
||||
border: 0;
|
||||
margin-bottom: -$gutter + 2px;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ $path: '/static/images/';
|
||||
@import 'elements/layout';
|
||||
@import 'elements/lists';
|
||||
@import 'elements/panels';
|
||||
@import 'elements/phase-banner';
|
||||
@import 'elements/tables';
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import time
|
||||
import dateutil
|
||||
from datetime import datetime, timedelta, timezone
|
||||
@@ -21,7 +20,6 @@ from app import (
|
||||
job_api_client,
|
||||
notification_api_client,
|
||||
service_api_client,
|
||||
statistics_api_client,
|
||||
current_service,
|
||||
format_datetime_short)
|
||||
from app.main import main
|
||||
@@ -30,7 +28,7 @@ from app.utils import (
|
||||
generate_previous_next_dict,
|
||||
user_has_permissions,
|
||||
generate_notifications_csv)
|
||||
from app.statistics_utils import sum_of_statistics, statistics_by_state, add_rate_to_jobs
|
||||
from app.statistics_utils import add_rate_to_jobs
|
||||
from app.utils import get_help_argument
|
||||
|
||||
|
||||
@@ -171,9 +169,6 @@ def view_notifications(service_id, message_type):
|
||||
template_type=[message_type],
|
||||
status=filter_args.get('status'),
|
||||
limit_days=current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
|
||||
service_statistics_by_state = statistics_by_state(sum_of_statistics(
|
||||
statistics_api_client.get_statistics_for_service(service_id, limit_days=7)['data']
|
||||
))
|
||||
view_dict = dict(
|
||||
message_type=message_type,
|
||||
status=request.args.get('status')
|
||||
@@ -223,23 +218,11 @@ def view_notifications(service_id, message_type):
|
||||
message_type=message_type,
|
||||
status=request.args.get('status')
|
||||
),
|
||||
status_filters=[
|
||||
[
|
||||
item[0], item[1],
|
||||
url_for(
|
||||
'.view_notifications',
|
||||
service_id=current_service['id'],
|
||||
message_type=message_type,
|
||||
status=item[1]
|
||||
),
|
||||
service_statistics_by_state[message_type][item[0]]
|
||||
] for item in [
|
||||
['processed', 'sending,delivered,failed'],
|
||||
['sending', 'sending'],
|
||||
['delivered', 'delivered'],
|
||||
['failed', 'failed'],
|
||||
]
|
||||
]
|
||||
status_filters=get_status_filters(
|
||||
current_service,
|
||||
message_type,
|
||||
service_api_client.get_detailed_service(service_id)['data']['statistics']
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -261,6 +244,34 @@ def view_notification(service_id, job_id, notification_id):
|
||||
)
|
||||
|
||||
|
||||
def get_status_filters(service, message_type, statistics):
|
||||
stats = statistics[message_type]
|
||||
stats['sending'] = stats['requested'] - stats['delivered'] - stats['failed']
|
||||
|
||||
filters = [
|
||||
# key, label, option
|
||||
('requested', 'processed', 'sending,delivered,failed'),
|
||||
('sending', 'sending', 'sending'),
|
||||
('delivered', 'delivered', 'delivered'),
|
||||
('failed', 'failed', 'failed'),
|
||||
]
|
||||
return [
|
||||
# return list containing label, option, link, count
|
||||
(
|
||||
label,
|
||||
option,
|
||||
url_for(
|
||||
'.view_notifications',
|
||||
service_id=service['id'],
|
||||
message_type=message_type,
|
||||
status=option
|
||||
),
|
||||
stats[key]
|
||||
)
|
||||
for key, label, option in filters
|
||||
]
|
||||
|
||||
|
||||
def _get_job_counts(job, help_argument):
|
||||
return [
|
||||
(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from notifications_python_client.base import BaseAPIClient
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
|
||||
class StatisticsApiClient(BaseAPIClient):
|
||||
@@ -13,15 +12,6 @@ class StatisticsApiClient(BaseAPIClient):
|
||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
||||
|
||||
def get_statistics_for_service(self, service_id, limit_days=None):
|
||||
params = {}
|
||||
if limit_days is not None:
|
||||
params['limit_days'] = limit_days
|
||||
return self.get(
|
||||
url='/service/{}/notifications-statistics'.format(service_id),
|
||||
params=params
|
||||
)
|
||||
|
||||
def get_7_day_aggregate_for_service(self, service_id, date_from=None, week_count=None):
|
||||
params = {}
|
||||
if date_from is not None:
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
<!--[if gt IE 8]><!-->
|
||||
<link rel="stylesheet" media="screen" href="{{ asset_url('stylesheets/main.css') }}" />
|
||||
<!--<![endif]-->
|
||||
{% if current_user.is_authenticated %}
|
||||
<style>
|
||||
#global-header-bar { background-color: {{header_colour}} }
|
||||
#global-header-bar { background-color: {{header_colour}} }
|
||||
</style>
|
||||
{% endif %}
|
||||
<!--[if IE 6]>
|
||||
<link rel="stylesheet" media="screen" href="{{ asset_url('stylesheets/main-ie6.css') }}" />
|
||||
<![endif]-->
|
||||
|
||||
26
app/templates/partials/check/too_many_messages.html
Normal file
26
app/templates/partials/check/too_many_messages.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<div class="bottom-gutter">
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
<h1 class='banner-title'>
|
||||
Too many recipients
|
||||
</h1>
|
||||
<p>
|
||||
You can only send {{ current_service.message_limit }} messages per day
|
||||
{%- if current_service.restricted %}
|
||||
in <a href="{{ url_for('.trial_mode')}}">trial mode</a>
|
||||
{%- endif -%}
|
||||
.
|
||||
</p>
|
||||
<p>
|
||||
{% if statistics.emails_requested or statistics.sms_requested %}
|
||||
You can still send
|
||||
{{ current_service.message_limit - statistics.get('emails_requested', 0) - statistics.get('sms_requested', 0) }}
|
||||
messages today, but
|
||||
{% endif %}
|
||||
‘{{ original_file_name }}’ contains
|
||||
{{ count_of_recipients }} {{ recipients.recipient_column_header }}
|
||||
{%- if count_of_recipients != 1 -%}
|
||||
{{ 'es' if 'email address' == recipients.recipient_column_header else 's' }}
|
||||
{%- endif %}.
|
||||
</p>
|
||||
{% endcall %}
|
||||
</div>
|
||||
@@ -9,6 +9,13 @@
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="phase-banner-beta">
|
||||
<p>
|
||||
<strong class="phase-tag">BETA</strong>
|
||||
<span>This is a new service – your <a href="{{ url_for('main.feedback') }}">feedback</a> will help us to improve it.</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{% call banner_wrapper(type='intro') %}
|
||||
<h1 class="heading-medium">
|
||||
GOV.UK Notify makes it easy to send text messages and emails to
|
||||
|
||||
Reference in New Issue
Block a user