Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rv0lt committed Oct 24, 2023
1 parent 33e78ef commit 494b7bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dds_web/api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def patch(self):
) # if not provided --> is None -> deadline is not updated

# some variable definition
curr_date = dds_web.utils.current_time()
send_email = False
default_unit_days = project.responsible_unit.days_in_available

Expand All @@ -269,20 +268,27 @@ def patch(self):
)

# the new deadline + days left shouldnt surpass 90 days
curr_date = dds_web.utils.current_time()
current_deadline = (project.current_deadline - curr_date).days
if new_deadline_in + current_deadline > 90:
raise DDSArgumentError(
message=f"You requested the deadline to be extended with {new_deadline_in} days (from {current_deadline}), giving a new total deadline of {new_deadline_in + current_deadline} days. The new deadline needs to be less than (or equal to) 90 days."
)
try:
# add a fake expire status to mimick a re-release in order to have an udpated deadline
curr_date = (
dds_web.utils.current_time()
) # call current_time before each call so it is stored with different timestamps
new_status_row = self.expire_project(
project=project,
current_time=curr_date,
deadline_in=project.responsible_unit.days_in_expired,
deadline_in=1, # some dummy deadline bc it will re-release now again
)
project.project_statuses.append(new_status_row)

curr_date = (
dds_web.utils.current_time()
) # call current_time before each call so it is stored with different timestamps
new_status_row = self.release_project(
project=project,
current_time=curr_date,
Expand Down
2 changes: 2 additions & 0 deletions tests/api/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ def test_extend_deadline_maxium_number_available_exceded(module_client, boto3_se
assert project.times_expired == i
assert project.current_deadline == deadline + datetime.timedelta(days=new_deadline_in)
deadline = project.current_deadline # update current deadline
assert project.current_status == "Available"
assert (
f"The project '{project_id}' has been given a new deadline"
in response.json["message"]
Expand Down Expand Up @@ -1408,6 +1409,7 @@ def test_extend_deadline_ok(module_client, boto3_session):
assert project.current_deadline == deadline + datetime.timedelta(
days=extend_deadline_data.get("new_deadline_in")
)
assert project.current_status == "Available"

assert f"The project '{project_id}' has been given a new deadline" in response.json["message"]
assert "An e-mail notification has not been sent." in response.json["message"]
Expand Down

0 comments on commit 494b7bc

Please sign in to comment.