mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fixing Remove Roles when Removing a Server
This commit is contained in:
parent
eb3b86641d
commit
057379d888
@ -14,6 +14,7 @@ from app.classes.shared.console import console
|
||||
|
||||
from app.classes.models.roles import roles_helper
|
||||
from app.classes.models.server_permissions import server_permissions
|
||||
from app.classes.models.users import users_helper
|
||||
|
||||
from app.classes.shared.server import Server
|
||||
from app.classes.minecraft.server_props import ServerProps
|
||||
@ -69,6 +70,8 @@ class Roles_Controller:
|
||||
|
||||
@staticmethod
|
||||
def remove_role(role_id):
|
||||
server_permissions.delete_roles_permissions(role_id)
|
||||
users_helper.remove_roles_from_role_id(role_id)
|
||||
return roles_helper.remove_role(role_id)
|
||||
|
||||
@staticmethod
|
||||
|
@ -15,6 +15,7 @@ from app.classes.shared.console import console
|
||||
|
||||
from app.classes.shared.main_models import db_helper
|
||||
from app.classes.models.servers import servers_helper
|
||||
from app.classes.models.roles import roles_helper
|
||||
from app.classes.models.users import users_helper
|
||||
from app.classes.models.server_permissions import server_permissions, Enum_Permissions_Server
|
||||
|
||||
@ -36,6 +37,11 @@ class Servers_Controller:
|
||||
|
||||
@staticmethod
|
||||
def remove_server(server_id):
|
||||
roles_list = server_permissions.get_roles_from_server(server_id)
|
||||
for role_id in roles_list:
|
||||
server_permissions.delete_roles_permissions(role_id)
|
||||
users_helper.remove_roles_from_role_id(role_id)
|
||||
roles_helper.remove_role(role_id)
|
||||
server_permissions.remove_roles_of_server(server_id)
|
||||
servers_helper.remove_server(server_id)
|
||||
|
||||
|
@ -278,10 +278,10 @@ class Stats:
|
||||
p_stats = self._get_process_stats(server_obj.PID)
|
||||
|
||||
# TODO: search server properties file for possible override of 127.0.0.1
|
||||
#internal_ip = server['server_ip']
|
||||
#server_port = server['server_port']
|
||||
internal_ip = server_data.get('server_ip', "127.0.0.1")
|
||||
server_port = server_settings.get('server-port', "25565")
|
||||
internal_ip = server['server_ip']
|
||||
server_port = server['server_port']
|
||||
#internal_ip = server_data.get('server_ip', "127.0.0.1")
|
||||
#server_port = server_settings.get('server-port', "25565")
|
||||
|
||||
|
||||
logger.debug("Pinging server '{}' on {}:{}".format(server.name, internal_ip, server_port))
|
||||
|
@ -73,8 +73,6 @@ class helper_roles:
|
||||
@staticmethod
|
||||
def remove_role(role_id):
|
||||
with database.atomic():
|
||||
Role_Servers.delete().where(Role_Servers.role_id == role_id).execute()
|
||||
User_Roles.delete().where(User_Roles.role_id == role_id).execute()
|
||||
role = Roles.get(Roles.role_id == role_id)
|
||||
return role.delete_instance()
|
||||
|
||||
|
@ -106,6 +106,10 @@ class Permissions_Servers:
|
||||
def get_servers_from_role(role_id):
|
||||
return Role_Servers.select().join(Servers, JOIN.INNER).where(Role_Servers.role_id == role_id)
|
||||
|
||||
@staticmethod
|
||||
def get_roles_from_server(server_id):
|
||||
return Role_Servers.select().join(Roles, JOIN.INNER).where(Role_Servers.server_id == server_id)
|
||||
|
||||
@staticmethod
|
||||
def add_role_server(server_id, role_id, rs_permissions="00000000"):
|
||||
servers = Role_Servers.insert({Role_Servers.server_id: server_id, Role_Servers.role_id: role_id, Role_Servers.permissions: rs_permissions}).execute()
|
||||
|
@ -234,4 +234,9 @@ class helper_users:
|
||||
def delete_user_roles(user_id, removed_roles):
|
||||
User_Roles.delete().where(User_Roles.user_id == user_id).where(User_Roles.role_id.in_(removed_roles)).execute()
|
||||
|
||||
@staticmethod
|
||||
def remove_roles_from_role_id(role_id):
|
||||
User_Roles.delete().where(User_Roles.role_id == role_id).execute()
|
||||
|
||||
|
||||
users_helper = helper_users()
|
Loading…
Reference in New Issue
Block a user