Skip to content

Commit

Permalink
Merge branch 'main' into 2658-update-corfunc-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-wilkins authored Nov 14, 2023
2 parents 29f9897 + acb1a6f commit 6d0e17e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion build_tools/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ lxml
pytools
cffi
dominate
html5lib
importlib-resources
bumps
html2text
Expand Down
18 changes: 18 additions & 0 deletions src/sas/qtgui/Utilities/TabbedModelEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, parent=None, edit_only=False):
self.edit_only = edit_only
self.is_modified = False
self.label = None
self.builtinmodels = self.allBuiltinModels()

self.addWidgets()

Expand Down Expand Up @@ -141,6 +142,15 @@ def onLoad(self):
self.tabWidget.removeTab(1)
self.loadFile(filename)

def allBuiltinModels(self):
"""
create a list of all builtin models
"""
from sas.sascalc.fit.models import ModelManager
model_list = ModelManager().cat_model_list()
model_names = [model.name for model in model_list]
return model_names

def loadFile(self, filename):
"""
Performs the load operation and updates the view
Expand Down Expand Up @@ -444,6 +454,14 @@ def canWriteModel(self, model=None, full_path=""):
QtWidgets.QMessageBox.critical(self, "Plugin Error", msg)
# Don't accept but return
return False

if model['filename'].casefold() in (model.casefold() for model in self.builtinmodels):
# notify the viewer
msg = "Built-in model with specified name already exists.\n"
msg += "Please specify different filename."
QtWidgets.QMessageBox.critical(self, "Plugin Error", msg)
# Don't accept but return
return False
# Update model editor if plugin definition changed
func_str = model['text']
msg = None
Expand Down

0 comments on commit 6d0e17e

Please sign in to comment.