From fbafc3de84d724f3e838787e336e5bb1c4649cf6 Mon Sep 17 00:00:00 2001 From: TBS093A Date: Sat, 29 Aug 2020 15:31:07 +0200 Subject: [PATCH] upgrade AbstractGet class --- generalApp/AbstractCRUD.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/generalApp/AbstractCRUD.py b/generalApp/AbstractCRUD.py index 322fcad..fd099fb 100644 --- a/generalApp/AbstractCRUD.py +++ b/generalApp/AbstractCRUD.py @@ -32,6 +32,8 @@ class AbstractUtilsCRUD(): class AbstractGet(AbstractUtilsCRUD): + + parent_id_field = '' @classmethod def getObject(self, objectID): @@ -47,11 +49,12 @@ class AbstractGet(AbstractUtilsCRUD): return HttpResponse(json.dumps(objectsAll)) @classmethod - def getObjectsByParentID(self, request, parentID): - return HttpResponse(self.getAllByParentID(parentID)) + def getObjectsByParentID(self, parentID): + return HttpResponse(self.__getAllByParentID(parentID)) def __getAllByParentID(self, parentID): - list = [ x.toDict() for x in self.objectFactory().__get.objects.filter(subject_id = parentID)] + list = [ x.toDict() for x in self.objectFactory() + .__get.objects.filter(**{ parent_id_field: parentID })] return json.dumps(list)