-
Notifications
You must be signed in to change notification settings - Fork 383
Improved error handling when license expiration is unset #971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved error handling when license expiration is unset #971
Conversation
@@ -203,8 +203,11 @@ def get_build(request): | |||
LICENSE_SEATS = settings.LICENSE_SEATS | |||
LICENSE_EXPIRATION = settings.LICENSE_EXPIRATION | |||
try: | |||
expiration_iso = datetime.fromisoformat(LICENSE_EXPIRATION) | |||
license_expiration = date_format(expiration_iso, use_l10n=True) | |||
if LICENSE_EXPIRATION and LICENSE_EXPIRATION.lower() != "unset": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advise to wrap the date cast in a try/except block, instead of explicitly checking for an "unset" string.
expiration_iso = datetime.fromisoformat(LICENSE_EXPIRATION) | ||
license_expiration = date_format(expiration_iso, use_l10n=True) | ||
else: | ||
license_expiration = "No expiration date set" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have an error identifier here instead of an english string, e.g. "noExpirationDateSet". This would make it easier to translate it in the frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…xpiration-is-unset
…xpiration-is-unset
fdb8aad
to
af7143a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Improving the error handling when license expiration is unset by catching error when licence_expiracy = "unset"