Esempio n. 1
0
class WebhookLogSerializer(serializers.ModelSerializer):
    request_data = JsonField()
    request_headers = JsonField()
    response_headers = JsonField()

    class Meta:
        model = WebhookLog
Esempio n. 2
0
class HistoryEntrySerializer(serializers.ModelSerializer):
    diff = HistoryDiffField()
    snapshot = JsonField()
    values = JsonField()
    user = JsonField()
    delete_comment_user = JsonField()

    class Meta:
        model = history_models.HistoryEntry
Esempio n. 3
0
class HistoryEntrySerializer(serializers.ModelSerializer):
    diff = JsonField()
    snapshot = JsonField()
    values = JsonField()
    values_diff = JsonField()
    user = JsonField()

    class Meta:
        model = models.HistoryEntry
Esempio n. 4
0
class StorageEntrySerializer(serializers.ModelSerializer):
    value = JsonField(label="value")

    class Meta:
        model = models.StorageEntry
        fields = ("key", "value", "created_date", "modified_date")
        read_only_fields = ("created_date", "modified_date")
Esempio n. 5
0
class ProjectExportSerializer(serializers.ModelSerializer):
    owner = UserRelatedField(required=False)
    default_points = serializers.SlugRelatedField(slug_field="name", required=False)
    default_us_status = serializers.SlugRelatedField(slug_field="name", required=False)
    default_task_status = serializers.SlugRelatedField(slug_field="name", required=False)
    default_priority = serializers.SlugRelatedField(slug_field="name", required=False)
    default_severity = serializers.SlugRelatedField(slug_field="name", required=False)
    default_issue_status = serializers.SlugRelatedField(slug_field="name", required=False)
    default_issue_type = serializers.SlugRelatedField(slug_field="name", required=False)
    memberships = MembershipExportSerializer(many=True, required=False)
    points = PointsExportSerializer(many=True, required=False)
    us_statuses = UserStoryStatusExportSerializer(many=True, required=False)
    task_statuses = TaskStatusExportSerializer(many=True, required=False)
    issue_statuses = IssueStatusExportSerializer(many=True, required=False)
    priorities = PriorityExportSerializer(many=True, required=False)
    severities = SeverityExportSerializer(many=True, required=False)
    issue_types = IssueTypeExportSerializer(many=True, required=False)
    roles = RoleExportSerializer(many=True, required=False)
    milestones = MilestoneExportSerializer(many=True, required=False)
    wiki_pages = WikiPageExportSerializer(many=True, required=False)
    wiki_links = WikiLinkExportSerializer(many=True, required=False)
    user_stories = UserStoryExportSerializer(many=True, required=False)
    tasks = TaskExportSerializer(many=True, required=False)
    issues = IssueExportSerializer(many=True, required=False)
    tags_colors = JsonField(required=False)
    anon_permissions = PgArrayField(required=False)
    public_permissions = PgArrayField(required=False)
    modified_date = serializers.DateTimeField(required=False)

    class Meta:
        model = projects_models.Project
        exclude = ('id', 'creation_template', 'members')
Esempio n. 6
0
class BaseCustomAttributesValuesExportSerializer(serializers.ModelSerializer):
    attributes_values = JsonField(source="attributes_values", required=True)
    _custom_attribute_model = None
    _container_field = None

    class Meta:
        exclude = ("id", )

    def validate_attributes_values(self, attrs, source):
        # values must be a dict
        data_values = attrs.get("attributes_values", None)
        if self.object:
            data_values = (data_values or self.object.attributes_values)

        if type(data_values) is not dict:
            raise ValidationError(
                _("Invalid content. It must be {\"key\": \"value\",...}"))

        # Values keys must be in the container object project
        data_container = attrs.get(self._container_field, None)
        if data_container:
            project_id = data_container.project_id
        elif self.object:
            project_id = getattr(self.object, self._container_field).project_id
        else:
            project_id = None

        values_ids = list(data_values.keys())
        qs = self._custom_attribute_model.objects.filter(project=project_id,
                                                         id__in=values_ids)
        if qs.count() != len(values_ids):
            raise ValidationError(_("It contain invalid custom fields."))

        return attrs
Esempio n. 7
0
class ProjectTemplateSerializer(ModelSerializer):
    default_options = JsonField(required=False, label=_("Default options"))
    us_statuses = JsonField(required=False, label=_("User story's statuses"))
    points = JsonField(required=False, label=_("Points"))
    task_statuses = JsonField(required=False, label=_("Task's statuses"))
    issue_statuses = JsonField(required=False, label=_("Issue's statuses"))
    issue_types = JsonField(required=False, label=_("Issue's types"))
    priorities = JsonField(required=False, label=_("Priorities"))
    severities = JsonField(required=False, label=_("Severities"))
    roles = JsonField(required=False, label=_("Roles"))

    class Meta:
        model = models.ProjectTemplate
Esempio n. 8
0
class HistoryExportSerializer(serializers.ModelSerializer):
    user = HistoryUserField()
    diff = HistoryDiffField(required=False)
    snapshot = JsonField(required=False)
    values = HistoryValuesField(required=False)
    comment = CommentField(required=False)
    delete_comment_user = HistoryUserField(required=False)

    class Meta:
        model = history_models.HistoryEntry
        exclude = ("id", "comment_html", "key")
Esempio n. 9
0
class TimelineSerializer(serializers.ModelSerializer):
    data = JsonField()

    class Meta:
        model = models.Timeline