class IssueSerializer(WatchersValidator, ModelSerializer): tags = TagsField(required=False) external_reference = PgArrayField(required=False) is_closed = serializers.Field(source="is_closed") comment = serializers.SerializerMethodField("get_comment") generated_user_stories = serializers.SerializerMethodField( "get_generated_user_stories") blocked_note_html = serializers.SerializerMethodField( "get_blocked_note_html") description_html = serializers.SerializerMethodField( "get_description_html") votes = serializers.SerializerMethodField("get_votes_number") class Meta: model = models.Issue read_only_fields = ('id', 'ref', 'created_date', 'modified_date') def get_comment(self, obj): # NOTE: This method and field is necessary to historical comments work return "" def get_generated_user_stories(self, obj): return obj.generated_user_stories.values("id", "ref", "subject") def get_blocked_note_html(self, obj): return mdrender(obj.project, obj.blocked_note) def get_description_html(self, obj): return mdrender(obj.project, obj.description) def get_votes_number(self, obj): # The "votes_count" attribute is attached in the get_queryset of the viewset. return getattr(obj, "votes_count", 0)
class TaskSerializer(WatchersValidator, ModelSerializer): tags = TagsField(required=False, default=[]) external_reference = PgArrayField(required=False) comment = serializers.SerializerMethodField("get_comment") milestone_slug = serializers.SerializerMethodField("get_milestone_slug") blocked_note_html = serializers.SerializerMethodField("get_blocked_note_html") description_html = serializers.SerializerMethodField("get_description_html") is_closed = serializers.SerializerMethodField("get_is_closed") class Meta: model = models.Task read_only_fields = ('id', 'ref', 'created_date', 'modified_date') def get_comment(self, obj): return "" def get_milestone_slug(self, obj): if obj.milestone: return obj.milestone.slug else: return None def get_blocked_note_html(self, obj): return mdrender(obj.project, obj.blocked_note) def get_description_html(self, obj): return mdrender(obj.project, obj.description) def get_is_closed(self, obj): return obj.status.is_closed
class TaskSerializer(serializers.ModelSerializer): tags = TagsField(default=[], required=False) owner = UserSerializer() assigned_to = UserSerializer() watchers = UserSerializer(many=True) class Meta: model = task_models.Task
class UserStorySerializer(serializers.ModelSerializer): tags = TagsField(default=[], required=False) external_reference = PgArrayField(required=False) owner = UserSerializer() assigned_to = UserSerializer() watchers = UserSerializer(many=True) points = PointSerializer(many=True) class Meta: model = us_models.UserStory exclude = ("backlog_order", "sprint_order", "kanban_order", "version")
class IssueSerializer(CustomAttributesValuesWebhookSerializerMixin, serializers.ModelSerializer): tags = TagsField(default=[], required=False) owner = UserSerializer() assigned_to = UserSerializer() watchers = UserSerializer(many=True) class Meta: model = issue_models.Issue def custom_attributes_queryset(self, project): return project.issuecustomattributes.all()
class UserStorySerializer(WatchersValidator, serializers.ModelSerializer): tags = TagsField(default=[], required=False) external_reference = PgArrayField(required=False) points = RolePointsField(source="role_points", required=False) total_points = serializers.SerializerMethodField("get_total_points") comment = serializers.SerializerMethodField("get_comment") milestone_slug = serializers.SerializerMethodField("get_milestone_slug") milestone_name = serializers.SerializerMethodField("get_milestone_name") origin_issue = serializers.SerializerMethodField("get_origin_issue") blocked_note_html = serializers.SerializerMethodField( "get_blocked_note_html") description_html = serializers.SerializerMethodField( "get_description_html") class Meta: model = models.UserStory depth = 0 read_only_fields = ('created_date', 'modified_date') def get_total_points(self, obj): return obj.get_total_points() def get_comment(self, obj): # NOTE: This method and field is necessary to historical comments work return "" def get_milestone_slug(self, obj): if obj.milestone: return obj.milestone.slug else: return None def get_milestone_name(self, obj): if obj.milestone: return obj.milestone.name else: return None def get_origin_issue(self, obj): if obj.generated_from_issue: return { "id": obj.generated_from_issue.id, "ref": obj.generated_from_issue.ref, "subject": obj.generated_from_issue.subject, } return None def get_blocked_note_html(self, obj): return mdrender(obj.project, obj.blocked_note) def get_description_html(self, obj): return mdrender(obj.project, obj.description)
class UserStorySerializer(CustomAttributesValuesWebhookSerializerMixin, serializers.ModelSerializer): tags = TagsField(default=[], required=False) external_reference = PgArrayField(required=False) owner = UserSerializer() assigned_to = UserSerializer() watchers = UserSerializer(many=True) points = PointSerializer(many=True) class Meta: model = us_models.UserStory exclude = ("backlog_order", "sprint_order", "kanban_order", "version") def custom_attributes_queryset(self, project): return project.userstorycustomattributes.all()