Instead of deleting the data in the name field just copy it to the text field.

The admin app still needs to use the name column.
Add the text field to the post data schemas.
If the text is not in the post data, then populate it with the data in the name field.
This should make the migration to text easier, and will work until we are able to update the admin app.
This commit is contained in:
Rebecca Law
2018-08-02 15:55:45 +01:00
parent 4345771547
commit c30e58eaad
4 changed files with 76 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ post_create_email_branding_schema = {
"properties": {
"colour": {"type": ["string", "null"]},
"name": {"type": ["string", "null"]},
"text": {"type": ["string", "null"]},
"logo": {"type": ["string", "null"]}
},
"required": []
@@ -17,6 +18,7 @@ post_update_email_branding_schema = {
"properties": {
"colour": {"type": ["string", "null"]},
"name": {"type": ["string", "null"]},
"text": {"type": ["string", "null"]},
"logo": {"type": ["string", "null"]}
},
"required": []

View File

@@ -37,6 +37,8 @@ def create_email_branding():
validate(data, post_create_email_branding_schema)
email_branding = EmailBranding(**data)
if not data.get('text'):
email_branding.text = email_branding.name
dao_create_email_branding(email_branding)
return jsonify(data=email_branding.serialize()), 201
@@ -49,6 +51,8 @@ def update_email_branding(email_branding_id):
validate(data, post_update_email_branding_schema)
fetched_email_branding = dao_get_email_branding_by_id(email_branding_id)
if not data.get('text') and data.get('name'):
data['text'] = data['name']
dao_update_email_branding(fetched_email_branding, **data)
return jsonify(data=fetched_email_branding.serialize()), 200