use new letter branding instead of dvla organisation id

new code is copied stylistically from the email branding patterns.
Instead of `service.dvla_organisation`, there's now
`service.letter_branding` and `service.letter_branding_id`. However,
unlike email branding we're not currently showing a preview of the
logo. That can come later when we work out how we want to do it.
This commit is contained in:
Leo Hemsted
2019-02-01 16:34:54 +00:00
parent 0e20ca44a3
commit a1caf77b0e
7 changed files with 49 additions and 19 deletions

View File

@@ -1,10 +1,24 @@
from app.notify_client import NotifyAdminAPIClient
from app.notify_client import NotifyAdminAPIClient, cache
class LetterBrandingClient(NotifyAdminAPIClient):
def get_letter_branding(self):
return self.get(url='/dvla_organisations')
@cache.set('letter_branding-{branding_id}')
def get_letter_branding(self, branding_id):
return self.get(url='/letter-branding/{}'.format(branding_id))
@cache.set('letter_branding')
def get_all_letter_branding(self, sort_key=None):
brandings = self.get(url='/letter-branding')
if sort_key and sort_key in brandings[0]:
brandings.sort(key=lambda branding: branding[sort_key].lower())
return brandings
def get_letter_branding_id_for_domain(self, domain):
for branding in self.get_all_letter_branding():
if domain and branding.get('domain') == domain:
return branding['id']
return None
def create_letter_branding(self, filename, name, domain):
data = {

View File

@@ -75,6 +75,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
'sms_sender',
'created_by',
'branding',
'letter_branding',
'email_branding',
'letter_contact_block',
'dvla_organisation',