-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-6668] Add Contributor Page Improvements for Institutional Access (…
…#10825) ## Purpose The new Institutional Access feature creates a new "Curator" role that has certain requirements. The first is that it have a special label in the contributor list, shown here: The second requirement is that the user is unable to set the curator to a bibliographic or "visible contributor. ## Changes - Add check constraint to avoid visible institutional admins. - Locates area in page where Curator status can be lableled - adds tests to test for specific behavior at model and API level - adds extra UI notice for contributor page.
- Loading branch information
1 parent
d9540f3
commit 78597c8
Showing
20 changed files
with
383 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
api_tests/nodes/views/test_node_contributor_insti_admin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import pytest | ||
from osf.models import Contributor | ||
from osf_tests.factories import ( | ||
AuthUserFactory, | ||
ProjectFactory, | ||
InstitutionFactory, | ||
) | ||
from api.base.settings.defaults import API_BASE | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestChangeInstitutionalAdminContributor: | ||
|
||
@pytest.fixture() | ||
def project_admin(self): | ||
return AuthUserFactory() | ||
|
||
@pytest.fixture() | ||
def project_admin2(self): | ||
return AuthUserFactory() | ||
|
||
@pytest.fixture() | ||
def institution(self): | ||
return InstitutionFactory() | ||
|
||
@pytest.fixture() | ||
def institutional_admin(self, institution): | ||
admin_user = AuthUserFactory() | ||
institution.get_group('institutional_admins').user_set.add(admin_user) | ||
return admin_user | ||
|
||
@pytest.fixture() | ||
def project(self, project_admin, project_admin2, institutional_admin): | ||
project = ProjectFactory(creator=project_admin) | ||
project.add_contributor(project_admin2, permissions='admin', visible=False) | ||
project.add_contributor(institutional_admin, visible=False, make_curator=True) | ||
return project | ||
|
||
@pytest.fixture() | ||
def url_contrib(self, project, institutional_admin): | ||
return f'/{API_BASE}nodes/{project._id}/contributors/{institutional_admin._id}/' | ||
|
||
def test_cannot_set_institutional_admin_contributor_bibliographic(self, app, project_admin, project, | ||
institutional_admin, url_contrib): | ||
res = app.put_json_api( | ||
url_contrib, | ||
{ | ||
'data': { | ||
'id': f'{project._id}-{institutional_admin._id}', | ||
'type': 'contributors', | ||
'attributes': { | ||
'bibliographic': True, | ||
} | ||
} | ||
}, | ||
auth=project_admin.auth, | ||
expect_errors=True | ||
) | ||
|
||
assert res.status_code == 409 | ||
assert res.json['errors'][0]['detail'] == 'Curators cannot be made bibliographic contributors' | ||
|
||
contributor = Contributor.objects.get( | ||
node=project, | ||
user=institutional_admin | ||
) | ||
assert not contributor.visible |
2 changes: 1 addition & 1 deletion
2
...request_requested_permissions_and_more.py → ...s/0025_contributor_is_curator_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by Django 4.2.13 on 2025-01-10 19:27 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('osf', '0025_contributor_is_curator_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='contributor', | ||
name='is_curator', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='noderequest', | ||
name='is_institutional_request', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='preprintrequest', | ||
name='is_institutional_request', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.