-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENG-6668] Add Contributor Page Improvements for Institutional Access #10825
Open
Johnetordoff
wants to merge
9
commits into
CenterForOpenScience:feature/institutional_access
Choose a base branch
from
Johnetordoff:institutional-access-insti-admin-validation
base: feature/institutional_access
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4e507b1
validate curator's non-biblio status and display details on contrbut…
52d1a43
add is _curator in it's own migration file
d1a7412
refactor and split up permissions checks and improve `.save` conditio…
5c33833
add positive test cases for institutional access project curator vali…
756a53d
redo do contributor.mako logic to work for new more specific curator …
8ef8cd6
ensure insti admins are only labeled as such when they make insti req…
0da606a
revert last commit and fix data model by adding more booleans and ser…
2bbcf07
fix update contributor check
6c8eb0a
fix conditional for is_curator check in contributor management method
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overwriting
save
doesn't always cut it, but this looks like that only place we.update
visibility, arguably we want to retain the ability to change the visibility which leans away from placing in DB constraints. However I think this is all visibility updates in the existing code.