def change_status(self, id): """ Change Status to Active :return: """ payload = update_timestamp() payload["meta.is_archived"], payload["meta.is_deleted"] = False, False base_obj.update(COLLECTIONS['INVENTORIES'], {"_id": ObjectId(id)}, {"$set": payload})
def archive_inventory(self, id): """ Archive inventory :return: """ payload = update_timestamp() payload["meta.is_archived"], payload["meta.is_deleted"] = True, False base_obj.update(COLLECTIONS['INVENTORIES'], {"_id": ObjectId(id)}, {"$set": payload})
def delete_inventory(self, id): """ Delete inventory :return: """ count, records = base_obj.get(COLLECTIONS['INVENTORIES'], {"_id": ObjectId(id)}) if count != 1: abort(400, "inventory Already Deleted") payload = update_timestamp() payload["meta.is_archived"], payload["meta.is_deleted"] = False, True base_obj.update(COLLECTIONS['INVENTORIES'], {"_id": ObjectId(id)}, {"$set": payload})
def change_status(self, id): """ Change Status to Active :param id: :return: """ payload = update_timestamp() email = get_jwt_identity() payload["meta.is_archived"], payload["meta.is_deleted"] = False, False result = base_obj.update(COLLECTIONS['ROOMS'], { "_id": ObjectId(id), "meta.created_by": email }, {"$set": payload}) if not result.modified_count: abort(401, "Unauthorized")
def archive_task(self, taskroom_id, task_id): """ Update the task id with payload :param taskroom_id: :param task_id: :param payload: :return: """ email = get_jwt_identity() payload = update_timestamp(prefix="tasks.$") payload["tasks.$.meta.is_archived"], payload[ "tasks.$.meta.is_deleted"] = True, False result = base_obj.update( COLLECTIONS['ROOMS'], { '_id': ObjectId(taskroom_id), "tasks._id": ObjectId(task_id), "users": email }, {"$set": payload}) print(payload, result)