77from django .contrib .contenttypes .fields import GenericForeignKey
88from django .contrib .contenttypes .models import ContentType
99from django .db import models
10- from django .db .models import Case , Q , QuerySet , Value , When
10+ from django .db .models import Case , Q , Value , When
1111from django .db .models .functions import Concat
1212from django .urls import reverse
1313from django .utils import timezone
3232APPLICANT = _ ("applicant" )
3333TEAM = _ ("team" )
3434REVIEWER = _ ("reviewers" )
35- PARTNER = _ ("partners" )
3635ALL = _ ("all" )
37- APPLICANT_PARTNERS = f"{ APPLICANT } { PARTNER } "
3836
3937# Visibility choice strings
4038VISIBILITY = {
4139 APPLICANT : _ ("Applicants" ),
4240 TEAM : _ ("Staff only" ),
4341 REVIEWER : _ ("Reviewers" ),
44- PARTNER : _ ("Partners" ),
4542 ALL : _ ("All" ),
46- APPLICANT_PARTNERS : _ ("Applicants & Partners" ),
4743}
4844
4945
@@ -67,16 +63,12 @@ def visible_to(self, user) -> models.QuerySet:
6763
6864 user_qs = Q (user = user )
6965
70- # There are scenarios where users will have activities in which they
71- # wouldn't have visibility just using Activity.visibility_for. Thus,
72- # the queryset should include activity in which they author via
73- # `user_qs` (ie. A comment made only to staff from a partner).
7466 if user .is_applicant :
75- # Handle the edge case where a partner or reviewer is also an
67+ # Handle the edge case where a xreviewer is also an
7668 # applicant. Ensures that any applications/projects the user
7769 # authored will have comment visibility of applicant while others
7870 # will get the appropriate role.
79- if user .is_partner or user . is_reviewer :
71+ if user .is_reviewer :
8072 ApplicationSubmission = apps .get_model ("funds" , "ApplicationSubmission" )
8173 Project = apps .get_model ("application_projects" , "Project" )
8274
@@ -253,7 +245,7 @@ def get_absolute_url(self):
253245 @property
254246 def privileged (self ):
255247 # Not visible to applicant
256- return self .visibility not in [APPLICANT , PARTNER , APPLICANT_PARTNERS , ALL ]
248+ return self .visibility not in [APPLICANT , ALL ]
257249
258250 @property
259251 def private (self ):
@@ -270,11 +262,7 @@ def visibility_for(
270262 """Gets activity visibility for a specified user
271263
272264 Takes an optional boolean that is used to determine the visibility of
273- an application comment. This was mainly implemented to allow partners
274- also holding the role of applicant to have a proper visibility.
275-
276- ie. Prevent someone with the role of partner & applicant looking at
277- comments on their own application and seeing partner visibility
265+ an application comment.
278266
279267 Args:
280268 user:
@@ -285,72 +273,33 @@ def visibility_for(
285273 Returns:
286274 A list of visibility strings
287275 """
288- if user .is_apply_staff :
289- return [TEAM , APPLICANT , REVIEWER , APPLICANT_PARTNERS , PARTNER , ALL ]
276+ if user .is_apply_staff or user . is_finance or user . is_contracting :
277+ return [TEAM , APPLICANT , REVIEWER , ALL ]
290278 if user .is_reviewer and not is_submission_author :
291279 return [REVIEWER , ALL ]
292- if user .is_finance or user .is_contracting :
293- # for project part
294- return [TEAM , APPLICANT , REVIEWER , PARTNER , ALL ]
295- if user .is_partner and not is_submission_author :
296- return [PARTNER , ALL , APPLICANT_PARTNERS ]
297280 if user .is_applicant :
298- return [APPLICANT , ALL , APPLICANT_PARTNERS ]
281+ return [APPLICANT , ALL ]
299282
300283 return [ALL ]
301284
302285 @classmethod
303- def visibility_choices_for (
304- cls , user , submission_partner_list : Optional [QuerySet ] = None
305- ) -> List [Tuple [str , str ]]:
286+ def visibility_choices_for (cls , user ) -> List [Tuple [str , str ]]:
306287 """Gets activity visibility choices for the specified user
307288
308- Uses the given user (and partner query set if provided) to give
309- the specified user activity visibility choices.
310-
311289 Args:
312- user:
313- The [`User`][hypha.apply.users.models.User] being given
314- visibility choices
315- submission_has_partner:
316- An optional QuerySet of partners
317- ([`Users`][hypha.apply.users.models.User])
290+ user: The [`User`][hypha.apply.users.models.User] being given visibility choices
291+
318292 Returns:
319293 A list of tuples in the format of:
320294 [(<visibility string>, <visibility display string>), ...]
321295 """
322- has_partner = submission_partner_list and len (submission_partner_list ) > 0
323296
324297 if user .is_apply_staff :
325- if not has_partner :
326- choices = [
327- (TEAM , VISIBILITY [TEAM ]),
328- (APPLICANT , VISIBILITY [APPLICANT ]),
329- (REVIEWER , VISIBILITY [REVIEWER ]),
330- (ALL , VISIBILITY [ALL ]),
331- ]
332- else :
333- choices = [
334- (TEAM , VISIBILITY [TEAM ]),
335- (APPLICANT , VISIBILITY [APPLICANT ]),
336- (PARTNER , VISIBILITY [PARTNER ]),
337- (APPLICANT_PARTNERS , VISIBILITY [APPLICANT_PARTNERS ]),
338- (REVIEWER , VISIBILITY [REVIEWER ]),
339- (ALL , VISIBILITY [ALL ]),
340- ]
341- return choices
342-
343- if user .is_partner and has_partner and submission_partner_list .contains (user ):
344298 return [
345- (APPLICANT_PARTNERS , VISIBILITY [APPLICANT_PARTNERS ]),
346- (PARTNER , VISIBILITY [PARTNER ]),
347299 (TEAM , VISIBILITY [TEAM ]),
348- ]
349-
350- if user .is_applicant and has_partner :
351- return [
352- (APPLICANT_PARTNERS , VISIBILITY [PARTNER ]),
353- (APPLICANT , VISIBILITY [TEAM ]),
300+ (APPLICANT , VISIBILITY [APPLICANT ]),
301+ (REVIEWER , VISIBILITY [REVIEWER ]),
302+ (ALL , VISIBILITY [ALL ]),
354303 ]
355304
356305 if user .is_applicant :
0 commit comments