Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-callback-receipt-1

This commit is contained in:
venusbb
2017-12-05 12:04:18 +00:00
6 changed files with 81 additions and 0 deletions

View File

@@ -172,6 +172,7 @@ def dao_create_service(service, user, service_id=None, service_permissions=None)
service.id = service_id or uuid.uuid4() # must be set now so version history model can use same id
service.active = True
service.research_mode = False
service.crown = service.organisation_type == 'central'
for permission in service_permissions:
service_permission = ServicePermission(service_id=service.id, permission=permission)

View File

@@ -249,6 +249,7 @@ class Service(db.Model, Versioned):
db.String(255),
nullable=True,
)
crown = db.Column(db.Boolean, index=False, nullable=False, default=True)
association_proxy('permissions', 'service_permission_types')

View File

@@ -178,7 +178,11 @@ def update_service(service_id):
service_going_live = fetched_service.restricted and not req_json.get('restricted', True)
current_data = dict(service_schema.dump(fetched_service).data.items())
current_data.update(request.get_json())
update_dict = service_schema.load(current_data).data
org_type = req_json.get('organisation_type', None)
if org_type:
update_dict.crown = org_type == 'central'
dao_update_service(update_dict)
# bridging code between frontend is deployed and data has not been migrated yet. Can only update current year