From 144381d52081491250b792a6d1f52168b23c50c0 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/license_manager/apps/subscriptions/models.py b/license_manager/apps/subscriptions/models.py index 47939af6..b26071f7 100644 --- a/license_manager/apps/subscriptions/models.py +++ b/license_manager/apps/subscriptions/models.py @@ -282,6 +282,12 @@ 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 and not self.url_for_button_in_modal.startswith(("http://", "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)