mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 07:46:06 -04:00
Remove deprecated fields from orgs and services
Once the admin app has started using the new fields returned in https://github.com/alphagov/notifications-api/pull/2539 these fields won’t be needed any more.
This commit is contained in:
@@ -507,35 +507,10 @@ def get_orgs_and_services(user):
|
|||||||
{
|
{
|
||||||
'name': org.name,
|
'name': org.name,
|
||||||
'id': org.id,
|
'id': org.id,
|
||||||
'services': [
|
|
||||||
{
|
|
||||||
'id': service.id,
|
|
||||||
'name': service.name,
|
|
||||||
'restricted': service.restricted,
|
|
||||||
}
|
|
||||||
for service in org.services
|
|
||||||
if service.active and service in user.services
|
|
||||||
],
|
|
||||||
'count_of_live_services': len(org.live_services),
|
'count_of_live_services': len(org.live_services),
|
||||||
}
|
}
|
||||||
for org in user.organisations if org.active
|
for org in user.organisations if org.active
|
||||||
],
|
],
|
||||||
'services_without_organisations': [
|
|
||||||
{
|
|
||||||
'id': service.id,
|
|
||||||
'name': service.name,
|
|
||||||
'restricted': service.restricted,
|
|
||||||
} for service in user.services
|
|
||||||
if (
|
|
||||||
service.active and
|
|
||||||
# include services that either aren't in an organisation, or are in an organisation,
|
|
||||||
# but not one that the user can see.
|
|
||||||
(
|
|
||||||
not service.organisation or
|
|
||||||
service.organisation not in user.organisations
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
'services': [
|
'services': [
|
||||||
{
|
{
|
||||||
'id': service.id,
|
'id': service.id,
|
||||||
|
|||||||
@@ -837,41 +837,20 @@ def test_get_orgs_and_services_nests_services(admin_request, sample_user):
|
|||||||
|
|
||||||
assert set(resp.keys()) == {
|
assert set(resp.keys()) == {
|
||||||
'organisations',
|
'organisations',
|
||||||
'services_without_organisations',
|
|
||||||
'services',
|
'services',
|
||||||
}
|
}
|
||||||
assert resp['organisations'] == [
|
assert resp['organisations'] == [
|
||||||
{
|
{
|
||||||
'name': org1.name,
|
'name': org1.name,
|
||||||
'id': str(org1.id),
|
'id': str(org1.id),
|
||||||
'services': [
|
|
||||||
{
|
|
||||||
'name': service1.name,
|
|
||||||
'id': str(service1.id),
|
|
||||||
'restricted': False,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': service2.name,
|
|
||||||
'id': str(service2.id),
|
|
||||||
'restricted': False,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'count_of_live_services': 2,
|
'count_of_live_services': 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': org2.name,
|
'name': org2.name,
|
||||||
'id': str(org2.id),
|
'id': str(org2.id),
|
||||||
'services': [],
|
|
||||||
'count_of_live_services': 0,
|
'count_of_live_services': 0,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
assert resp['services_without_organisations'] == [
|
|
||||||
{
|
|
||||||
'name': service3.name,
|
|
||||||
'id': str(service3.id),
|
|
||||||
'restricted': False,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
assert resp['services'] == [
|
assert resp['services'] == [
|
||||||
{
|
{
|
||||||
'name': service1.name,
|
'name': service1.name,
|
||||||
@@ -917,30 +896,15 @@ def test_get_orgs_and_services_only_returns_active(admin_request, sample_user):
|
|||||||
|
|
||||||
assert set(resp.keys()) == {
|
assert set(resp.keys()) == {
|
||||||
'organisations',
|
'organisations',
|
||||||
'services_without_organisations',
|
|
||||||
'services',
|
'services',
|
||||||
}
|
}
|
||||||
assert resp['organisations'] == [
|
assert resp['organisations'] == [
|
||||||
{
|
{
|
||||||
'name': org1.name,
|
'name': org1.name,
|
||||||
'id': str(org1.id),
|
'id': str(org1.id),
|
||||||
'services': [
|
|
||||||
{
|
|
||||||
'name': service1.name,
|
|
||||||
'id': str(service1.id),
|
|
||||||
'restricted': False,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'count_of_live_services': 1,
|
'count_of_live_services': 1,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
assert resp['services_without_organisations'] == [
|
|
||||||
{
|
|
||||||
'name': service4.name,
|
|
||||||
'id': str(service4.id),
|
|
||||||
'restricted': False,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
assert resp['services'] == [
|
assert resp['services'] == [
|
||||||
{
|
{
|
||||||
'name': service1.name,
|
'name': service1.name,
|
||||||
@@ -983,25 +947,15 @@ def test_get_orgs_and_services_only_shows_users_orgs_and_services(admin_request,
|
|||||||
|
|
||||||
assert set(resp.keys()) == {
|
assert set(resp.keys()) == {
|
||||||
'organisations',
|
'organisations',
|
||||||
'services_without_organisations',
|
|
||||||
'services',
|
'services',
|
||||||
}
|
}
|
||||||
assert resp['organisations'] == [
|
assert resp['organisations'] == [
|
||||||
{
|
{
|
||||||
'name': org2.name,
|
'name': org2.name,
|
||||||
'id': str(org2.id),
|
'id': str(org2.id),
|
||||||
'services': [],
|
|
||||||
'count_of_live_services': 0,
|
'count_of_live_services': 0,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
# service1 belongs to org1, but the user doesn't know about org1
|
|
||||||
assert resp['services_without_organisations'] == [
|
|
||||||
{
|
|
||||||
'name': service1.name,
|
|
||||||
'id': str(service1.id),
|
|
||||||
'restricted': False,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
# 'services' always returns the org_id no matter whether the user
|
# 'services' always returns the org_id no matter whether the user
|
||||||
# belongs to that org or not
|
# belongs to that org or not
|
||||||
assert resp['services'] == [
|
assert resp['services'] == [
|
||||||
|
|||||||
Reference in New Issue
Block a user