mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:45:32 -04:00
Merge pull request #928 from GSA/927-fix-math-on-dashboard
927 - Updates to math in Dashboard area
This commit is contained in:
@@ -284,6 +284,7 @@ def init_app(application):
|
|||||||
|
|
||||||
@application.context_processor
|
@application.context_processor
|
||||||
def _attach_current_global_daily_messages():
|
def _attach_current_global_daily_messages():
|
||||||
|
global_limit = 0
|
||||||
remaining_global_messages = 0
|
remaining_global_messages = 0
|
||||||
if current_app:
|
if current_app:
|
||||||
if request.view_args:
|
if request.view_args:
|
||||||
@@ -301,7 +302,10 @@ def init_app(application):
|
|||||||
remaining_global_messages = global_limit - global_messages_count.get(
|
remaining_global_messages = global_limit - global_messages_count.get(
|
||||||
"count"
|
"count"
|
||||||
)
|
)
|
||||||
return {"daily_global_messages_remaining": remaining_global_messages}
|
return {
|
||||||
|
"global_message_limit": global_limit,
|
||||||
|
"daily_global_messages_remaining": remaining_global_messages,
|
||||||
|
}
|
||||||
|
|
||||||
@application.before_request
|
@application.before_request
|
||||||
def record_start_time():
|
def record_start_time():
|
||||||
|
|||||||
9
app/assets/javascripts/date.js
Normal file
9
app/assets/javascripts/date.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
(function (window) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Show the current year
|
||||||
|
document.getElementById("current-year").innerHTML = new Date().getFullYear();
|
||||||
|
|
||||||
|
|
||||||
|
})(window);
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ big_number(40000 - sms_allowance_remaining, smaller=True) }}</td>
|
<td>{{ big_number(sms_sent, smaller=True) }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if sms_cost %}
|
{% if sms_cost %}
|
||||||
{{ big_number(
|
{{ big_number(
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ 5000 - daily_global_messages_remaining }}</td>
|
<td>{{ global_message_limit - daily_global_messages_remaining }}</td>
|
||||||
<td>
|
<td>
|
||||||
{{ daily_global_messages_remaining }}
|
{{ daily_global_messages_remaining }}
|
||||||
</td>
|
</td>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% if current_user.has_permissions('manage_service') %}
|
{% if current_user.has_permissions('manage_service') %}
|
||||||
<h3 class='margin-bottom-0'>2023</h3>
|
<h3 class='margin-bottom-0' id="current-year"></h3>
|
||||||
{{ ajax_block(partials, updates_url, 'usage') }}
|
{{ ajax_block(partials, updates_url, 'usage') }}
|
||||||
{{ show_more(
|
{{ show_more(
|
||||||
url_for(".usage", service_id=current_service['id']),
|
url_for(".usage", service_id=current_service['id']),
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<div class='grid-col-12'>
|
<div class='grid-col-12'>
|
||||||
<h2 class="heading-small margin-bottom-1">Daily messages across all services</h2>
|
<h2 class="heading-small margin-bottom-1">Daily messages across all services</h2>
|
||||||
<p class="margin-0">You have sent {{ 5000 - daily_global_messages_remaining }} of your 5000 daily messages allowance.</p>
|
<p class="margin-0">You have sent {{ global_message_limit - daily_global_messages_remaining }} of your {{ global_message_limit }} daily messages allowance.</p>
|
||||||
<p class="margin-0"></p>You have {{ daily_global_messages_remaining }} messages remaining.</p>
|
<p class="margin-0"></p>You have {{ daily_global_messages_remaining }} messages remaining.</p>
|
||||||
<h2 class='heading-small margin-bottom-1'>Text messages</h2>
|
<h2 class='heading-small margin-bottom-1'>Text messages</h2>
|
||||||
<div class="keyline-block">
|
<div class="keyline-block">
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ const javascripts = () => {
|
|||||||
paths.src + 'javascripts/errorBanner.js',
|
paths.src + 'javascripts/errorBanner.js',
|
||||||
paths.src + 'javascripts/homepage.js',
|
paths.src + 'javascripts/homepage.js',
|
||||||
paths.src + 'javascripts/timeoutPopup.js',
|
paths.src + 'javascripts/timeoutPopup.js',
|
||||||
|
paths.src + 'javascripts/date.js',
|
||||||
paths.src + 'javascripts/main.js',
|
paths.src + 'javascripts/main.js',
|
||||||
])
|
])
|
||||||
.pipe(plugins.prettyerror())
|
.pipe(plugins.prettyerror())
|
||||||
|
|||||||
@@ -1517,6 +1517,7 @@ def test_breadcrumb_shows_if_service_is_suspended(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_service_dashboard_shows_usage(
|
def test_service_dashboard_shows_usage(
|
||||||
|
mocker,
|
||||||
client_request,
|
client_request,
|
||||||
service_one,
|
service_one,
|
||||||
mock_get_service_templates,
|
mock_get_service_templates,
|
||||||
@@ -1526,18 +1527,22 @@ def test_service_dashboard_shows_usage(
|
|||||||
mock_get_free_sms_fragment_limit,
|
mock_get_free_sms_fragment_limit,
|
||||||
permissions,
|
permissions,
|
||||||
):
|
):
|
||||||
|
mocker.patch(
|
||||||
|
"app.service_api_client.get_global_notification_count",
|
||||||
|
return_value={
|
||||||
|
"count": 500,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
service_one["permissions"] = permissions
|
service_one["permissions"] = permissions
|
||||||
page = client_request.get("main.service_dashboard", service_id=SERVICE_ONE_ID)
|
page = client_request.get("main.service_dashboard", service_id=SERVICE_ONE_ID)
|
||||||
|
|
||||||
assert normalize_spaces(page.select_one("[data-key=usage]").text) == (
|
table_rows = page.find_all("tbody")[0].find_all("tr")
|
||||||
"Daily Usage Remaining "
|
|
||||||
"40,000 "
|
assert len(table_rows) == 1
|
||||||
"$29.85 "
|
|
||||||
"spent on text messages"
|
assert "500" in table_rows[0].find_all("td")[0].text
|
||||||
# Disabled for pilot
|
assert "9500" in table_rows[0].find_all("td")[1].text
|
||||||
# '0 '
|
|
||||||
# 'email disabled during SMS pilot'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_service_dashboard_shows_free_allowance(
|
def test_service_dashboard_shows_free_allowance(
|
||||||
@@ -1566,4 +1571,4 @@ def test_service_dashboard_shows_free_allowance(
|
|||||||
|
|
||||||
usage_text = normalize_spaces(page.select_one("[data-key=usage]").text)
|
usage_text = normalize_spaces(page.select_one("[data-key=usage]").text)
|
||||||
assert "spent on text messages" not in usage_text
|
assert "spent on text messages" not in usage_text
|
||||||
assert "Daily Usage Remaining -209,000 249,000" in usage_text
|
assert "Daily Usage Remaining 1,000 249,000" in usage_text
|
||||||
|
|||||||
Reference in New Issue
Block a user