Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions hypha/apply/funds/models/co_applicants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _

from hypha.apply.users.models import User
Expand Down Expand Up @@ -60,6 +61,11 @@ class Meta:
def __str__(self):
return f"{self.invited_user_email} invited to {self.submission})"

def respond(self, status):
self.status = status
self.responded_on = timezone.now()
self.save(update_fields=["status", "responded_on"])


class CoApplicant(models.Model):
submission = models.ForeignKey(
Expand Down
4 changes: 2 additions & 2 deletions hypha/apply/funds/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import csv
import os
import re
from datetime import datetime
from io import StringIO
from itertools import chain
from typing import Iterable

from django.core.files.storage import default_storage
from django.urls import reverse
from django.utils import timezone
from django.utils.encoding import force_bytes
from django.utils.html import strip_tags
from django.utils.http import urlsafe_base64_encode
Expand Down Expand Up @@ -162,7 +162,7 @@ def get_copied_form_name(original_form_name: str) -> str:
str: name of the copied form
"""
copy_str = _("Copied on {copy_time}")
copy_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-4]
copy_time = timezone.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-4]
date_reg = r"(\d{2,4}-?){3} (\d{2}(:|.)?){4}" # match the strftime pattern of %Y-%m-%d %H:%M:%S.%f

# Escape the `copy_str` to allow for translations to be matched & replace the
Expand Down
9 changes: 2 additions & 7 deletions hypha/apply/funds/views/co_applicants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import json

from django.conf import settings
Expand Down Expand Up @@ -153,9 +152,7 @@ def get(self, *args, **kwargs):
def post(self, args, **kwargs):
action = self.request.POST.get("action")
if action == "accept":
self.invite.status = CoApplicantInviteStatus.ACCEPTED
self.invite.responded_on = datetime.datetime.now()
self.invite.save(update_fields=["status", "responded_on"])
self.invite.respond(CoApplicantInviteStatus.ACCEPTED)

# handle auto login/signup
user, created = User.objects.get_or_create(
Expand Down Expand Up @@ -194,9 +191,7 @@ def post(self, args, **kwargs):

login(self.request, user)
return HttpResponseClientRedirect(self.get_success_url())
self.invite.status = CoApplicantInviteStatus.REJECTED
self.invite.responded_on = datetime.datetime.now()
self.invite.save(update_fields=["status", "responded_on"])
self.invite.respond(CoApplicantInviteStatus.REJECTED)
if self.request.user.is_authenticated:
return HttpResponseClientRedirect(reverse_lazy("dashboard:dashboard"))
return HttpResponseClientRedirect("/")
Expand Down
5 changes: 2 additions & 3 deletions hypha/apply/funds/views/revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ def cleanse_stream_fields(self, a_field, b_field) -> List[str]:

sanitized_answers.append(f"{heading}{answer}")
except AttributeError:
# If it fails to match for some reason just cleanse the fields but leave h2s
answer = nh3.clean(answer, attributes={}, tags={"h2"})
sanitized_answers.append(field)
# If it fails to match for some reason just cleanse the field but leave h2s
sanitized_answers.append(nh3.clean(field, attributes={}, tags={"h2"}))

return sanitized_answers
2 changes: 1 addition & 1 deletion hypha/apply/projects/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def can_user_delete(self, user):
CoApplicantRole,
)

if self.status in (SUBMITTED):
if self.status == SUBMITTED:
if user.is_apply_staff:
return True
if user.is_applicant:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def handle(self, *args, **options):
delta = frequency.reminder_days * multiplier

due_date = today + relativedelta(days=delta)
for project in Project.objects.in_progress():
# Make sure that project has report_config.
for project in Project.objects.in_progress().filter(
report_config__isnull=False
):
next_report = project.report_config.ensure_due_report()
if not next_report:
continue
Expand Down