# Path: kokemomo/plugins/engine/model/km_user_table.py
# class KMUser(adapter.Model):
#     __tablename__ = 'km_user'
#     id = adapter.Column(adapter.Integer, autoincrement=True, primary_key=True)
#     user_id = adapter.Column(adapter.String(50))
#     name = adapter.Column(adapter.String(254))
#     password = adapter.Column(adapter.String(254))
#     mail_address = adapter.Column(adapter.String(254))
#     group_id = adapter.Column(adapter.Integer)
#     role_id = adapter.Column(adapter.Integer)
# 
#     def __init__(self, data=None):
#         if data is None:
#             self.user_id= ''
#             self.name = ''
#             self.password = ''
#             self.mail_address = ''
#         else:
#             self.set_data(data)
# 
#     def __repr__(self):
#         return create_repr_str(self)
# 
#     def get_json(self):
#         return create_json(self)
# 
#     def set_data(self, data):
#         self.error = None
#         self.user_id = data.get_request_parameter('user_id', default='')
#         self.name = data.get_request_parameter('name', default='')
#         self.password = data.get_request_parameter('password', default='')
#         self.mail_address = data.get_request_parameter('mail_address', default='')
#         self.group_id = data.get_request_parameter('group_id', default=None)
#         self.role_id = data.get_request_parameter('role_id', default=None)
# 
#     def save(self, validate=True):
#         self.password = bcrypt.hashpw(self.password.encode(SETTINGS.CHARACTER_SET), bcrypt.gensalt())
#         super(KMUser, self).save()
# 
#     @classmethod
#     def get(cls, id):
#         if id is None:
#             user = KMUser()
#         else:
#             user = super(KMUser, cls).get(id=id)
#         return user
# 
# Path: kokemomo/plugins/engine/model/km_group_table.py
# class KMGroup(adapter.Model):
#     __tablename__ = 'km_group'
#     id = adapter.Column(adapter.Integer, autoincrement=True, primary_key=True)
#     name = adapter.Column(adapter.String(254))
#     parent_id = adapter.Column(adapter.Integer)
# 
# 
#     def __init__(self, data=None):
#         if data is None:
#             self.name = ''
#             self.parent_id = -1
#         else:
#             self.set_data(data)
# 
# 
#     def __repr__(self):
#         return create_repr_str(self)
# 
# 
#     def get_json(self):
#         return create_json(self)
# 
# 
#     def set_data(self, data):
#         self.error = None
#         self.name = data.get_request_parameter('name', default='')
#         self.parent_id = data.get_request_parameter('parent_id', default=-1)
# 
# 
#     @classmethod
#     def get(cls, id):
#         if id is None:
#             group = KMGroup()
#         else:
#             group = super(KMGroup, cls).get(id=id)
#         return group
# 
# Path: kokemomo/plugins/engine/model/km_role_table.py
# class KMRole(adapter.Model):
#     __tablename__ = 'km_role'
#     id = adapter.Column(adapter.Integer, autoincrement=True, primary_key=True)
#     name = adapter.Column(adapter.String(254))
#     target = adapter.Column(adapter.String(254))
#     is_allow = adapter.Column(adapter.Boolean)
# 
# 
#     def __init__(self, data=None):
#         if data is None:
#             self.name = ''
#             self.target = ''
#             self.is_allow = False
#         else:
#             self.set_data(data)
# 
# 
#     def __repr__(self):
#         return create_repr_str(self)
# 
# 
#     def get_json(self):
#         return create_json(self)
# 
# 
#     def set_data(self, data):
#         self.error = None
#         self.name = data.get_request_parameter('name', default='')
#         self.target = data.get_request_parameter('target', default='')
#         self.is_allow = data.get_request_parameter('is_allow', default=False)
# 
# 
#     @classmethod
#     def get(cls, id):
#         if id is None:
#             role = KMRole()
#         else:
#             role = super(KMRole, cls).get(id=id)
#         return role


from kokemomo.plugins.engine.model.km_user_table import KMUser
from kokemomo.plugins.engine.model.km_group_table import KMGroup
from kokemomo.plugins.engine.model.km_role_table import KMRole
#!/usr/bin/env python
# -*- coding:utf-8 -*-

class KMUserAdmin:

    @classmethod
    def save_user(cls, data):
        id = data.get_request_parameter("id")
        delete = data.get_request_parameter("delete", default=None)
        if delete is None:
            user = KMUser.get(id)
            user.set_data(data)
            user.save()
        else:
            KMUser.delete_by_id(id)

    @classmethod
    def save_group(cls, data):
        id = data.get_request_parameter("id")
        delete = data.get_request_parameter("delete", default=None)
        if delete is None:

# Path: kokemomo/plugins/engine/model/km_user_table.py
# class KMUser(adapter.Model):
#     __tablename__ = 'km_user'
#     id = adapter.Column(adapter.Integer, autoincrement=True, primary_key=True)
#     user_id = adapter.Column(adapter.String(50))
#     name = adapter.Column(adapter.String(254))
#     password = adapter.Column(adapter.String(254))
#     mail_address = adapter.Column(adapter.String(254))
#     group_id = adapter.Column(adapter.Integer)
#     role_id = adapter.Column(adapter.Integer)
# 
#     def __init__(self, data=None):
#         if data is None:
#             self.user_id= ''
#             self.name = ''
#             self.password = ''
#             self.mail_address = ''
#         else:
#             self.set_data(data)
# 
#     def __repr__(self):
#         return create_repr_str(self)
# 
#     def get_json(self):
#         return create_json(self)
# 
#     def set_data(self, data):
#         self.error = None
#         self.user_id = data.get_request_parameter('user_id', default='')
#         self.name = data.get_request_parameter('name', default='')
#         self.password = data.get_request_parameter('password', default='')
#         self.mail_address = data.get_request_parameter('mail_address', default='')
#         self.group_id = data.get_request_parameter('group_id', default=None)
#         self.role_id = data.get_request_parameter('role_id', default=None)
# 
#     def save(self, validate=True):
#         self.password = bcrypt.hashpw(self.password.encode(SETTINGS.CHARACTER_SET), bcrypt.gensalt())
#         super(KMUser, self).save()
# 
#     @classmethod
#     def get(cls, id):
#         if id is None:
#             user = KMUser()
#         else:
#             user = super(KMUser, cls).get(id=id)
#         return user
# 
# Path: kokemomo/plugins/engine/model/km_group_table.py
# class KMGroup(adapter.Model):
#     __tablename__ = 'km_group'
#     id = adapter.Column(adapter.Integer, autoincrement=True, primary_key=True)
#     name = adapter.Column(adapter.String(254))
#     parent_id = adapter.Column(adapter.Integer)
# 
# 
#     def __init__(self, data=None):
#         if data is None:
#             self.name = ''
#             self.parent_id = -1
#         else:
#             self.set_data(data)
# 
# 
#     def __repr__(self):
#         return create_repr_str(self)
# 
# 
#     def get_json(self):
#         return create_json(self)
# 
# 
#     def set_data(self, data):
#         self.error = None
#         self.name = data.get_request_parameter('name', default='')
#         self.parent_id = data.get_request_parameter('parent_id', default=-1)
# 
# 
#     @classmethod
#     def get(cls, id):
#         if id is None:
#             group = KMGroup()
#         else:
#             group = super(KMGroup, cls).get(id=id)
#         return group
# 
# Path: kokemomo/plugins/engine/model/km_role_table.py
# class KMRole(adapter.Model):
#     __tablename__ = 'km_role'
#     id = adapter.Column(adapter.Integer, autoincrement=True, primary_key=True)
#     name = adapter.Column(adapter.String(254))
#     target = adapter.Column(adapter.String(254))
#     is_allow = adapter.Column(adapter.Boolean)
# 
# 
#     def __init__(self, data=None):
#         if data is None:
#             self.name = ''
#             self.target = ''
#             self.is_allow = False
#         else:
#             self.set_data(data)
# 
# 
#     def __repr__(self):
#         return create_repr_str(self)
# 
# 
#     def get_json(self):
#         return create_json(self)
# 
# 
#     def set_data(self, data):
#         self.error = None
#         self.name = data.get_request_parameter('name', default='')
#         self.target = data.get_request_parameter('target', default='')
#         self.is_allow = data.get_request_parameter('is_allow', default=False)
# 
# 
#     @classmethod
#     def get(cls, id):
#         if id is None:
#             role = KMRole()
#         else:
#             role = super(KMRole, cls).get(id=id)
#         return role


# Path: kokemomo/plugins/admin/model/km_user_admin.py
from kokemomo.plugins.engine.model.km_user_table import KMUser
from kokemomo.plugins.engine.model.km_group_table import KMGroup
from kokemomo.plugins.engine.model.km_role_table import KMRole

#!/usr/bin/env python
# -*- coding:utf-8 -*-

class KMUserAdmin:

    @classmethod
    def save_user(cls, data):
        id = data.get_request_parameter("id")
        delete = data.get_request_parameter("delete", default=None)
        if delete is None:
            user = KMUser.get(id)
            user.set_data(data)
            user.save()
        else:
            KMUser.delete_by_id(id)

    @classmethod
    def save_group(cls, data):
        id = data.get_request_parameter("id")
        delete = data.get_request_parameter("delete", default=None)
        if delete is None:

            group = KMGroup.get(id)