[PATCH v2 4/7] api: Add list archive fields
Stephen Finucane
stephen at that.guru
Fri Apr 17 20:40:40 AEST 2020
On Thu, 2019-08-22 at 17:13 +1000, Andrew Donnellan wrote:
> Add the new list archive fields to the API. As this is a
> backwards-compatible change, this requires only a minor version increment
> to v1.2.
>
> Signed-off-by: Andrew Donnellan <ajd at linux.ibm.com>
> ---
> v1->v2:
> - switch to using format string (Daniel)
> ---
> patchwork/api/comment.py | 5 +++--
> patchwork/api/cover.py | 6 ++++--
> patchwork/api/embedded.py | 14 +++++++++++---
> patchwork/api/patch.py | 15 ++++++++-------
> patchwork/api/project.py | 7 +++++--
> patchwork/urls.py | 4 ++--
> 6 files changed, 33 insertions(+), 18 deletions(-)
>
> diff --git a/patchwork/api/comment.py b/patchwork/api/comment.py
> index 57b37111c30b..290b9cd3f3ce 100644
> --- a/patchwork/api/comment.py
> +++ b/patchwork/api/comment.py
> @@ -47,11 +47,12 @@ class CommentListSerializer(BaseHyperlinkedModelSerializer):
>
> class Meta:
> model = Comment
> - fields = ('id', 'web_url', 'msgid', 'date', 'subject', 'submitter',
> - 'content', 'headers')
> + fields = ('id', 'web_url', 'msgid', 'list_archive_url', 'date',
> + 'subject', 'submitter', 'content', 'headers')
> read_only_fields = fields
> versioned_fields = {
> '1.1': ('web_url', ),
> + '1.2': ('list_archive_url',),
> }
>
>
> diff --git a/patchwork/api/cover.py b/patchwork/api/cover.py
> index 7a663226ade8..caf9a386efa5 100644
> --- a/patchwork/api/cover.py
> +++ b/patchwork/api/cover.py
> @@ -50,11 +50,13 @@ class CoverLetterListSerializer(BaseHyperlinkedModelSerializer):
>
> class Meta:
> model = CoverLetter
> - fields = ('id', 'url', 'web_url', 'project', 'msgid', 'date', 'name',
> - 'submitter', 'mbox', 'series', 'comments')
> + fields = ('id', 'url', 'web_url', 'project', 'msgid',
> + 'list_archive_url', 'date', 'name', 'submitter', 'mbox',
> + 'series', 'comments')
> read_only_fields = fields
> versioned_fields = {
> '1.1': ('web_url', 'mbox', 'comments'),
> + '1.2': ('list_archive_url',),
> }
> extra_kwargs = {
> 'url': {'view_name': 'api-cover-detail'},
> diff --git a/patchwork/api/embedded.py b/patchwork/api/embedded.py
> index 60fb9a4e9701..968cb7f91f10 100644
> --- a/patchwork/api/embedded.py
> +++ b/patchwork/api/embedded.py
> @@ -108,10 +108,12 @@ class CoverLetterSerializer(SerializedRelatedField):
>
> class Meta:
> model = models.CoverLetter
> - fields = ('id', 'url', 'web_url', 'msgid', 'date', 'name', 'mbox')
> + fields = ('id', 'url', 'web_url', 'msgid', 'list_archive_url',
> + 'date', 'name', 'mbox')
I don't know how I missed this, but this shouldn't have been included
in the embedded responses. Those are supposed to be summary views with
the bare minimum fields necessary to avoid making unnecessary second
requests. This doesn't really qualify :-\ Ditto for the other entries
below (maybe project scrapes in, but barely). Probably a bit late to
drop this now but I think we should do so in API v2.0.
Stephen
> read_only_fields = fields
> versioned_fields = {
> '1.1': ('web_url', 'mbox', ),
> + '1.2': ('list_archive_url',),
> }
> extra_kwargs = {
> 'url': {'view_name': 'api-cover-detail'},
> @@ -124,10 +126,12 @@ class PatchSerializer(SerializedRelatedField):
>
> class Meta:
> model = models.Patch
> - fields = ('id', 'url', 'web_url', 'msgid', 'date', 'name', 'mbox')
> + fields = ('id', 'url', 'web_url', 'msgid', 'list_archive_url',
> + 'date', 'name', 'mbox')
> read_only_fields = fields
> versioned_fields = {
> '1.1': ('web_url', ),
> + '1.2': ('list_archive_url',),
> }
> extra_kwargs = {
> 'url': {'view_name': 'api-patch-detail'},
> @@ -158,11 +162,15 @@ class ProjectSerializer(SerializedRelatedField):
> class Meta:
> model = models.Project
> fields = ('id', 'url', 'name', 'link_name', 'list_id',
> - 'list_email', 'web_url', 'scm_url', 'webscm_url')
> + 'list_email', 'web_url', 'scm_url', 'webscm_url',
> + 'list_archive_url', 'list_archive_url_format')
> read_only_fields = fields
> extra_kwargs = {
> 'url': {'view_name': 'api-project-detail'},
> }
> + versioned_fields = {
> + '1.2': ('list_archive_url', 'list_archive_url_format'),
> + }
>
>
> class SeriesSerializer(SerializedRelatedField):
> diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py
> index 05f6cea84c45..c9360308a56a 100644
> --- a/patchwork/api/patch.py
> +++ b/patchwork/api/patch.py
> @@ -121,15 +121,16 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer):
>
> class Meta:
> model = Patch
> - fields = ('id', 'url', 'web_url', 'project', 'msgid', 'date', 'name',
> - 'commit_ref', 'pull_url', 'state', 'archived', 'hash',
> - 'submitter', 'delegate', 'mbox', 'series', 'comments',
> - 'check', 'checks', 'tags')
> - read_only_fields = ('web_url', 'project', 'msgid', 'date', 'name',
> - 'hash', 'submitter', 'mbox', 'series', 'comments',
> - 'check', 'checks', 'tags')
> + fields = ('id', 'url', 'web_url', 'project', 'msgid',
> + 'list_archive_url', 'date', 'name', 'commit_ref', 'pull_url',
> + 'state', 'archived', 'hash', 'submitter', 'delegate', 'mbox',
> + 'series', 'comments', 'check', 'checks', 'tags')
> + read_only_fields = ('web_url', 'project', 'msgid', 'list_archive_url',
> + 'date', 'name', 'hash', 'submitter', 'mbox',
> + 'series', 'comments', 'check', 'checks', 'tags')
> versioned_fields = {
> '1.1': ('comments', 'web_url'),
> + '1.2': ('list_archive_url',),
> }
> extra_kwargs = {
> 'url': {'view_name': 'api-patch-detail'},
> diff --git a/patchwork/api/project.py b/patchwork/api/project.py
> index d7bb1f21cd09..62a8c3e73efe 100644
> --- a/patchwork/api/project.py
> +++ b/patchwork/api/project.py
> @@ -26,11 +26,13 @@ class ProjectSerializer(BaseHyperlinkedModelSerializer):
> model = Project
> fields = ('id', 'url', 'name', 'link_name', 'list_id', 'list_email',
> 'web_url', 'scm_url', 'webscm_url', 'maintainers',
> - 'subject_match')
> + 'subject_match', 'list_archive_url',
> + 'list_archive_url_format')
> read_only_fields = ('name', 'link_name', 'list_id', 'list_email',
> 'maintainers', 'subject_match')
> versioned_fields = {
> '1.1': ('subject_match', ),
> + '1.2': ('list_archive_url', 'list_archive_url_format'),
> }
> extra_kwargs = {
> 'url': {'view_name': 'api-project-detail'},
> @@ -68,7 +70,8 @@ class ProjectList(ProjectMixin, ListAPIView):
> """List projects."""
>
> search_fields = ('link_name', 'list_id', 'list_email', 'web_url',
> - 'scm_url', 'webscm_url')
> + 'scm_url', 'webscm_url', 'list_archive_url',
> + 'list_archive_url_format')
> ordering_fields = ('id', 'name', 'link_name', 'list_id')
> ordering = 'id'
>
> diff --git a/patchwork/urls.py b/patchwork/urls.py
> index cfcf04dc3b71..c24bf55ee83f 100644
> --- a/patchwork/urls.py
> +++ b/patchwork/urls.py
> @@ -234,8 +234,8 @@ if settings.ENABLE_REST_API:
> ]
>
> urlpatterns += [
> - url(r'^api/(?:(?P<version>(1.0|1.1))/)?', include(api_patterns)),
> - url(r'^api/(?:(?P<version>1.1)/)?', include(api_1_1_patterns)),
> + url(r'^api/(?:(?P<version>(1.0|1.1|1.2))/)?', include(api_patterns)),
> + url(r'^api/(?:(?P<version>(1.1|1.2))/)?', include(api_1_1_patterns)),
>
> # token change
> url(r'^user/generate-token/$', user_views.generate_token,
More information about the Patchwork
mailing list