コード例 #1
0
ファイル: sync.py プロジェクト: Leonidpopob/tasks
 def updateCategories(self, requestObject):
     result = []
     valuesForUpdate = self.getObjectsByType(requestObject, "DouiTodoCategories")
     for value in valuesForUpdate:
         category = DouiTodoCategory(user = users.get_current_user(), 
                                     userId = users.get_current_user().user_id())
         category.createCategory(value)
         requestItems = self.getObjectsByType(requestObject, "DouiTodoItem")
         for item in requestItems:
             if(item[Sync.JSON_UPDATE_ITEM_FK_CATEGORY] == value[Sync.JSON_UPDATE_OBJECT_CLIENT_ID]):
                 item[Sync.JSON_UPDATE_ITEM_FK_CATEGORY] = value[Sync.JSON_UPDATED_OBJECT_KEY]
         result.append(value)
     return result
コード例 #2
0
ファイル: sync.py プロジェクト: Leonidpopob/tasks
 def generateKeys(self, requestObject):
     ''' This method generate new key values for entities received from client. '''
     statusValues = self.getObjectsByType(requestObject, "DouiTodoStatus")
     status = DouiTodoStatus(user = users.get_current_user(), userId = users.get_current_user().user_id())
     for item in statusValues:
         status.generateKeys(item)
     
     categoriesValues = self.getObjectsByType(requestObject, "DouiTodoCategories")
     category = DouiTodoCategory(user = users.get_current_user(), userId = users.get_current_user().user_id())
     for item in categoriesValues:
         category.generateKeys(item)
     
     items = self.getItems(requestObject)
     
     if(items["itemsCount"] > 0):
         DouiTodoItem.generateKeys(items)
     else:
         items["itemsKeys"] = [] 
             
     return  json.dumps(requestObject, cls = doui_model.jsonEncoder)