From 7b46c9d6ae00a9b99fb24644425154126f6f23c4 Mon Sep 17 00:00:00 2001 From: Max Cotton Date: Mon, 18 Mar 2024 14:14:57 +0000 Subject: [PATCH] Add model name validation for double spaces --- school_project/__main__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/school_project/__main__.py b/school_project/__main__.py index 499658c..65f48e0 100644 --- a/school_project/__main__.py +++ b/school_project/__main__.py @@ -395,16 +395,25 @@ def manage_testing(self, test_thread: threading.Thread) -> None: def save_model(self) -> None: """Save the model, save the model information to the database, then enter the home frame.""" - model_name = self.save_model_name_entry.get() + model_name = self.save_model_name_entry.get().strip() # Check if model name is empty - if model_name == '': + if len(model_name) == 0: self.test_frame.model_status_label.configure( text="Model name can not be blank", fg='red' ) return + # Check if model contains double spaces or greater + elif ' ' in model_name: + self.test_frame.model_status_label.configure( + text="Only single spaces are allowed", + fg='red' + ) + return + + # Check if model name has already been taken dataset = self.dataset_option_menu_var.get().replace(" ", "_") sql = """