How to use the productmd.common.RELEASE_SHORT_RE function in productmd

To help you get started, we’ve selected a few productmd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github product-definition-center / product-definition-center / pdc / apps / release / models.py View on Github external
short               = models.CharField(max_length=255, blank=False, unique=True)
    name                = models.CharField(max_length=255, blank=False, unique=True)
    suffix              = models.CharField(max_length=255, blank=True, unique=True)

    class Meta:
        ordering = ('short', 'name', 'suffix')

    def __unicode__(self):
        return u"%s" % self.short


class BaseProduct(models.Model):
    # base_product_id is populated by populate_base_product_id() pre_save hook
    base_product_id     = models.CharField(max_length=200, blank=False, unique=True)
    short = models.CharField(max_length=200, validators=[
        RegexValidator(regex=RELEASE_SHORT_RE.pattern, message='Only accept lowercase letters, numbers or -')])
    version             = models.CharField(max_length=200)
    name                = models.CharField(max_length=255)
    release_type        = models.ForeignKey(ReleaseType, blank=False, db_index=True, on_delete=models.CASCADE)

    class Meta:
        unique_together = (
            ("short", "version", "release_type"),
            ("name", "version", "release_type"),
        )
        ordering = ("base_product_id", )

    def __unicode__(self):
        return unicode(self.base_product_id)

    def get_base_product_id(self):
        return create_release_id(self.short.lower(), self.version, self.release_type.short)