def group_to_user_insert(self, request): my_items = GroupToUserMessageCollection(items=request.items) for item in my_items.items: query = GroupToUserModel.query(GroupToUserModel.uuid == item.uuid) if query.count() == 0: GroupToUserModel( uuid=item.uuid, deleted=item.deleted, last_modified=date_to_utc(item.last_modified), group=item.group, user=item.user, ).put() else: groupToUser = query.get() groupToUser.last_modified = date_to_utc(item.last_modified) groupToUser.deleted = item.deleted groupToUser.group = item.group groupToUser.user = item.user groupToUser.put() return message_types.VoidMessage()
def group_to_user_sync_down(self, request): query = GroupToUserModel.query(GroupToUserModel.last_modified > string_to_datetime(request.date)) my_items = [] for group_to_user in query: my_items.append( GroupToUserMessage( last_modified=group_to_user.last_modified, uuid=group_to_user.uuid, deleted=group_to_user.deleted, group=group_to_user.group, user=group_to_user.user, ) ) return GroupToUserMessageCollection(items=my_items)