How to use the productmd.images.SUPPORTED_IMAGE_FORMATS 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 / package / models.py View on Github external
def sync_image_formats_and_types():
    logger = logging.getLogger(__name__)
    missing_image_formats = set(images.SUPPORTED_IMAGE_FORMATS) - set([obj.name for obj in ImageFormat.objects.all()])
    missing_image_types = set(images.SUPPORTED_IMAGE_TYPES) - set([obj.name for obj in ImageType.objects.all()])

    for image_format in missing_image_formats:
        ImageFormat.objects.create(name=image_format)
        logger.info("Created image format %s" % image_format)
    for image_type in missing_image_types:
        ImageType.objects.create(name=image_type)
        logger.info("Created image type %s" % image_type)
github product-definition-center / product-definition-center / pdc / apps / package / serializers.py View on Github external
from django.contrib.contenttypes.models import ContentType
from rest_framework import serializers
from rest_framework.reverse import reverse

from productmd import images

from . import models
from pdc.apps.compose.models import ComposeAcceptanceTestingState
from pdc.apps.common.fields import ChoiceSlugField
from pdc.apps.common.serializers import StrictSerializerMixin
from pdc.apps.repository.serializers import RepoField


class ImageFormatSerializer(serializers.SlugRelatedField):
    doc_format = " | ".join(images.SUPPORTED_IMAGE_FORMATS)

    def __init__(self):
        super(ImageFormatSerializer, self).__init__(
            slug_field='name',
            queryset=models.ImageFormat.objects.all())


class ImageTypeSerializer(serializers.SlugRelatedField):
    doc_format = " | ".join(images.SUPPORTED_IMAGE_TYPES)

    def __init__(self):
        super(ImageTypeSerializer, self).__init__(
            slug_field='name',
            queryset=models.ImageType.objects.all())