Skip to content

Commit

Permalink
ensure insti admins are only labeled as such when they make insti req…
Browse files Browse the repository at this point in the history
…uests, fix tpyos
  • Loading branch information
John Tordoff committed Jan 10, 2025
1 parent 756a53d commit f7dfae4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
13 changes: 13 additions & 0 deletions osf/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion website/profile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion website/project/views/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
8 changes: 4 additions & 4 deletions website/templates/project/contributors.mako
Original file line number Diff line number Diff line change
Expand Up @@ -406,23 +406,23 @@
<td>
<div class="header" data-bind="visible: accessRequest.expanded() && $root.collapsed()"></div>
<div class="td-content" data-bind="visible: !$root.collapsed() || accessRequest.expanded()">
<div data-bind="ifnot: accessRequest.user.is_institutional_admin">
<div data-bind="ifnot: accessRequest.user.has_institutional_request">
<input
type="checkbox" class="biblio"
data-bind="checked: visible"
/>
</div>
<div data-bind="if: accessRequest.user.is_institutional_admin">
<div data-bind="if: accessRequest.user.has_institutional_request">
<input type="checkbox" aria-label="Curator Confirmation Checkbox" disabled>
</div>
</td>
<td>
<div class="header" data-bind="visible: accessRequest.expanded() && $root.collapsed()"></div>
<div class="td-content" data-bind="visible: !$root.collapsed() || accessRequest.expanded()">
<div data-bind="ifnot: accessRequest.user.is_institutional_admin">
<div data-bind="ifnot: accessRequest.user.has_institutional_request">
<input type="checkbox" aria-label="Curator Confirmation Checkbox" disabled>
</div>
<div data-bind="if: accessRequest.user.is_institutional_admin">
<div data-bind="if: accessRequest.user.has_institutional_request">
<input type="checkbox" aria-label="Curator Confirmation Checkbox" disabled checked>
</div>
</div>
Expand Down

0 comments on commit f7dfae4

Please sign in to comment.