blob: 1e4cdf56d994c29c6fd85a19167d2c35d410fbf0 [file] [log] [blame]
Scott Bakere791dc62014-08-28 14:02:54 -07001from rest_framework import serializers
2
3""" PlusSerializerMixin
4
5 Implements Serializer fields that are common to all OpenCloud objects. For
6 example, stuff related to backend fields.
7"""
8
9class PlusSerializerMixin():
10 backendIcon = serializers.SerializerMethodField("getBackendIcon")
11 backendHtml = serializers.SerializerMethodField("getBackendHtml")
12
13 # This will cause a descendant class to pull in the methods defined
14 # above. See rest_framework/serializers.py: _get_declared_fields().
15 base_fields = {"backendIcon": backendIcon, "backendHtml": backendHtml}
16
17 def getBackendIcon(self, obj):
18 return obj.getBackendIcon()
19
20 def getBackendHtml(self, obj):
21 return obj.getBackendHtml()
22