-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add serializer for the progress models.
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from gettext import gettext as _ | ||
|
||
from rest_framework import serializers | ||
|
||
from pulp.app import models | ||
from pulp.app.serializers import ModelSerializer | ||
|
||
|
||
class ProgressReportSerializer(ModelSerializer): | ||
|
||
message = serializers.CharField( | ||
help_text=_("The message shown to the user for the progress report."), | ||
read_only=True | ||
) | ||
|
||
state = serializers.CharField( | ||
help_text=_("The current state of the progress report. The possible values are:" | ||
" 'waiting', 'skipped', 'running', 'completed', 'failed' and 'canceled'." | ||
" The default is 'waiting'."), | ||
read_only=True | ||
) | ||
|
||
total = serializers.IntegerField( | ||
help_text=_("The total count of items to be handled by the ProgressBar."), | ||
read_only=True | ||
) | ||
|
||
done = serializers.IntegerField( | ||
help_text=_("The count of items already processed. Defaults to 0."), | ||
read_only=True | ||
) | ||
|
||
task = serializers.HyperlinkedRelatedField( | ||
help_text=_("The task associated with this progress report."), | ||
read_only=True, | ||
view_name='tasks-detail' | ||
) | ||
|
||
class Meta: | ||
model = models.ProgressReport | ||
# this serializer is meant to be nested inside Task serializer, | ||
# so it will not have its own endpoint, that's why | ||
# we need to explicitly define fields to exclude '_href' field. | ||
fields = ('message', 'state', 'total', 'done', 'task') |