Skip to content

Commit

Permalink
fix update contributor check
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Jan 10, 2025
1 parent 0da606a commit 2bbcf07
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions osf/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1839,15 +1839,17 @@ def get_visible(self, user):
def set_visible(self, user, visible, log=True, auth=None, save=False):
if not self.is_contributor(user):
raise ValueError(f'User {user} not in contributors')
if user.is_curator(self):
raise ValueError('Curators cannot be made bibliographic contributors')
kwargs = self.contributor_kwargs
kwargs['user'] = user
kwargs['visible'] = True
if visible and not self.contributor_class.objects.filter(**kwargs).exists():
set_visible_kwargs = kwargs
set_visible_kwargs['visible'] = False
self.contributor_class.objects.filter(**set_visible_kwargs).update(visible=True)
contribs = self.contributor_class.objects.filter(**set_visible_kwargs)
if contribs.filter(is_curator=True).exists():
raise ValueError('Curators cannot be made bibliographic contributors')
contribs.update(visible=True)

elif not visible and self.contributor_class.objects.filter(**kwargs).exists():
num_visible_kwargs = self.contributor_kwargs
num_visible_kwargs['visible'] = True
Expand Down

0 comments on commit 2bbcf07

Please sign in to comment.