Skip to content

Commit

Permalink
change max date based on contract effective date
Browse files Browse the repository at this point in the history
  • Loading branch information
abhigyanghosh30 committed Oct 4, 2024
1 parent d49ff67 commit c680fa6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion templates/credentials/schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h1 class="p-heading--2">
name="timezone"
required></select>
<label class="p-heading--5 u-no-margin" for="exam-date">Select your preferred day</label>
<p>You can schedule your exam to begin {{ time_delay }} from now or later.</p>
<p>You can schedule your exam to begin {{ time_delay }} from now or later. {{max_date}}</p>
<input class="spaced-bottom--smaller is-paper--input"
type="date"
id="exam-date"
Expand Down
12 changes: 9 additions & 3 deletions webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,17 @@ def cred_schedule(
**_,
):
error = None

contract_long_id = flask.request.args.get("contractLongID")
contract_detail = ua_contracts_api.get_contract(contract_long_id)

now = datetime.utcnow()
min_date = (now + timedelta(minutes=30)).strftime("%Y-%m-%d")
max_date = (now + timedelta(days=365)).strftime("%Y-%m-%d")
contract_long_id = flask.request.args.get("contractLongID")
max_date = datetime.strptime(
f"{contract_detail['contractInfo']['effectiveTo']}",
"%Y-%m-%dT%H:%M:%SZ",
).strftime("%Y-%m-%d")

is_staging = "staging" in os.getenv(
"CONTRACTS_API_URL", "https://contracts.staging.canonical.com/"
)
Expand Down Expand Up @@ -317,7 +324,6 @@ def cred_schedule(
between the contract effectiveness window"""
if not contract_long_id:
return flask.redirect("/credentials/your-exams")
contract_detail = ua_contracts_api.get_contract(contract_long_id)
effective_from = now.astimezone(tz_info) + timedelta(
hours=time_delta
)
Expand Down

0 comments on commit c680fa6

Please sign in to comment.