Пример #1
0
    def update(self, updates):
        query = {'_id': self._id}
        update = {**updates, "isEdited": True, "action": Log.actions['UPDATE']}
        Database.update_one(Log.collection, query, update)
        updatedCursor = Log.get_by_id(self._id)

        return updatedCursor
Пример #2
0
    def set_new_title(self, title):
        query = {'_id': self._id}
        update = {'title': title}
        Database.update_one(Checklist.collection, query, update)
        updatedChecklist = Checklist.get_by_id(self._id).dict_from_class()

        return updatedChecklist
Пример #3
0
 def add_label(self, label):
     Database.update_one('cards', {'_id': self._id}, {"labels": []})
     if type(label) is dict:
         Database.update_push('cards', {'_id': self._id}, {"labels": label})
     elif type(label) is list:
         [
             Database.update_push('cards', {'_id': self._id},
                                  {"labels": lebl}) for lebl in label
         ]
Пример #4
0
    def add_attachment(self, file, content_type, file_name):
        filedId = FS.put(file, content_type, file_name)
        query = {'_id': self._id}

        if len(self.attachments['files']) == 0:
            Database.update_one(Card.collection, query,
                                {'attachments.assigned': filedId})

        Database.update_push(Card.collection, query,
                             {'attachments.files': filedId})

        _, cursorCard = Card.get_card_by_id(self._id)

        return cursorCard, filedId
Пример #5
0
    def assign_attachment_file(self, fileId):
        query = {'_id': self._id}
        if fileId == self.attachments['assigned']:
            Database.update_one(Card.collection, query,
                                {'attachments.assigned': ''})
        else:
            Database.update_one(Card.collection, query,
                                {'attachments.assigned': fileId})

        cursorCard = Database.find_one(Card.collection, query)
        return {
            **cursorCard, 'attachments': {
                'assigned': cursorCard['attachments']['assigned']
            }
        }
Пример #6
0
    def update(self, updates):
        isUpdatedResult = Database.update_one(Board.collection,
                                              {'_id': self._id}, {**updates})

        if isUpdatedResult.raw_result['nModified'] == 1:
            return {'_id': self._id, **updates, 'reletedTo': self.reletedTo}

        return "Nothink to update"
Пример #7
0
    def update_team(self, updates):
        updatedClass = Database.update_one(Team.collection, {'_id': self._id},
                                           {**updates})

        if updatedClass.raw_result['nModified'] == 1:
            return {**updates, '_id': self._id}

        return "THERE IS NOTHINK TO UPDATE"
Пример #8
0
    def update_user_info(self, updates):
        updatedClass = Database.update_one(User.collection, {'_id': self._id}, {**updates})

        if updatedClass.raw_result['nModified']  == 1:
            return {**updates, '_id' : self._id}

        # userWutkUpdatedData = User.get_user_by_id_cursor(self._id)

        return "We dont uppdate actualy nothink"
Пример #9
0
 def update_comment(self, updates):
     commentId = Database.update_one('comments', {'_id': self._id}, {
         'description': updates,
         'isEdited': True
     })
     if commentId.acknowledged:
         cursor, _ = Comment.get_by_id(self._id)
         return cursor
     return "throw error cause nothink to update actually"
Пример #10
0
    def delete_attachment(self, fileId):
        query = {'_id': self._id}
        toRemoveFile = {'attachments.files': fileId}

        isRemoveFromFs = FS.delete(fileId)

        try:
            if isRemoveFromFs:
                if fileId == self.attachments['assigned']:
                    clearAssignment = {'attachments.assigned': ''}
                    Database.update_one(Card.collection, query,
                                        clearAssignment)

                Database.delete_one_from_array(Card.collection, query,
                                               toRemoveFile)

            return {**query, 'forList': self.forList, 'deletedFile': fileId}
        except:
            raise "The file is not exist with — {} | id".format(fileId)
Пример #11
0
 def toggleBoardImportant(self, isImportant):
     Database.update_one('boards', {'_id': self._id},
                         {'isImportant': isImportant})
     cursorBoard = Database.find_one('boards', {'_id': self._id})
     return cursorBoard
Пример #12
0
    def upload_photo(self, file, content_type, file_name):
        imageId = FS.put(file, content_type, file_name)

        Database.update_one('users', {'_id': self._id}, {'photo': imageId})

        return imageId
Пример #13
0
    def update_item(self, itemId, title):
        query = {'_id': self._id, 'items._id': itemId}
        toUpdate = {'items.$.title': title}
        Database.update_one(Checklist.collection, query, toUpdate)

        return self._id
Пример #14
0
    def toggle_item(self, itemId, isCompleted):
        query = {'_id': self._id, 'items._id': itemId}
        toUpdate = {'items.$.isCompleted': isCompleted}
        Database.update_one(Checklist.collection, query, toUpdate)

        return self._id
Пример #15
0
 def update(self, updates):
     updatedClass = Database.update_one(List.collection, {'_id': self._id}, {**updates})
     if updatedClass.raw_result['nModified']  == 1:
             return {'_id' : self._id, 'forBoard': self.forBoard, **updates}
     return "Nothink to update"
Пример #16
0
 def update_card(self, update):
     curdId = Database.update_one('cards', {'_id': self._id}, {**update})
     return curdId