Skip to content

Commit dfd8ad8

Browse files
committed
Removed partner role, migrated all existing partners to coapplicants with comment priveledges
1 parent 6fab4f0 commit dfd8ad8

41 files changed

Lines changed: 131 additions & 1526 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.test_durations

Lines changed: 0 additions & 924 deletions
This file was deleted.

hypha/apply/activity/adapters/activity_feed.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class ActivityAdapter(AdapterBase):
3838
MESSAGES.INVITED_TO_PROPOSAL: _("Invited to submit a proposal"),
3939
MESSAGES.REVIEWERS_UPDATED: "reviewers_updated",
4040
MESSAGES.BATCH_REVIEWERS_UPDATED: "batch_reviewers_updated",
41-
MESSAGES.PARTNERS_UPDATED: "partners_updated",
4241
MESSAGES.NEW_REVIEW: _("Submitted a review"),
4342
MESSAGES.OPENED_SEALED: _("Opened the submission while still sealed"),
4443
MESSAGES.SCREENING: "handle_screening_statuses",
@@ -89,7 +88,6 @@ def extra_kwargs(self, message_type, source, sources, **kwargs):
8988
MESSAGES.REVIEW_OPINION,
9089
MESSAGES.DELETE_REVIEW_OPINION,
9190
MESSAGES.BATCH_REVIEWERS_UPDATED,
92-
MESSAGES.PARTNERS_UPDATED,
9391
MESSAGES.APPROVE_PROJECT,
9492
MESSAGES.REQUEST_PROJECT_CHANGE,
9593
MESSAGES.SEND_FOR_APPROVAL,
@@ -287,18 +285,6 @@ def handle_batch_transition(self, transitions, sources, **kwargs):
287285
old_phase=old_phase, source=submission, **kwargs
288286
)
289287

290-
def partners_updated(self, added, removed, **kwargs):
291-
message = [_("Partners updated.")]
292-
if added:
293-
message.append(_("Added:"))
294-
message.append(", ".join([str(user) for user in added]) + ".")
295-
296-
if removed:
297-
message.append(_("Removed:"))
298-
message.append(", ".join([str(user) for user in removed]) + ".")
299-
300-
return " ".join(message)
301-
302288
def handle_report_frequency(self, config, **kwargs):
303289
new_schedule = config.get_frequency_display()
304290
return _(

hypha/apply/activity/adapters/emails.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from django.utils.translation import gettext as _
1010

1111
from hypha.apply.activity import tasks
12-
from hypha.apply.activity.models import ALL, APPLICANT_PARTNERS, PARTNER
1312
from hypha.apply.funds.models.co_applicants import (
1413
CoApplicantProjectPermission,
1514
CoApplicantRole,
@@ -65,8 +64,6 @@ class EmailAdapter(AdapterBase):
6564
MESSAGES.READY_FOR_REVIEW: "handle_ready_for_review",
6665
MESSAGES.REVIEWERS_UPDATED: "handle_ready_for_review",
6766
MESSAGES.BATCH_REVIEWERS_UPDATED: "handle_batch_ready_for_review",
68-
MESSAGES.PARTNERS_UPDATED: "partners_updated_applicant",
69-
MESSAGES.PARTNERS_UPDATED_PARTNER: "partners_updated_partner",
7067
MESSAGES.UPLOAD_CONTRACT: "messages/email/contract_uploaded.html",
7168
MESSAGES.SUBMIT_CONTRACT_DOCUMENTS: "messages/email/submit_contract_documents.html",
7269
MESSAGES.CREATED_PROJECT: "messages/email/project_created.html",
@@ -328,10 +325,6 @@ def recipients(self, message_type, source, user, **kwargs):
328325
related = kwargs.get("related", None)
329326
return [related.invited_user_email]
330327

331-
if message_type == MESSAGES.PARTNERS_UPDATED_PARTNER:
332-
partners = kwargs["added"]
333-
return [partner.email for partner in partners]
334-
335328
if message_type == MESSAGES.APPROVE_PAF:
336329
from hypha.apply.projects.models.project import ProjectSettings
337330

@@ -488,12 +481,6 @@ def recipients(self, message_type, source, user, **kwargs):
488481
).values_list("user__email", flat=True)
489482
recipients: List[str] = [source.user.email, *co_applicants]
490483

491-
if partners := list(source.partners.values_list("email", flat=True)):
492-
if comment.visibility == PARTNER:
493-
recipients = partners
494-
elif comment.visibility in [APPLICANT_PARTNERS, ALL]:
495-
recipients += partners
496-
497484
# Comment handling for Projects
498485
elif isinstance(source, Project):
499486
# co_applciants with Comment permission
@@ -557,23 +544,6 @@ def reviewers(self, source):
557544
and not reviewer.is_apply_staff
558545
]
559546

560-
def partners_updated_applicant(self, added, removed, **kwargs):
561-
if added:
562-
return self.render_message(
563-
"messages/email/partners_update_applicant.html", added=added, **kwargs
564-
)
565-
566-
def partners_updated_partner(self, added, removed, **kwargs):
567-
if added:
568-
recipient = kwargs["recipient"]
569-
# Pass the user object to render_message rather than the email string
570-
recipient_obj = User.objects.get(email__exact=recipient)
571-
kwargs["recipient"] = recipient_obj
572-
573-
return self.render_message(
574-
"messages/email/partners_update_partner.html", **kwargs
575-
)
576-
577547
def render_message(self, template, **kwargs):
578548
with language(settings.LANGUAGE_CODE):
579549
text = render_to_string(template, kwargs, kwargs["request"])

hypha/apply/activity/adapters/slack.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ class SlackAdapter(AdapterBase):
4545
),
4646
MESSAGES.REVIEWERS_UPDATED: "reviewers_updated",
4747
MESSAGES.BATCH_REVIEWERS_UPDATED: "handle_batch_reviewers",
48-
MESSAGES.PARTNERS_UPDATED: _(
49-
"{user} has updated the partners on <{link}|{source.title_text_display}>"
50-
),
5148
MESSAGES.TRANSITION: _(
5249
"{user} has updated the status of <{link}|{source.title_text_display}>: {old_phase.display_name} → {source.phase.display_name}"
5350
),

hypha/apply/activity/forms.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,8 @@ class Meta:
4242
}
4343

4444
def __init__(self, *args, user=None, **kwargs):
45-
# Get `submission_partner_list` kwarg and remove it before initializing parent.
46-
submission_partner_list = None
47-
if "submission_partner_list" in kwargs:
48-
submission_partner_list = kwargs.pop("submission_partner_list")
49-
5045
super().__init__(*args, **kwargs)
51-
self.visibility_choices = self._meta.model.visibility_choices_for(
52-
user, submission_partner_list
53-
)
46+
self.visibility_choices = self._meta.model.visibility_choices_for(user)
5447
visibility = self.fields["visibility"]
5548
# Set default visibility to "Applicant" for staff and staff can view everything.
5649
visibility.initial = self.visibility_choices[0]

hypha/apply/activity/migrations/0019_partner_field_event.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Migration(migrations.Migration):
2626
("INVITED_TO_PROPOSAL", "Invited To Proposal"),
2727
("REVIEWERS_UPDATED", "Reviewers Updated"),
2828
("BATCH_REVIEWERS_UPDATED", "Batch Reviewers Updated"),
29-
("PARTNERS_UPDATED", "Partners Updated"),
3029
("READY_FOR_REVIEW", "Ready For Review"),
3130
("BATCH_READY_FOR_REVIEW", "Batch Ready For Review"),
3231
("NEW_REVIEW", "New Review"),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 5.2.12 on 2026-03-25 18:29
2+
3+
from django.db import migrations
4+
5+
from hypha.apply.activity.models import APPLICANT
6+
7+
8+
def convert_partner_perms_to_applicant(apps, schema_editor):
9+
Activity = apps.get_model("activity", "Activity")
10+
11+
# Encompasses both "partner" & "applicant partner" visibilities
12+
Activity.objects.filter(visibility__contains="partner").update(visibility=APPLICANT)
13+
14+
15+
class Migration(migrations.Migration):
16+
dependencies = [
17+
("activity", "0088_activity_deleted"),
18+
]
19+
20+
operations = [migrations.RunPython(convert_partner_perms_to_applicant)]

hypha/apply/activity/models.py

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.contrib.contenttypes.fields import GenericForeignKey
88
from django.contrib.contenttypes.models import ContentType
99
from 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
1111
from django.db.models.functions import Concat
1212
from django.urls import reverse
1313
from django.utils import timezone
@@ -32,18 +32,14 @@
3232
APPLICANT = _("applicant")
3333
TEAM = _("team")
3434
REVIEWER = _("reviewers")
35-
PARTNER = _("partners")
3635
ALL = _("all")
37-
APPLICANT_PARTNERS = f"{APPLICANT} {PARTNER}"
3836

3937
# Visibility choice strings
4038
VISIBILITY = {
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:

hypha/apply/activity/options.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class MESSAGES(TextChoices):
2121
INVITED_TO_PROPOSAL = "INVITED_TO_PROPOSAL", _("invited to proposal")
2222
REVIEWERS_UPDATED = "REVIEWERS_UPDATED", _("updated reviewers")
2323
BATCH_REVIEWERS_UPDATED = "BATCH_REVIEWERS_UPDATED", _("batch updated reviewers")
24-
PARTNERS_UPDATED = "PARTNERS_UPDATED", _("updated partners")
25-
PARTNERS_UPDATED_PARTNER = "PARTNERS_UPDATED_PARTNER", _("partners updated partner")
2624
READY_FOR_REVIEW = "READY_FOR_REVIEW", _("marked ready for review")
2725
BATCH_READY_FOR_REVIEW = (
2826
"BATCH_READY_FOR_REVIEW",

hypha/apply/activity/templates/messages/email/partners_update_applicant.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)