From 881c3d949d7804f310b43525dc572f27fb23d30e Mon Sep 17 00:00:00 2001 From: jajjibhai008 Date: Thu, 24 Oct 2024 13:20:07 +0500 Subject: [PATCH] feat: add validation check on valid url in user agreement model --- license_manager/apps/subscriptions/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/license_manager/apps/subscriptions/models.py b/license_manager/apps/subscriptions/models.py index 47939af6..85061ba0 100644 --- a/license_manager/apps/subscriptions/models.py +++ b/license_manager/apps/subscriptions/models.py @@ -282,6 +282,11 @@ def clean(self): error_msg = "This field must be blank if 'Has Custom License Expiration Messaging' is unchecked." errors = {field: error_msg for field in fields_to_check} + # Validate that url_for_button_in_modal is a complete URL + if self.url_for_button_in_modal: + if not (self.url_for_button_in_modal.startswith('http://') or self.url_for_button_in_modal.startswith('https://')): + errors['url_for_button_in_modal'] = "The URL must start with 'http://' or 'https://'. Please provide a valid URL." + # Raise ValidationError if there are any errors if errors: raise ValidationError(errors)