From 881a965df913c0b4e21e22c13f5b9571a1df3a0b Mon Sep 17 00:00:00 2001 From: xiao-kong-long <2745240762@qq.com> Date: Wed, 29 Nov 2023 19:23:06 +0800 Subject: [PATCH] design a function that dumps customized object to json data, just change for group class --- src/casdoor/group.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/casdoor/group.py b/src/casdoor/group.py index 0fee9e6..5d12103 100644 --- a/src/casdoor/group.py +++ b/src/casdoor/group.py @@ -32,10 +32,10 @@ def __init__(self): self.type = "" self.parentId = "" self.isTopGroup = False - # self.users = [User] + self.users = [User] self.title = "" self.key = "" - # self.children = [Group] + self.children = [Group] self.isEnabled = False @classmethod @@ -118,8 +118,8 @@ def modify_group(self, method: str, group: Group) -> Dict: "clientSecret": self.client_secret, } - group_info = json.dumps(group.to_dict()) - # group_info = json.dumps(group.to_dict(), default=self.custom_encoder) + # group_info = json.dumps(group.to_dict()) + group_info = json.dumps(group.to_dict(), default=self.custom_encoder) r = requests.post(url, params=params, data=group_info) response = r.json() if response["status"] != "ok": @@ -139,6 +139,6 @@ def delete_group(self, group: Group) -> Dict: response = self.modify_group("delete-group", group) return response - # def custom_encoder(self, o): - # if isinstance(o, (Group, User)): - # return o.__dict__ \ No newline at end of file + def custom_encoder(self, o): + if isinstance(o, (Group, User)): + return o.__dict__ \ No newline at end of file