blob: 9ace688bca0abdbad11585d0a792d1193d09699b [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}
Scott Bakera4ac3a82014-12-23 11:04:27 -080016 # Rest_framework 3.0 uses _declared_fields instead of base_fields
17 _declared_fields = {"backendIcon": backendIcon, "backendHtml": backendHtml}
Scott Bakere791dc62014-08-28 14:02:54 -070018
19 def getBackendIcon(self, obj):
20 return obj.getBackendIcon()
21
22 def getBackendHtml(self, obj):
23 return obj.getBackendHtml()
24