diff --git a/app/models/user.py b/app/models/user.py index 6af8e5aef..2175d868e 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -237,6 +237,24 @@ class User(JSONModel, UserMixin): def email_domain(self): return self.email_address.split('@')[-1] + @cached_property + def all_services(self): + return user_api_client.get_services_for_user(self.id) + + @property + def trial_mode_services(self): + return [ + service for service in self.all_services + if service['restricted'] + ] + + @property + def live_services(self): + return [ + service for service in self.all_services + if not service['restricted'] + ] + @cached_property def default_organisation(self): return Organisation( diff --git a/app/templates/views/choose-account.html b/app/templates/views/choose-account.html index e277b289f..6686a4e65 100644 --- a/app/templates/views/choose-account.html +++ b/app/templates/views/choose-account.html @@ -15,7 +15,7 @@
  • All organisations
  • -
    +
    {% endif %} {% for org in organisations %}
  • @@ -30,7 +30,7 @@ {% endif %}
  • -
    +
    {% endfor %} {% if services_without_organisations %} {% for item in services_without_organisations %} @@ -38,9 +38,24 @@ {{ item.name }} {% endfor %} -
    +
    + {% endif %} + {% if current_user.trial_mode_services %} + {% if organisations or current_user.live_services %} + +

    + Trial mode services +

    + + {% if can_add_service %}
    Add a new service diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index d84b7cb2f..f7c7f4fc3 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -15,16 +15,16 @@ SAMPLE_DATA = { 'name': 'org_1', 'id': 'o1', 'services': [ - {'name': 'org_service_1', 'id': 'os1'}, - {'name': 'org_service_2', 'id': 'os2'}, - {'name': 'org_service_3', 'id': 'os3'}, + {'name': 'org_service_1', 'id': 'os1', 'restricted': False}, + {'name': 'org_service_2', 'id': 'os2', 'restricted': False}, + {'name': 'org_service_3', 'id': 'os3', 'restricted': True}, ] }, { 'name': 'org_2', 'id': 'o2', 'services': [ - {'name': 'org_service_4', 'id': 'os4'}, + {'name': 'org_service_4', 'id': 'os4', 'restricted': False}, ] }, { @@ -34,9 +34,9 @@ SAMPLE_DATA = { } ], 'services_without_organisations': [ - {'name': 'service_1', 'id': 's1'}, - {'name': 'service_2', 'id': 's2'}, - {'name': 'service_3', 'id': 's3'}, + {'name': 'service_1', 'id': 's1', 'restricted': False}, + {'name': 'service_2', 'id': 's2', 'restricted': False}, + {'name': 'service_3', 'id': 's3', 'restricted': True}, ] }