Пример #1
0
    def revisions(cls, material_id):
        """

        :param basestring|ObjectId material_id:
        :return [Schematic]:
        """
        return Schematic.manager.find(
            cond={'material_id': doc._objectid(material_id)})
Пример #2
0
    def pair_exists(cls, material_id, rev_id, conf_size):
        """
        validate if material_id + rev_id + conf_size exist.

        :param material_id:
        :param rev_id:
        :param conf_size:
        :return:
        """
        return 0 < Schematic.manager.count(
            cond={
                'material_id': doc._objectid(material_id),
                'rev_id': rev_id,
                'conf_size': conf_size
            })
Пример #3
0
    def handle(self, **options):
        op_id = options.get('task_operation_doc_id', None)
        action = options.get('action', None)
        if not op_id:
            raise ValueError('--op is required.')

        tasks = TaskDoc.manager.find(cond={
            '_id': _objectid(op_id)
        })
        if len(tasks) < 1:
            raise ValueError('Failed to load task=%s' % op_id)
        task = tasks[0]

        if action == "release":
            print "Releasing %s" % op_id
            task.release(user=IntraUser.robot())
        else:
            raise ValueError('Unknown action: %s' % action)
Пример #4
0
    def of(cls, material_id, revision_id, throw=False):
        """

        :param basestring|ObjectId material_id:
        :param int revision_id:
        :param bool throw:
        :return Schematic:
        """
        o = Schematic.manager.find(cond={
            'material_id': doc._objectid(material_id),
            'rev_id': revision_id
        })
        if len(o) == 0:
            if throw:
                raise ValueError('Unknown material+revision=%s+%s' %
                                 (material_id, revision_id))
            else:
                return None
        return o[0]
Пример #5
0
 def get(code):
     candidates = DesignUID.manager.find(1, 0, _id=_objectid(code))
     if len(candidates) == 0:
         return None
     return candidates[0]