Commit 69d47632 by aa.gusti

user departemen

2 parents c1c0479e 0f2bd501
...@@ -271,7 +271,11 @@ def append_csv(table, filename, keys, get_file_func=get_file, ...@@ -271,7 +271,11 @@ def append_csv(table, filename, keys, get_file_func=get_file,
# Penambahan checking field nullable false wajib ada datanya 2024-09-05 # Penambahan checking field nullable false wajib ada datanya 2024-09-05
for c in columns_table: for c in columns_table:
if (not c["nullable"] and c["name"] not in data and c["name"] != "id"): # if (not c["nullable"] and c["name"] not in data and c["name"] != "id"):
if (not c["nullable"] and c["name"] not in data and c["name"] != "id") and c["default"] is None:
# update: tambah periksa nilai default.
# Jika default=None berarti wajib ada nilainya
# by tatang 2024-10-12
raise Exception( raise Exception(
f"Table {str(table.__name__)} Field '{c['name']}' wajib ada {c['type']} ") f"Table {str(table.__name__)} Field '{c['name']}' wajib ada {c['type']} ")
......
...@@ -17,11 +17,18 @@ class UserArea(DefaultModel, Base): ...@@ -17,11 +17,18 @@ class UserArea(DefaultModel, Base):
@classmethod @classmethod
def allow_area(cls, user_id, desa_id=None, desa_kd=None, def allow_area(cls, user_id, desa_id=None, desa_kd=None,
group_names=("Superuser", "pbbm-admin"), ): group_names=("Superuser", "pbbm-admin"), ):
<<<<<<< HEAD
user = UserGroup.query().filter_by(user_id = user_id).outerjoin( user = UserGroup.query().filter_by(user_id = user_id).outerjoin(
Group, Group.id == UserGroup.group_id).filter( Group, Group.id == UserGroup.group_id).filter(
Group.group_name._in(*group_names)).first() Group.group_name._in(*group_names)).first()
if user and user.id: if user and user.id:
=======
user = UserGroup.query().filter(user_id == user_id).outerjoin(
Group, Group.id == UserGroup.group_id).filter(
Group.group_name.in_(group_names)).first()
if user and user.user_id:
>>>>>>> 0f2bd50199cb24a1f7080c0f664126a56f675ea9
return True return True
if not desa_id and not desa_kd: if not desa_id and not desa_kd:
......
...@@ -36,6 +36,10 @@ class UserGroup(UserGroupMixin, Base, CommonModel): ...@@ -36,6 +36,10 @@ class UserGroup(UserGroupMixin, Base, CommonModel):
return DBSession.query(cls).filter_by(user_id=user.id).all() return DBSession.query(cls).filter_by(user_id=user.id).all()
@classmethod @classmethod
def query(cls):
return DBSession.query(cls)
@classmethod
def get_by_user(cls, user): def get_by_user(cls, user):
groups = [] groups = []
for g in cls._get_by_user(user): for g in cls._get_by_user(user):
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!