From be5b56ba410e4b48875b1eb241bd5a6a49921dfe Mon Sep 17 00:00:00 2001 From: hblankenship Date: Wed, 6 Nov 2024 09:36:49 -0600 Subject: [PATCH] not used imports, file url or title --- dojo/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dojo/models.py b/dojo/models.py index c1aae95835f..117b8d0ebef 100644 --- a/dojo/models.py +++ b/dojo/models.py @@ -7,7 +7,6 @@ import warnings from datetime import datetime from pathlib import Path -from typing import Dict, Optional, Set from uuid import uuid4 import hyperlink @@ -749,7 +748,12 @@ def clean(self): valid_extensions = settings.FILE_UPLOAD_TYPES - if Path(self.file.url).suffix.lower() not in valid_extensions: + # why does this not work with self.file.... + if self.file: + file_name = self.file.url + else: + file_name = self.title + if Path(file_name).suffix.lower() not in valid_extensions: if accepted_extensions := f"{', '.join(valid_extensions)}": msg = ( _("Unsupported extension. Supported extensions are as follows: %s") % accepted_extensions