moved to meta class
@@ -115,9 +115,6 @@ class BuildSerializer(FlexFieldsModelSerializer):
state = BuildStateSerializer(source='*')
_links = BuildLinksSerializer(source='*')
- expandable_fields = {
- 'config': (BuildConfigSerializer, {'source': 'config'})
- }
class Meta:
model = Build
@@ -135,6 +132,10 @@ class BuildSerializer(FlexFieldsModelSerializer):
'_links',
]
+ expandable_fields = {
+ 'config': (BuildConfigSerializer, {'source': 'config'})
+ }
+
def get_finished(self, obj):
if obj.date and obj.length:
return obj.date + datetime.timedelta(seconds=obj.length)
@@ -210,10 +211,6 @@ class VersionSerializer(FlexFieldsModelSerializer):
urls = VersionURLsSerializer(source='*')
_links = VersionLinksSerializer(source='*')
- expandable_fields = {
- 'last_build': (BuildSerializer, {'source': 'last_build'})
- }
-
class Meta:
model = Version
fields = [
@@ -231,6 +228,12 @@ class VersionSerializer(FlexFieldsModelSerializer):
'_links',
]
+ expandable_fields = {
+ 'last_build': (
+ BuildSerializer, {'source': 'last_build'}
+ )
+ }
+
def get_downloads(self, obj):
downloads = obj.get_downloads()
data = {}
@@ -438,17 +441,6 @@ class ProjectSerializer(FlexFieldsModelSerializer):
created = serializers.DateTimeField(source='pub_date')
modified = serializers.DateTimeField(source='modified_date')
- expandable_fields = {
- 'active_versions': (
- VersionSerializer,
- {
- # NOTE: this has to be a Model method, can't be a
- # ``SerializerMethodField`` as far as I know
- 'source': 'active_versions',
- 'many': True,
- }
- )
- }
class Meta:
model = Project
@@ -479,6 +471,17 @@ class ProjectSerializer(FlexFieldsModelSerializer):
'_links',
]
+ expandable_fields = {
+ 'active_versions': (VersionSerializer,
+ {
+ # NOTE: this has to be a Model method, can't be a
+ # ``SerializerMethodField`` as far as I know
+ 'source': 'active_versions',
+ 'many': True,
+ }
+ )
+ }
+
def get_homepage(self, obj):
# Overridden only to return ``None`` when the project_url is ``''``
return obj.project_url or None
