blob: 9ace688bca0abdbad11585d0a792d1193d09699b [file] [log] [blame]
from rest_framework import serializers
""" PlusSerializerMixin
Implements Serializer fields that are common to all OpenCloud objects. For
example, stuff related to backend fields.
"""
class PlusSerializerMixin():
backendIcon = serializers.SerializerMethodField("getBackendIcon")
backendHtml = serializers.SerializerMethodField("getBackendHtml")
# This will cause a descendant class to pull in the methods defined
# above. See rest_framework/serializers.py: _get_declared_fields().
base_fields = {"backendIcon": backendIcon, "backendHtml": backendHtml}
# Rest_framework 3.0 uses _declared_fields instead of base_fields
_declared_fields = {"backendIcon": backendIcon, "backendHtml": backendHtml}
def getBackendIcon(self, obj):
return obj.getBackendIcon()
def getBackendHtml(self, obj):
return obj.getBackendHtml()