diff --git a/hypha/apply/activity/forms.py b/hypha/apply/activity/forms.py index e3359f75fe..fa8483dbc2 100644 --- a/hypha/apply/activity/forms.py +++ b/hypha/apply/activity/forms.py @@ -43,9 +43,11 @@ class Meta: "message": PagedownWidget(), } - def __init__(self, *args, user=None, **kwargs): + def __init__(self, *args, user=None, has_coapplicants=False, **kwargs): super().__init__(*args, **kwargs) - self.visibility_choices = self._meta.model.visibility_choices_for(user) + self.visibility_choices = self._meta.model.visibility_choices_for( + user, has_coapplicants + ) visibility = self.fields["visibility"] # Set default visibility to "Applicant" for staff and staff can view everything. visibility.initial = self.visibility_choices[0] diff --git a/hypha/apply/activity/models.py b/hypha/apply/activity/models.py index 83574e642f..431ab002ec 100644 --- a/hypha/apply/activity/models.py +++ b/hypha/apply/activity/models.py @@ -289,7 +289,9 @@ def visibility_for( return [ALL] @classmethod - def visibility_choices_for(cls, user) -> List[Tuple[str, str]]: + def visibility_choices_for( + cls, user, has_coapplicants=False + ) -> List[Tuple[str, str]]: """Gets activity visibility choices for the specified user Args: @@ -309,7 +311,10 @@ def visibility_choices_for(cls, user) -> List[Tuple[str, str]]: ] if user.is_applicant: - return [(APPLICANT, VISIBILITY[APPLICANT])] + applicant_choices = [(APPLICANT, VISIBILITY[APPLICANT])] + if has_coapplicants: + applicant_choices.append((TEAM, VISIBILITY[TEAM])) + return applicant_choices if user.is_reviewer: return [(REVIEWER, VISIBILITY[REVIEWER])] diff --git a/hypha/apply/funds/views/comments.py b/hypha/apply/funds/views/comments.py index afae1daf63..9a7cd985e0 100644 --- a/hypha/apply/funds/views/comments.py +++ b/hypha/apply/funds/views/comments.py @@ -30,7 +30,11 @@ def comments_view(request, pk): form = None if user_can_view_post_comment_form(user=request.user, submission=submission): - form = CommentForm(user=request.user, data=request.POST or None) + form = CommentForm( + user=request.user, + data=request.POST or None, + has_coapplicants=submission.co_applicants.exists(), + ) if request.method == "POST": form.instance.user = request.user form.instance.source = submission