diff --git a/osf/models/user.py b/osf/models/user.py index 26cfd93b8dc..feccc780be4 100644 --- a/osf/models/user.py +++ b/osf/models/user.py @@ -45,6 +45,7 @@ from .spam import SpamMixin from .session import UserSessionMap from .tag import Tag +from .request import NodeRequest from .validators import validate_email, validate_social, validate_history_item from osf.utils.datetime_aware_jsonfield import DateTimeAwareJSONField from osf.utils.fields import NonNaiveDateTimeField, LowercaseEmailField, ensure_str @@ -57,6 +58,7 @@ from website.util.metrics import OsfSourceTags, unregistered_created_source_tag from importlib import import_module from osf.utils.requests import get_headers_from_request +from osf.utils.workflows import NodeRequestTypes SessionStore = import_module(settings.SESSION_ENGINE).SessionStore @@ -672,6 +674,17 @@ def is_institutional_curator(self, node): is_curator=True, ).exists() + def has_institutional_request(self, node): + """ + Checks if user a has requested a node using the institutional access request feature. + """ + return NodeRequest.objects.filter( + request_type=NodeRequestTypes.INSTITUTIONAL_REQUEST.value, + node=node, + user=self, + is_curator=True, + ).exists() + def group_role(self, group): """ For the given OSFGroup, return the user's role - either member or manager diff --git a/website/profile/utils.py b/website/profile/utils.py index 1ee0a3e082d..ba1a6ab65d4 100644 --- a/website/profile/utils.py +++ b/website/profile/utils.py @@ -33,7 +33,7 @@ def serialize_user(user, node=None, admin=False, full=False, is_profile=False, i 'surname': user.family_name, 'fullname': fullname, 'shortname': fullname if len(fullname) < 50 else fullname[:23] + '...' + fullname[-23:], - 'is_institutional_admin': user.is_institutional_admin(), + 'has_institutional_request': user.has_institutional_request(node), 'is_curator': user.is_institutional_curator(node), 'profile_image_url': user.profile_image_url(size=settings.PROFILE_IMAGE_MEDIUM), 'active': user.is_active, diff --git a/website/project/views/contributor.py b/website/project/views/contributor.py index 8bd78ce46ad..0b36b494c34 100644 --- a/website/project/views/contributor.py +++ b/website/project/views/contributor.py @@ -290,7 +290,7 @@ def project_manage_contributors(auth, node, **kwargs): raise HTTPError(http_status.HTTP_400_BAD_REQUEST, data={'message_long': error.args[0]}) except IntegrityError as error: status.push_status_message( - 'You can not make an institutional admin a bibliographic contributor.', + 'You can not make an institutional curator a bibliographic contributor.', kind='error', trust=False ) diff --git a/website/templates/project/contributors.mako b/website/templates/project/contributors.mako index 852a716fd0a..d83ec98263f 100644 --- a/website/templates/project/contributors.mako +++ b/website/templates/project/contributors.mako @@ -406,23 +406,23 @@