Added support for post install scripts when a model is created
This commit is contained in:
parent
b678823a0e
commit
97ab25c162
2 changed files with 30 additions and 2 deletions
|
|
@ -49,8 +49,6 @@ def start():
|
|||
if '/' in args.model:
|
||||
|
||||
args.model=args.model.replace('/', '.')[:-3] #.replace('.py', '')
|
||||
|
||||
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -307,7 +305,35 @@ def start():
|
|||
else:
|
||||
if not os.path.isfile(backup_path):
|
||||
create_backup(original_file_path, backup_path)
|
||||
|
||||
# Execute script
|
||||
|
||||
arr_script_model=args.model.split('.')
|
||||
|
||||
arr_script_model.pop()
|
||||
|
||||
script_model='.'.join(arr_script_model)+'.scripts.install'
|
||||
|
||||
script_py=script_model.replace('.', '/')+'.py'
|
||||
|
||||
if os.path.isfile(script_py):
|
||||
|
||||
locked_file='/'.join(arr_script_model)+'/scripts/locked'
|
||||
|
||||
if not os.path.isfile(locked_file):
|
||||
|
||||
script_install=import_module(script_model)
|
||||
|
||||
script_install.run()
|
||||
|
||||
f=open(locked_file, 'w')
|
||||
|
||||
f.write('OK')
|
||||
|
||||
f.close()
|
||||
|
||||
|
||||
#script_model=args.model+''
|
||||
|
||||
print(Style.BRIGHT+"All tasks finished")
|
||||
|
||||
|
|
|
|||
|
|
@ -309,6 +309,8 @@ class WebModel:
|
|||
# Add extra fields from related table from select_fields ForeignKeyField class member
|
||||
|
||||
for extra_field in self.fields[field].select_fields:
|
||||
|
||||
# Check if extra_field is ForeignKeyField, if yes, call this function recursively.
|
||||
|
||||
extra_fields.append("`"+table_name+"`.`"+extra_field+"` as `"+table_name+"_"+extra_field+"`")
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue