blob: f753620cda7d1b2e1398994595427109d0a16ac0 [file] [log] [blame]
Scott Bakerdcf6fbf2015-01-11 13:45:19 -08001from rest_framework import generics
Scott Bakere791dc62014-08-28 14:02:54 -07002from rest_framework import serializers
Scott Bakerdcf6fbf2015-01-11 13:45:19 -08003from rest_framework.response import Response
4from rest_framework import status
Scott Baker8974e552015-02-10 19:26:00 -08005from xosapibase import XOSRetrieveUpdateDestroyAPIView, XOSListCreateAPIView
Scott Bakere791dc62014-08-28 14:02:54 -07006
7""" PlusSerializerMixin
8
9 Implements Serializer fields that are common to all OpenCloud objects. For
10 example, stuff related to backend fields.
11"""
12
13class PlusSerializerMixin():
14 backendIcon = serializers.SerializerMethodField("getBackendIcon")
15 backendHtml = serializers.SerializerMethodField("getBackendHtml")
16
17 # This will cause a descendant class to pull in the methods defined
18 # above. See rest_framework/serializers.py: _get_declared_fields().
19 base_fields = {"backendIcon": backendIcon, "backendHtml": backendHtml}
Scott Bakera4ac3a82014-12-23 11:04:27 -080020 # Rest_framework 3.0 uses _declared_fields instead of base_fields
21 _declared_fields = {"backendIcon": backendIcon, "backendHtml": backendHtml}
Scott Bakere791dc62014-08-28 14:02:54 -070022
23 def getBackendIcon(self, obj):
24 return obj.getBackendIcon()
25
26 def getBackendHtml(self, obj):
27 return obj.getBackendHtml()
28
Scott Bakercba0ffe2015-02-03 15:02:17 -080029
Scott Bakercba0ffe2015-02-03 15:02:17 -080030
Scott Bakerbbc8a5b2015-01-12 12:57:22 -080031
Scott Bakerdcf6fbf2015-01-11 13:45:19 -080032