mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 00:07:02 -04:00
Remove link for adding service if nonwhitelist user
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
from flask import (render_template, redirect, url_for, session)
|
import re
|
||||||
|
|
||||||
|
from flask import (current_app, render_template, redirect, url_for, session)
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app import service_api_client
|
from app import service_api_client
|
||||||
from app.notify_client.service_api_client import ServicesBrowsableItem
|
from app.notify_client.service_api_client import ServicesBrowsableItem
|
||||||
|
from app.utils import user_in_whitelist
|
||||||
|
|
||||||
|
|
||||||
@main.route("/services")
|
@main.route("/services")
|
||||||
@@ -11,7 +14,8 @@ def choose_service():
|
|||||||
return render_template(
|
return render_template(
|
||||||
'views/choose-service.html',
|
'views/choose-service.html',
|
||||||
services=[ServicesBrowsableItem(x) for x in
|
services=[ServicesBrowsableItem(x) for x in
|
||||||
service_api_client.get_services({'user_id': current_user.id})['data']]
|
service_api_client.get_services({'user_id': current_user.id})['data']],
|
||||||
|
can_add_service=user_in_whitelist(current_user.email_address)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,14 @@
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{{ browse_list(services) }}
|
{{ browse_list(services) }}
|
||||||
|
{% if can_add_service %}
|
||||||
{{ browse_list([
|
{{ browse_list([
|
||||||
{
|
{
|
||||||
'title': 'Add a new service…',
|
'title': 'Add a new service…',
|
||||||
'link': url_for('.add_service')
|
'link': url_for('.add_service')
|
||||||
},
|
},
|
||||||
]) }}
|
]) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -487,6 +487,22 @@ def platform_admin_user(fake_uuid):
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='function')
|
||||||
|
def nonwhitelist_user(fake_uuid):
|
||||||
|
from app.notify_client.user_api_client import User
|
||||||
|
user_data = {'id': fake_uuid,
|
||||||
|
'name': 'Platform admin user',
|
||||||
|
'password': 'somepassword',
|
||||||
|
'email_address': 'someuser@notonwhitelist.com',
|
||||||
|
'mobile_number': '07700 900762',
|
||||||
|
'state': 'active',
|
||||||
|
'failed_login_count': 0,
|
||||||
|
'permissions': {}
|
||||||
|
}
|
||||||
|
user = User(user_data)
|
||||||
|
return user
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def api_user_active(fake_uuid):
|
def api_user_active(fake_uuid):
|
||||||
from app.notify_client.user_api_client import User
|
from app.notify_client.user_api_client import User
|
||||||
|
|||||||
Reference in New Issue
Block a user