mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 05:29:38 -04:00
big commit with letters removal
This commit is contained in:
@@ -79,14 +79,6 @@ class ServiceEvent(Event):
|
||||
def format_inbound_api(self):
|
||||
return 'Updated the callback for received text messages'
|
||||
|
||||
def format_letter_branding(self):
|
||||
if self.value_to is None:
|
||||
return 'Removed the logo from this service’s letters'
|
||||
return 'Updated the logo on this service’s letters'
|
||||
|
||||
def format_letter_contact_block(self):
|
||||
return 'Updated the default letter contact block for this service'
|
||||
|
||||
def format_message_limit(self):
|
||||
return (
|
||||
'{} this service’s daily message limit from {} to {}'
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
from notifications_utils.letter_timings import (
|
||||
CANCELLABLE_JOB_LETTER_STATUSES,
|
||||
get_letter_timings,
|
||||
)
|
||||
from werkzeug.utils import cached_property
|
||||
|
||||
from app.models import JSONModel, ModelList, PaginatedModelList
|
||||
@@ -51,10 +47,6 @@ class Job(JSONModel):
|
||||
def upload_type(self):
|
||||
return self._dict.get('upload_type')
|
||||
|
||||
@property
|
||||
def pdf_letter(self):
|
||||
return self.upload_type == 'letter'
|
||||
|
||||
@property
|
||||
def processing_started(self):
|
||||
if not self._dict.get('processing_started'):
|
||||
@@ -139,24 +131,11 @@ class Job(JSONModel):
|
||||
|
||||
@property
|
||||
def uncancellable_notifications(self):
|
||||
# TODO: this is redundant now
|
||||
return (
|
||||
n for n in self.all_notifications
|
||||
if n['status'] not in CANCELLABLE_JOB_LETTER_STATUSES
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def postage(self):
|
||||
# There might be no notifications if the job has only just been
|
||||
# created and the tasks haven't run yet
|
||||
try:
|
||||
return self.all_notifications[0]['postage']
|
||||
except IndexError:
|
||||
return self.template['postage']
|
||||
|
||||
@property
|
||||
def letter_timings(self):
|
||||
return get_letter_timings(self.created_at, postage=self.postage)
|
||||
|
||||
@property
|
||||
def failure_rate(self):
|
||||
if not self.notifications_delivered:
|
||||
|
||||
@@ -10,7 +10,6 @@ from app.models import (
|
||||
SortByNameMixin,
|
||||
)
|
||||
from app.notify_client.email_branding_client import email_branding_client
|
||||
from app.notify_client.letter_branding_client import letter_branding_client
|
||||
from app.notify_client.organisations_api_client import organisations_client
|
||||
|
||||
|
||||
@@ -32,7 +31,6 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
'active',
|
||||
'crown',
|
||||
'organisation_type',
|
||||
'letter_branding_id',
|
||||
'email_branding_id',
|
||||
'agreement_signed',
|
||||
'agreement_signed_at',
|
||||
@@ -167,13 +165,6 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
return self.email_branding['name']
|
||||
return 'GOV.UK'
|
||||
|
||||
@cached_property
|
||||
def letter_branding(self):
|
||||
if self.letter_branding_id:
|
||||
return letter_branding_client.get_letter_branding(
|
||||
self.letter_branding_id
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def agreement_signed_by(self):
|
||||
if self.agreement_signed_by_id:
|
||||
|
||||
@@ -18,7 +18,6 @@ from app.notify_client.email_branding_client import email_branding_client
|
||||
from app.notify_client.inbound_number_client import inbound_number_client
|
||||
from app.notify_client.invite_api_client import invite_api_client
|
||||
from app.notify_client.job_api_client import job_api_client
|
||||
from app.notify_client.letter_branding_client import letter_branding_client
|
||||
from app.notify_client.organisations_api_client import organisations_client
|
||||
from app.notify_client.service_api_client import service_api_client
|
||||
from app.notify_client.template_folder_api_client import (
|
||||
@@ -52,20 +51,17 @@ class Service(JSONModel, SortByNameMixin):
|
||||
'service_callback_api',
|
||||
'volume_email',
|
||||
'volume_sms',
|
||||
'volume_letter',
|
||||
}
|
||||
|
||||
TEMPLATE_TYPES = (
|
||||
'email',
|
||||
'sms',
|
||||
'letter',
|
||||
)
|
||||
|
||||
ALL_PERMISSIONS = TEMPLATE_TYPES + (
|
||||
'edit_folder_permissions',
|
||||
'email_auth',
|
||||
'inbound_sms',
|
||||
'international_letters',
|
||||
'international_sms',
|
||||
'upload_document',
|
||||
)
|
||||
@@ -260,7 +256,6 @@ class Service(JSONModel, SortByNameMixin):
|
||||
self.consent_to_research is not None and any((
|
||||
self.volume_email,
|
||||
self.volume_sms,
|
||||
self.volume_letter,
|
||||
))
|
||||
)
|
||||
|
||||
@@ -364,55 +359,11 @@ class Service(JSONModel, SortByNameMixin):
|
||||
self.sms_sender_is_govuk,
|
||||
))
|
||||
|
||||
@cached_property
|
||||
def letter_contact_details(self):
|
||||
return service_api_client.get_letter_contacts(self.id)
|
||||
|
||||
@property
|
||||
def count_letter_contact_details(self):
|
||||
return len(self.letter_contact_details)
|
||||
|
||||
@property
|
||||
def default_letter_contact_block(self):
|
||||
return next(
|
||||
(
|
||||
letter_contact_block
|
||||
for letter_contact_block in self.letter_contact_details
|
||||
if letter_contact_block['is_default']
|
||||
), None
|
||||
)
|
||||
|
||||
@property
|
||||
def default_letter_contact_block_html(self):
|
||||
# import in the function to prevent cyclical imports
|
||||
from app import nl2br
|
||||
|
||||
if self.default_letter_contact_block:
|
||||
return nl2br(self.default_letter_contact_block['contact_block'])
|
||||
return ''
|
||||
|
||||
def edit_letter_contact_block(self, id, contact_block, is_default):
|
||||
service_api_client.update_letter_contact(
|
||||
self.id, letter_contact_id=id, contact_block=contact_block, is_default=is_default,
|
||||
)
|
||||
|
||||
def remove_default_letter_contact_block(self):
|
||||
if self.default_letter_contact_block:
|
||||
self.edit_letter_contact_block(
|
||||
self.default_letter_contact_block['id'],
|
||||
self.default_letter_contact_block['contact_block'],
|
||||
is_default=False,
|
||||
)
|
||||
|
||||
def get_letter_contact_block(self, id):
|
||||
return service_api_client.get_letter_contact(self.id, id)
|
||||
|
||||
@property
|
||||
def volumes(self):
|
||||
return sum(filter(None, (
|
||||
self.volume_email,
|
||||
self.volume_sms,
|
||||
self.volume_letter,
|
||||
)))
|
||||
|
||||
@property
|
||||
@@ -465,26 +416,10 @@ class Service(JSONModel, SortByNameMixin):
|
||||
return 'GOV.UK'
|
||||
return self.email_branding['name']
|
||||
|
||||
@cached_property
|
||||
def letter_branding_name(self):
|
||||
if self.letter_branding is None:
|
||||
return 'no'
|
||||
return self.letter_branding['name']
|
||||
|
||||
@property
|
||||
def needs_to_change_email_branding(self):
|
||||
return self.email_branding_id is None and self.organisation_type != Organisation.TYPE_CENTRAL
|
||||
|
||||
@property
|
||||
def letter_branding_id(self):
|
||||
return self._dict['letter_branding']
|
||||
|
||||
@cached_property
|
||||
def letter_branding(self):
|
||||
if self.letter_branding_id:
|
||||
return letter_branding_client.get_letter_branding(self.letter_branding_id)
|
||||
return None
|
||||
|
||||
@cached_property
|
||||
def organisation(self):
|
||||
return Organisation.from_id(self.organisation_id)
|
||||
@@ -592,26 +527,6 @@ class Service(JSONModel, SortByNameMixin):
|
||||
}
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def returned_letter_statistics(self):
|
||||
return service_api_client.get_returned_letter_statistics(self.id)
|
||||
|
||||
@cached_property
|
||||
def returned_letter_summary(self):
|
||||
return service_api_client.get_returned_letter_summary(self.id)
|
||||
|
||||
@property
|
||||
def count_of_returned_letters_in_last_7_days(self):
|
||||
return self.returned_letter_statistics['returned_letter_count']
|
||||
|
||||
@property
|
||||
def date_of_most_recent_returned_letter_report(self):
|
||||
return self.returned_letter_statistics['most_recent_report']
|
||||
|
||||
@property
|
||||
def has_returned_letters(self):
|
||||
return bool(self.date_of_most_recent_returned_letter_report)
|
||||
|
||||
@property
|
||||
def contact_lists(self):
|
||||
return ContactLists(self.id)
|
||||
|
||||
Reference in New Issue
Block a user