diff --git a/generalApp/AbstractCRUD.py b/generalApp/AbstractCRUD.py index ffb9d3e..5607dea 100644 --- a/generalApp/AbstractCRUD.py +++ b/generalApp/AbstractCRUD.py @@ -5,6 +5,7 @@ from .utilities import * class ValidationUtils(): + @classmethod def fromDict(self, dict): self.__dict__.update(dict) @@ -78,6 +79,7 @@ class AbstractGet(AbstractUtilsCRUD): """ return HttpResponse(self.__getAllByParentID(parentID)) + @classmethod def __getAllByParentID(self, parentID): list = [ x.toDict() @@ -109,12 +111,14 @@ class AbstractCreate(AbstractUtilsCRUD): else: return HttpResponse("No Permission") + @classmethod def _validateUnique(self, userDict): """ use validate in override this method """ return True - + + @classmethod def _saveObject(self, objectDict): """ save object without parent @@ -132,13 +136,14 @@ class AbstractCreate(AbstractUtilsCRUD): object = jsonLoad(request) if checkSession(request, privilige): if self._validateUnique(object): - return self._saveObject(parentID, object) + return self._saveObjectWithParent(parentID, object) else: return HttpResponse("Object Is Already Exist") else: return HttpResponse("No Permission") - - def _saveObject(self, parentID, objectDict): + + @classmethod + def _saveObjectWithParent(self, parentID, objectDict): """ save object with parent & subject + comment & set trigger time """ @@ -152,15 +157,18 @@ class AbstractCreate(AbstractUtilsCRUD): newObject.save() return HttpResponse(f"Add new Object: {newObject.toDict()}") + @classmethod def _createFirstComment(self, newSubject, objectDict): pass - + + @classmethod def _setActualTimeTrigger(self): pass - + class Meta: abstract = True + class AbstractUpdate(AbstractUtilsCRUD): """ This class have a abstract `update` @@ -173,7 +181,8 @@ class AbstractUpdate(AbstractUtilsCRUD): return self._updateObject(object, objectID) else: return HttpResponse("No Permission") - + + @classmethod def _updateObject(self, objectDict, objectID): objectOld = self._objectFactory().objects.get(pk = objectID) objectOld.fromDict(objectDict) diff --git a/generalApp/__pycache__/AbstractCRUD.cpython-36.pyc b/generalApp/__pycache__/AbstractCRUD.cpython-36.pyc index d7506b2..7b9c042 100644 Binary files a/generalApp/__pycache__/AbstractCRUD.cpython-36.pyc and b/generalApp/__pycache__/AbstractCRUD.cpython-36.pyc differ diff --git a/generalApp/__pycache__/methods.cpython-36.pyc b/generalApp/__pycache__/methods.cpython-36.pyc index 9faf4e0..72844c0 100644 Binary files a/generalApp/__pycache__/methods.cpython-36.pyc and b/generalApp/__pycache__/methods.cpython-36.pyc differ diff --git a/generalApp/__pycache__/models.cpython-36.pyc b/generalApp/__pycache__/models.cpython-36.pyc index 7218bef..b7a84e4 100644 Binary files a/generalApp/__pycache__/models.cpython-36.pyc and b/generalApp/__pycache__/models.cpython-36.pyc differ diff --git a/generalApp/__pycache__/utilities.cpython-36.pyc b/generalApp/__pycache__/utilities.cpython-36.pyc old mode 100755 new mode 100644 index 54da211..ec62e28 Binary files a/generalApp/__pycache__/utilities.cpython-36.pyc and b/generalApp/__pycache__/utilities.cpython-36.pyc differ diff --git a/generalApp/__pycache__/views.cpython-36.pyc b/generalApp/__pycache__/views.cpython-36.pyc old mode 100755 new mode 100644 index a3c4c37..caa5f78 Binary files a/generalApp/__pycache__/views.cpython-36.pyc and b/generalApp/__pycache__/views.cpython-36.pyc differ diff --git a/generalApp/methods.py b/generalApp/methods.py index ecf5bf2..6a58713 100755 --- a/generalApp/methods.py +++ b/generalApp/methods.py @@ -18,11 +18,11 @@ def checkTriggerNotification(): # Exchange POST Methods -def addTrigger(request, userID): - return Triggers.addObject(request, userID, 1) +def addTrigger(request): + return Triggers.addObject(request, 1) -def addTransaction(request, userID): - return Transactions.addObject(request, userID, 1) +def addTransaction(request): + return Transactions.addObject(request, 1) def Prognosis(request, time, price): return ExchangeVO.createActualPrognosis(request, time, price, 1) diff --git a/generalApp/models.py b/generalApp/models.py index 79e0195..4687db8 100755 --- a/generalApp/models.py +++ b/generalApp/models.py @@ -219,7 +219,7 @@ class Threads(AbstractCRUD): # Object Factory for abstract - def objectFactory(): + def _objectFactory(): return Threads # Create Thread (validation) @@ -257,7 +257,7 @@ class Subjects(AbstractCRUD): # Object Factory for abstract - def objectFactory(): + def _objectFactory(): return Subjects # Create Subject ( create new subject + comment ones ) @@ -297,7 +297,7 @@ class Comments(AbstractCRUD): # Object Factory for abstract - def objectFactory(): + def _objectFactory(): return Comments @@ -325,7 +325,7 @@ class Ratings(AbstractCRUD): # Object Factory for abstract - def objectFactory(): + def _objectFactory(): return Ratings # Create Ratings (validate) @@ -368,7 +368,7 @@ class Transactions(AbstractCRUD): # Object Factory for abstract - def objectFactory(): + def _objectFactory(): return Transactions @@ -396,7 +396,7 @@ class Triggers(AbstractCRUD): # Object Factory for abstract - def objectFactory(): + def _objectFactory(): return Triggers # Create Trigger (set actual time) @@ -424,5 +424,5 @@ class Notifications(AbstractCRUD): # Object Factory for abstract - def objectFactory(): + def _objectFactory(): return Notifications diff --git a/generalApp/views.py b/generalApp/views.py index 539fc98..3d29999 100755 --- a/generalApp/views.py +++ b/generalApp/views.py @@ -122,7 +122,7 @@ def transactions(request, userID): if request.method == 'GET': return getUserTransactions(request, userID) elif request.method == 'POST': - return addTransaction(request, userID) + return addTransaction(request) else: return HttpResponse('Bad Request Method') @@ -146,7 +146,7 @@ def triggers(request, userID): if request.method == 'GET': return getUserTriggers(request, userID) elif request.method == 'POST': - return addTrigger(request, userID) + return addTrigger(request) else: return HttpResponse('Bad Request Method')