mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-29 04:09:07 -04:00
Allow a platform admin user to set flexible data retention for a service for a specified notification type.
Still a work in progress
This commit is contained in:
@@ -86,6 +86,7 @@ def service_settings(service_id):
|
||||
)
|
||||
|
||||
free_sms_fragment_limit = billing_api_client.get_free_sms_fragment_limit_for_year(service_id)
|
||||
data_retention = service_api_client.get_service_data_retention(service_id)
|
||||
|
||||
return render_template(
|
||||
'views/service-settings.html',
|
||||
@@ -104,6 +105,7 @@ def service_settings(service_id):
|
||||
free_sms_fragment_limit=free_sms_fragment_limit,
|
||||
prefix_sms=current_service['prefix_sms'],
|
||||
organisation=organisation,
|
||||
data_retention=data_retention,
|
||||
)
|
||||
|
||||
|
||||
@@ -1008,6 +1010,18 @@ def branding_request(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/set-data-retention", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_is_platform_admin
|
||||
def set_data_retention(service_id):
|
||||
results = service_api_client.get_service_data_retention(service_id)
|
||||
print("DATA RETENTION: ", results[0])
|
||||
return render_template(
|
||||
'views/service-settings/set-data-retention.html',
|
||||
data_retentions=results
|
||||
)
|
||||
|
||||
|
||||
def get_branding_as_value_and_label(email_branding):
|
||||
return [
|
||||
(branding['id'], branding['name'])
|
||||
|
||||
@@ -480,3 +480,23 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
"updated_by_id": user_id
|
||||
}
|
||||
return self.post("/service/{}/delivery-receipt-api".format(service_id), data)
|
||||
|
||||
def create_service_data_retention(self, service_id, notification_type, days_of_retention):
|
||||
data = {
|
||||
"notification_type": notification_type,
|
||||
"days_of_retention": days_of_retention
|
||||
}
|
||||
|
||||
return self.post("/service/{}/data-retention".format(service_id), data)
|
||||
|
||||
def update_service_data_retention(self, service_id, data_retention_id, days_of_retention):
|
||||
data = {
|
||||
"days_of_retention": days_of_retention
|
||||
}
|
||||
return self.post("/service/{}/data-retention/{}".format(service_id, data_retention_id), data)
|
||||
|
||||
def get_service_data_retention(self, service_id):
|
||||
return self.get("/service/{}/data-retention".format(service_id))
|
||||
|
||||
def get_service_data_retention_by_id(self, service_id, data_retention_id):
|
||||
return self.get("service/{}/data-retention/{}".format(service_id, data_retention_id))
|
||||
|
||||
@@ -320,6 +320,11 @@
|
||||
{{ text_field(letter_branding) }}
|
||||
{{ edit_field('Change', url_for('.set_letter_branding', service_id=current_service.id)) }}
|
||||
{% endcall %}
|
||||
{% call row() %}
|
||||
{{ text_field('Data Retention')}}
|
||||
{{ text_field(data_retention[0]['notification_type']) }}
|
||||
{{ edit_field('Change', url_for('.set_data_retention', service_id=current_service.id)) }}
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
|
||||
<ul>
|
||||
|
||||
28
app/templates/views/service-settings/set-data-retention.html
Normal file
28
app/templates/views/service-settings/set-data-retention.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Data retention
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-five-sixths">
|
||||
<h1 class="heading-large">Emails</h1>
|
||||
<p>
|
||||
Add new data retention here
|
||||
</p>
|
||||
{% for item in data_retentions %}
|
||||
{{ item.notification_type }}
|
||||
{{ item.days_of_retention }}
|
||||
{% endfor %}
|
||||
{{ page_footer(
|
||||
back_link=url_for('.service_settings', service_id=current_service.id),
|
||||
back_link_text='Back to settings'
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user