mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add Support for MVC
Merge branch 'dev-Silversthorn-MVC' into 'dev'
This commit is contained in:
commit
c6389f14b3
@ -24,7 +24,7 @@ from app.classes.minecraft.stats import Stats
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Roles_Controller:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_all_roles():
|
||||
return roles_helper.get_all_roles()
|
||||
@ -70,14 +70,15 @@ class Roles_Controller:
|
||||
|
||||
@staticmethod
|
||||
def remove_role(role_id):
|
||||
server_permissions.delete_roles_permissions(role_id)
|
||||
role_data = Roles_Controller.get_role_with_servers(role_id)
|
||||
server_permissions.delete_roles_permissions(role_id, role_data['servers'])
|
||||
users_helper.remove_roles_from_role_id(role_id)
|
||||
return roles_helper.remove_role(role_id)
|
||||
|
||||
@staticmethod
|
||||
def role_id_exists(role_id):
|
||||
return roles_helper.role_id_exists(role_id)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_role_with_servers(role_id):
|
||||
role = roles_helper.get_role(role_id)
|
||||
|
@ -1,3 +1,4 @@
|
||||
from app.classes.controllers.roles_controller import Roles_Controller
|
||||
import os
|
||||
import time
|
||||
import logging
|
||||
@ -27,7 +28,7 @@ from app.classes.minecraft.stats import Stats
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Servers_Controller:
|
||||
|
||||
|
||||
#************************************************************************************************
|
||||
# Generic Servers Methods
|
||||
#************************************************************************************************
|
||||
@ -38,10 +39,10 @@ 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)
|
||||
for role in roles_list:
|
||||
role_id = role.role_id
|
||||
role_data = Roles_Controller.get_role_with_servers(role_id)
|
||||
server_permissions.delete_roles_permissions(role_id, role_data['servers'])
|
||||
server_permissions.remove_roles_of_server(server_id)
|
||||
servers_helper.remove_server(server_id)
|
||||
|
||||
@ -133,7 +134,7 @@ class Servers_Controller:
|
||||
@staticmethod
|
||||
def get_waiting_start(server_id):
|
||||
return servers_helper.get_waiting_start(server_id)
|
||||
|
||||
|
||||
#************************************************************************************************
|
||||
# Servers Helpers Methods
|
||||
#************************************************************************************************
|
||||
@ -150,9 +151,9 @@ class Servers_Controller:
|
||||
except Exception as ex:
|
||||
print (ex)
|
||||
return None
|
||||
|
||||
|
||||
return json.loads(content)
|
||||
|
||||
|
||||
def check_for_old_logs(self):
|
||||
servers = servers_helper.get_all_defined_servers()
|
||||
for server in servers:
|
||||
|
@ -56,7 +56,7 @@ class Enum_Permissions_Server(Enum):
|
||||
Players = 7
|
||||
|
||||
class Permissions_Servers:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_or_create(role_id, server, permissions_mask):
|
||||
return Role_Servers.get_or_create(role_id=role_id, server_id=server, permissions=permissions_mask)
|
||||
@ -94,7 +94,7 @@ class Permissions_Servers:
|
||||
def get_permission(permission_mask, permission_tested: Enum_Permissions_Server):
|
||||
return permission_mask[permission_tested.value]
|
||||
|
||||
|
||||
|
||||
#************************************************************************************************
|
||||
# Role_Servers Methods
|
||||
#************************************************************************************************
|
||||
@ -114,7 +114,7 @@ class Permissions_Servers:
|
||||
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()
|
||||
return servers
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_permissions_mask(role_id, server_id):
|
||||
permissions_mask = ''
|
||||
@ -124,9 +124,10 @@ class Permissions_Servers:
|
||||
|
||||
@staticmethod
|
||||
def get_role_permissions_list(role_id):
|
||||
permissions_mask = ''
|
||||
role_server = Role_Servers.select().where(Role_Servers.role_id == role_id).execute()
|
||||
permissions_mask = role_server[0].permissions
|
||||
permissions_mask = '00000000'
|
||||
role_server = Role_Servers.get_or_none(role_id)# select().where(Role_Servers.role_id == role_id).execute()
|
||||
if role_server is not None:
|
||||
permissions_mask = role_server[0].permissions
|
||||
permissions_list = server_permissions.get_permissions(permissions_mask)
|
||||
return permissions_list
|
||||
|
||||
@ -159,5 +160,5 @@ class Permissions_Servers:
|
||||
permissions_mask = role_server[0].permissions
|
||||
permissions_list = server_permissions.get_permissions(permissions_mask)
|
||||
return permissions_list
|
||||
|
||||
|
||||
server_permissions = Permissions_Servers()
|
Loading…
Reference in New Issue
Block a user