Don't fallback to dvla_organisation if letter branding unset

The template preview app now accepts a null value for the `filename` 
parameter. If a service doesn't have a letter branding option set, 
previously we defaulted to their dvla_organisation (probably HM 
Government). Now, we pass through None, so that we generate letters 
without any logo or branding.
This commit is contained in:
Leo Hemsted
2019-02-13 11:58:54 +00:00
parent a8ee92cf03
commit afc5c96927
6 changed files with 10 additions and 16 deletions
+2 -3
View File
@@ -205,7 +205,7 @@ class ServiceSchema(BaseSchema):
created_by = field_for(models.Service, 'created_by', required=True)
organisation_type = field_for(models.Service, 'organisation_type')
dvla_organisation = field_for(models.Service, 'dvla_organisation')
letter_logo_filename = fields.Method(serialize='get_letter_logo_filename')
letter_logo_filename = fields.Method(dump_only=True, serialize='get_letter_logo_filename')
permissions = fields.Method("service_permissions")
email_branding = field_for(models.Service, 'email_branding')
organisation = field_for(models.Service, 'organisation')
@@ -213,8 +213,7 @@ class ServiceSchema(BaseSchema):
letter_contact_block = fields.Method(serialize="get_letter_contact")
def get_letter_logo_filename(self, service):
return service.letter_branding.filename if service.letter_branding\
else service.dvla_organisation.filename
return service.letter_branding and service.letter_branding.filename
def service_permissions(self, service):
return [p.permission for p in service.permissions]