Skip to content

Commit c55867f

Browse files
committed
Basic structure for Co-applicant feature
1 parent 4844022 commit c55867f

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

hypha/apply/funds/models/utils.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.conf import settings
2+
from django.contrib.auth import get_user_model
23
from django.db import models
34
from django.shortcuts import redirect
45
from django.urls import reverse
@@ -26,6 +27,8 @@
2627

2728
from ..workflows import DRAFT_STATE, WORKFLOWS
2829

30+
User = get_user_model()
31+
2932
REVIEW_GROUPS = [
3033
STAFF_GROUP_NAME,
3134
REVIEWER_GROUP_NAME,
@@ -200,3 +203,50 @@ def send_mail(self, submission):
200203
]
201204

202205
email_tab = ObjectList(email_confirmation_panels, heading=_("Confirmation email"))
206+
207+
208+
class SubmissionCoApplicantRole(models.Model):
209+
code = models.CharField(max_length=50, unique=True)
210+
name = models.CharField(max_length=100)
211+
description = models.TextField(blank=True)
212+
213+
def __str__(self):
214+
return self.name
215+
216+
217+
class SubmissionCoApplicantInviteStatus(models.TextChoices):
218+
PENDING = "pending", "Pending"
219+
ACCEPTED = "accepted", "Accepted"
220+
REJECTED = "rejected", "Rejected"
221+
EXPIRED = "expired", "Expired"
222+
223+
224+
class SubmissionCoApplicant(models.Model):
225+
submission = models.ForeignKey(
226+
"funds.ApplicationSubmission",
227+
on_delete=models.CASCADE,
228+
related_name="co-applicants",
229+
)
230+
user = models.ForeignKey(
231+
User, on_delete=models.CASCADE, related_name="co-applicants"
232+
)
233+
role = models.ManyToManyField(
234+
SubmissionCoApplicantRole, related_name="co-applicants"
235+
)
236+
237+
status = models.CharField(
238+
max_length=20,
239+
choices=SubmissionCoApplicantInviteStatus.choices,
240+
default=SubmissionCoApplicantInviteStatus.PENDING,
241+
)
242+
# invited_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name="co-applicant_invites")
243+
invited_on = models.DateTimeField(auto_now_add=True)
244+
responded_on = models.DateTimeField(null=True, blank=True)
245+
246+
class Meta:
247+
unique_together = ("submission", "user")
248+
249+
def __str__(self):
250+
return (
251+
f"{self.user} invited to {self.submission} as {self.role} ({self.status})"
252+
)

0 commit comments

Comments
 (0)