示例#1
0
文件: api.py 项目: yxl201908/ralph
class FooSerializer(RalphAPISerializer):
    __str__ = StrField()
    str_with_type = StrField(show_type=True, label='__str2__')

    class Meta:
        model = Foo
        # include view namespace for hyperlinked field
        extra_kwargs = {'url': {'view_name': 'test-ralph-api:foo-detail'}}
示例#2
0
class ServiceEnvironmentSerializer(RalphAPISerializer):
    __str__ = StrField(show_type=True)

    class Meta:
        model = ServiceEnvironment
        depth = 1
        exclude = ('content_type', 'parent', 'service_env')
示例#3
0
class BaseObjectSimpleSerializer(TypeFromContentTypeSerializerMixin,
                                 WithCustomFieldsSerializerMixin,
                                 RalphAPISerializer):
    __str__ = StrField(show_type=True)

    class Meta:
        model = BaseObject
        exclude = ('content_type', )
示例#4
0
class ConfigurationClassSerializer(TypeFromContentTypeSerializerMixin,
                                   WithCustomFieldsSerializerMixin,
                                   RalphAPISerializer):
    __str__ = StrField(show_type=True)
    module = ConfigurationModuleSimpleSerializer()

    class Meta:
        model = ConfigurationClass
        exclude = ('content_type', 'service_env', 'configuration_path')
示例#5
0
class BaseObjectSerializer(RalphAPISerializer):
    """
    Base class for other serializers inheriting from `BaseObject`.
    """
    service_env = ServiceEnvironmentSimpleSerializer()
    licences = SimpleBaseObjectLicenceSerializer(read_only=True, many=True)
    __str__ = StrField(show_type=True)

    class Meta:
        model = BaseObject
        exclude = ('content_type', )
示例#6
0
class ServiceEnvironmentSerializer(TypeFromContentTypeSerializerMixin,
                                   WithCustomFieldsSerializerMixin,
                                   RalphAPISerializer):
    __str__ = StrField(show_type=True)
    business_owners = SimpleRalphUserSerializer(
        many=True, source='service.business_owners')
    technical_owners = SimpleRalphUserSerializer(
        many=True, source='service.technical_owners')

    class Meta:
        model = ServiceEnvironment
        depth = 1
        exclude = ('content_type', 'parent', 'service_env')
示例#7
0
class BaseObjectPolymorphicSerializer(TypeFromContentTypeSerializerMixin,
                                      PolymorphicSerializer,
                                      RalphAPISerializer):
    """
    Serializer for BaseObjects viewset (serialize each model using dedicated
    serializer).
    """
    __str__ = StrField(show_type=True)
    service_env = ServiceEnvironmentSerializer()
    scmstatuscheck = SCMInfoSerializer()

    class Meta:
        model = BaseObject
        exclude = ('content_type', )