Skip to content

Commit

Permalink
Merge pull request #8179 from readthedocs/humitos/use-is-active-for-skip
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos authored May 18, 2021
2 parents 42e09be + 9090eb9 commit 8909c2a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions readthedocs/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ProjectAdminSerializer(ProjectSerializer):
)

environment_variables = serializers.SerializerMethodField()
skip = serializers.SerializerMethodField()

def get_environment_variables(self, obj):
"""Get all environment variables, including public ones."""
Expand All @@ -58,6 +59,15 @@ def get_environment_variables(self, obj):
for variable in obj.environmentvariable_set.all()
}

def get_skip(self, obj):
"""
Override ``Project.skip`` to consider more cases whether skip a project.
We rely on ``.is_active`` manager's method here that encapsulates all
these possible cases.
"""
return not Project.objects.is_active(obj)

class Meta(ProjectSerializer.Meta):
fields = ProjectSerializer.Meta.fields + (
'enable_epub_build',
Expand Down

0 comments on commit 8909c2a

Please sign in to comment.