Merge pull request #2896 from alphagov/remove-domains-yml

Use organisations from database rather than YAML file
This commit is contained in:
Chris Hill-Scott
2019-04-12 16:37:15 +01:00
committed by GitHub
35 changed files with 438 additions and 5294 deletions

View File

@@ -14,33 +14,25 @@ class EmailBrandingClient(NotifyAdminAPIClient):
brandings.sort(key=lambda branding: branding[sort_key].lower())
return brandings
def get_email_branding_id_for_domain(self, domain):
for branding in self.get_all_email_branding():
if domain and branding.get('domain') == domain:
return branding['id']
return None
@cache.delete('email_branding')
def create_email_branding(self, logo, name, text, colour, domain, brand_type):
def create_email_branding(self, logo, name, text, colour, brand_type):
data = {
"logo": logo,
"name": name,
"text": text,
"colour": colour,
"domain": domain,
"brand_type": brand_type
}
return self.post(url="/email-branding", data=data)
@cache.delete('email_branding')
@cache.delete('email_branding-{branding_id}')
def update_email_branding(self, branding_id, logo, name, text, colour, domain, brand_type):
def update_email_branding(self, branding_id, logo, name, text, colour, brand_type):
data = {
"logo": logo,
"name": name,
"text": text,
"colour": colour,
"domain": domain,
"brand_type": brand_type
}
return self.post(url="/email-branding/{}".format(branding_id), data=data)

View File

@@ -12,22 +12,19 @@ class LetterBrandingClient(NotifyAdminAPIClient):
return self.get(url='/letter-branding')
@cache.delete('letter_branding')
def create_letter_branding(self, filename, name, domain):
def create_letter_branding(self, filename, name):
data = {
"filename": filename,
"name": name,
"domain": domain,
}
return self.post(url="/letter-branding", data=data)
@cache.delete('letter_branding')
@cache.delete('letter_branding-{branding_id}')
def update_letter_branding(self, branding_id, filename, name, domain):
def update_letter_branding(self, branding_id, filename, name):
data = {
"filename": filename,
"name": name,
"domain": domain,
}
return self.post(url="/letter-branding/{}".format(branding_id), data=data)

View File

@@ -1,3 +1,5 @@
from notifications_python_client.errors import HTTPError
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
@@ -9,6 +11,16 @@ class OrganisationsClient(NotifyAdminAPIClient):
def get_organisation(self, org_id):
return self.get(url='/organisations/{}'.format(org_id))
def get_organisation_by_domain(self, domain):
try:
return self.get(
url='/organisations/by-domain?domain={}'.format(domain),
)
except HTTPError as error:
if error.status_code == 404:
return None
raise error
def create_organisation(self, name):
data = {
"name": name