mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 09:45:28 +01:00
Remove schedule logic from backups.
This commit is contained in:
parent
4f55ffed0f
commit
c220c6d3d3
@ -111,5 +111,5 @@ class Management_Controller:
|
||||
return management_helper.get_backup_config(server_id)
|
||||
|
||||
@staticmethod
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None, auto_enabled: bool = True):
|
||||
return management_helper.set_backup_config(server_id, backup_path, max_backups, auto_enabled)
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None):
|
||||
return management_helper.set_backup_config(server_id, backup_path, max_backups)
|
||||
|
@ -278,7 +278,7 @@ class helpers_management:
|
||||
return conf
|
||||
|
||||
@staticmethod
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None, auto_enabled: bool = True):
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None):
|
||||
logger.debug("Updating server {} backup config with {}".format(server_id, locals()))
|
||||
try:
|
||||
row = Backups.select().where(Backups.server_id == server_id).join(Schedules).join(Servers)[0]
|
||||
@ -303,7 +303,6 @@ class helpers_management:
|
||||
new_row = True
|
||||
if max_backups is not None:
|
||||
conf['max_backups'] = max_backups
|
||||
schd['enabled'] = bool(auto_enabled)
|
||||
if not new_row:
|
||||
with database.atomic():
|
||||
if backup_path is not None:
|
||||
@ -311,15 +310,12 @@ class helpers_management:
|
||||
else:
|
||||
u1 = 0
|
||||
u2 = Backups.update(conf).where(Backups.server_id == server_id).execute()
|
||||
u3 = Schedules.update(schd).where(Schedules.schedule_id == row.schedule_id).execute()
|
||||
logger.debug("Updating existing backup record. {}+{}+{} rows affected".format(u1, u2, u3))
|
||||
else:
|
||||
with database.atomic():
|
||||
conf["server_id"] = server_id
|
||||
if backup_path is not None:
|
||||
u = Servers.update(backup_path=backup_path).where(Servers.server_id == server_id)
|
||||
s = Schedules.create(**schd)
|
||||
conf['schedule_id'] = s.schedule_id
|
||||
b = Backups.create(**conf)
|
||||
logger.debug("Creating new backup record.")
|
||||
|
||||
|
@ -801,10 +801,6 @@ class PanelHandler(BaseHandler):
|
||||
else:
|
||||
backup_path = server_obj.backup_path
|
||||
max_backups = bleach.clean(self.get_argument('max_backups', None))
|
||||
try:
|
||||
enabled = int(float(bleach.clean(self.get_argument('auto_enabled'), '0')))
|
||||
except Exception as e:
|
||||
enabled = '0'
|
||||
|
||||
if not permissions['Backup'] in user_perms:
|
||||
if not exec_user['superuser']:
|
||||
@ -830,7 +826,7 @@ class PanelHandler(BaseHandler):
|
||||
server_obj = self.controller.servers.get_server_obj(server_id)
|
||||
server_obj.backup_path = backup_path
|
||||
self.controller.servers.update_server(server_obj)
|
||||
self.controller.management.set_backup_config(server_id, max_backups=max_backups, auto_enabled=True)
|
||||
self.controller.management.set_backup_config(server_id, max_backups=max_backups)
|
||||
|
||||
self.controller.management.add_to_audit_log(exec_user['user_id'],
|
||||
"Edited server {}: updated backups".format(server_id),
|
||||
|
@ -56,16 +56,6 @@
|
||||
<input type="text" class="form-control" name="max_backups" id="max_backups" value="{{ data['backup_config']['max_backups'] }}" placeholder="{{ translate('serverBackups', 'maxBackups', data['lang']) }}" >
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="superuser" class="form-check-label ml-4 mb-4">
|
||||
{% if data['backup_config']['auto_enabled'] %}
|
||||
<input type="checkbox" class="form-check-input" id="auto_enabled" name="auto_enabled" checked="" value="1" >{{ translate('serverBackups', 'backupAtMidnight', data['lang']) }}
|
||||
{% else %}
|
||||
<input type="checkbox" class="form-check-input" id="auto_enabled" name="auto_enabled" value="1" >{{ translate('serverBackups', 'backupAtMidnight', data['lang']) }}
|
||||
{% end %}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success mr-2">{{ translate('serverBackups', 'save', data['lang']) }}</button>
|
||||
<button type="reset" class="btn btn-light">{{ translate('serverBackups', 'cancel', data['lang']) }}</button>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user