Add basic "Review Model" step for new table wizard

This commit is contained in:
Lance Edgar 2023-01-14 23:23:21 -06:00
parent 9d2bcff96b
commit 68ed5942e6
2 changed files with 156 additions and 4 deletions

View file

@ -183,11 +183,28 @@ class TableView(MasterView):
path = data['module_file']
if os.path.exists(path):
return {'error': "File already exists"}
if data['overwrite']:
os.remove(path)
else:
return {'error': "File already exists"}
self.db_handler.write_table_model(data, path)
return {'ok': True}
def check_model(self):
model = self.model
data = self.request.json_body
model_name = data['model_name']
if not hasattr(model, model_name):
return {'ok': True,
'problem': "class not found in primary model contents",
'model': self.model.__name__}
# TODO: probably should inspect closer before assuming ok..?
return {'ok': True}
def get_row_data(self, table):
data = []
for i, column in enumerate(table['table'].columns, 1):
@ -261,6 +278,15 @@ class TableView(MasterView):
renderer='json',
permission='{}.create'.format(permission_prefix))
# check model
config.add_route('{}.check_model'.format(route_prefix),
'{}/check-model'.format(url_prefix),
request_method='POST')
config.add_view(cls, attr='check_model',
route_name='{}.check_model'.format(route_prefix),
renderer='json',
permission='{}.create'.format(permission_prefix))
class TablesView(TableView):