示例#1
0
文件: pcle.py 项目: esimorre/openplm
 def setUp(self):
     self.registered_PCLEs = list(models.registered_PCLEs)
     models.register_PCLE(MockExtension)
     models.register_PCLE(InvisibleMockExtension)
     super(ParentChildLinkExtensionTestCase, self).setUp()
     self.controller = self.CONTROLLER.create("aPart1", self.TYPE, "a",
                                              self.user, self.DATA)
     self.controller.name = u"mockextension"
     self.controller.save()
     self.controller2 = self.CONTROLLER.create("aPart2", self.TYPE, "a",
                                               self.user, self.DATA)
     self.controller2.name = u"imockextension"
     self.controller2.save()
     self.controller3 = self.CONTROLLER.create("aPart3", self.TYPE, "a",
                                               self.user, self.DATA)
示例#2
0
    """
    required = models.BooleanField(verbose_name=_("required"), default=False)
    version_range = models.CharField(verbose_name=_("version range"),
                                     max_length=50,
                                     blank=True)

    def __unicode__(self):
        return u"DependencyLink<%d,%s>" % (self.required, self.version_range)

    @classmethod
    def get_visible_fields(cls):
        return (
            "required",
            "version_range",
        )

    @classmethod
    def apply_to(cls, parent):
        return isinstance(parent, Software)

    def clone(self, link, save, **data):
        req = data.get("required", self.required)
        clone = DependencyLink(link=link, required=req)
        if save:
            clone.save()
        return clone


register(DependencyLink)
register_PCLE(DependencyLink)
示例#3
0
                              x4=x4,
                              y1=y1,
                              y2=y2,
                              y3=y3,
                              y4=y4,
                              z1=z1,
                              z2=z2,
                              z3=z3,
                              z4=z4)
        if save:
            clone.save()
        return clone


#admin.site.register(Location_link)
pmodels.register_PCLE(Location_link)


def generate_extra_location_links(link, pcl):
    """
    Creates all :class:`Location_link` bound to *link and *pcl*.

    :param link: :class:`.openPLM.apps.document3D.classes.Link` which will be used to create :class:`.Location_link`
    :type plmobject: :class:`.Link`
    :param ParentChildLink: Parent child link that is extended
    :type plmobject: :class:`.ParentChildLink`

    """
    # Location_link inherits from PCLE: it is not possible to call bulk_create
    for i in range(link.quantity):
        loc = Location_link()
示例#4
0
文件: models.py 项目: amarh/openPLM
    def get_visible_fields(cls):
        return ("reference_designator", )

    @classmethod
    def apply_to(cls, parent):
        return isinstance(parent, MotherBoard)

    def clone(self, link, save, **data):
        ref = data.get("reference_designator", self.reference_designator)
        clone = ReferenceDesignator(link=link, reference_designator=ref)
        if save:
            clone.save()
        return clone

register(ReferenceDesignator)
register_PCLE(ReferenceDesignator)


class RAM(SinglePart):
    size_in_mo = models.PositiveIntegerField(verbose_name=_("size in mo"))

    @property
    def attributes(self):
        attrs = list(super(RAM, self).attributes)
        attrs.extend(["size_in_mo"])
        return attrs

register(RAM)


class HardDisk(SinglePart):
示例#5
0
文件: models.py 项目: amarh/openPLM
    :model attributes:
        .. attribute:: required

           a boolean that indicate wether the depency is required or not
    """
    required = models.BooleanField(verbose_name=_("required"), default=False)
    version_range = models.CharField(verbose_name=_("version range"), max_length=50,blank=True)

    def __unicode__(self):
        return u"DependencyLink<%d,%s>" % (self.required, self.version_range)

    @classmethod
    def get_visible_fields(cls):
        return ("required","version_range", )

    @classmethod
    def apply_to(cls, parent):
        return isinstance(parent, Software)


    def clone(self, link, save, **data):
        req = data.get("required", self.required)
        clone = DependencyLink(link=link, required=req)
        if save:
            clone.save()
        return clone

register(DependencyLink)
register_PCLE(DependencyLink)

示例#6
0
文件: models.py 项目: amarh/openPLM
        z2 = data.get("z2", self.z2)
        z3 = data.get("z3", self.z3)
        z4 = data.get("z4", self.z4)

        name = data.get("name", self.name)
        clone = Location_link(link=link, name=name,
                x1=x1, x2=x2, x3=x3, x4=x4,
                y1=y1, y2=y2, y3=y3, y4=y4,
                z1=z1,z2=z2,z3=z3,z4=z4)
        if save:
            clone.save()
        return clone


#admin.site.register(Location_link)
pmodels.register_PCLE(Location_link)


def generate_extra_location_links(link, pcl):
    """
    Creates all :class:`Location_link` bound to *link and *pcl*.

    :param link: :class:`.openPLM.apps.document3D.classes.Link` which will be used to create :class:`.Location_link`
    :type plmobject: :class:`.Link`
    :param ParentChildLink: Parent child link that is extended
    :type plmobject: :class:`.ParentChildLink`

    """
    # Location_link inherits from PCLE: it is not possible to call bulk_create
    for i in range(link.quantity):
        loc = Location_link()