diff --git a/htdocs/css/style.css b/htdocs/css/style.css index 268a8c37..cba33cf9 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -407,6 +407,12 @@ span.p_mod { color: #a020f0; } font-weight: bold; } +/* series */ +a.series-list-header { + color: inherit; /* Inherit color from parent element */ + text-decoration: none; /* Optional: removes underline */ +} + /* bundles */ table.bundlelist { margin-top: 2em; diff --git a/patchwork/templates/patchwork/series-detail.html b/patchwork/templates/patchwork/series-detail.html new file mode 100644 index 00000000..d38d7b9f --- /dev/null +++ b/patchwork/templates/patchwork/series-detail.html @@ -0,0 +1,41 @@ +{% extends "base.html" %} + +{% load humanize %} +{% load syntax %} +{% load person %} +{% load patch %} +{% load static %} +{% load utils %} + +{% block title %}{{series.name}}{% endblock %} + +{% block body %} + +
+

{{ series.name }}

+
+ + + + + + + + + + + + + + + + + + +
Cover Letter{{ series.cover_letter.content|default:"No cover letter available" }}
Date{{ series.date }}
Submitter{{ series.submitter }}
Total{{ series.patches }}
+
+

Patches

+
+{% include "patchwork/partials/patch-list.html" %} + +{% endblock %} diff --git a/patchwork/templates/patchwork/series-list.html b/patchwork/templates/patchwork/series-list.html new file mode 100644 index 00000000..bd23c252 --- /dev/null +++ b/patchwork/templates/patchwork/series-list.html @@ -0,0 +1,108 @@ +{% extends "base.html" %} + +{% load person %} +{% load static %} + +{% block title %}{{project.name}}{% endblock %} +{% block series_active %}active{% endblock %} + +{% block body %} + +{% load person %} +{% load listurl %} +{% load patch %} +{% load project %} +{% load static %} + +{% include "patchwork/partials/pagination.html" %} + + + + + + + +{% if user.is_authenticated and user.profile.show_ids %} + +{% endif %} + + + + + + + + + + + + + + + + +{% for series in page %} + +{% if user.is_authenticated and user.profile.show_ids %} + +{% endif %} + + + + + + + + +{% empty %} + + + +{% endfor %} + +
+ ID + + Series + + Version + + Cover Letter + + Patches + + {% if 'date.asc' == order %} + + + {% elif 'date.desc' == order %} + + + {% endif %} + Date + {% if 'date.asc' == order or 'date.desc' == order%} + + {% endif %} + + Submitter +
+ + + + {{ series.name|default:"[no subject]"|truncatechars:100 }} + + + {{ series.version|default:"-"}} + + {% if series.cover_letter.content %} + + {% else %} + - + {% endif %} + {{ series.received_total}}{{ series.date|date:"Y-m-d" }}{{ series.submitter|personify:project }}
No series to display
+ +{% if page.paginator.count %} +{% include "patchwork/partials/pagination.html" %} +{% endif %} +{% endblock %} diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index cd74491c..88ad58aa 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -20,6 +20,20 @@

{{ submission.name }}

+
+ + next + +
+ +
+ + previous + +
+ diff --git a/patchwork/tests/views/test_series.py b/patchwork/tests/views/test_series.py new file mode 100644 index 00000000..c37a98df --- /dev/null +++ b/patchwork/tests/views/test_series.py @@ -0,0 +1,51 @@ +# Patchwork - automated patch tracking system +# Copyright (C) 2024 Meta Platforms, Inc. and affiliates. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from datetime import datetime as dt + +from django.test import TestCase +from django.urls import reverse + +from patchwork.models import Person +from patchwork.tests.utils import create_patch +from patchwork.tests.utils import create_cover +from patchwork.tests.utils import create_person +from patchwork.tests.utils import create_project +from patchwork.tests.utils import create_series +from patchwork.tests.utils import create_user + + +class SeriesList(TestCase): + def setUp(self): + self.project = create_project() + self.user = create_user() + self.person_1 = Person.objects.get(user=self.user) + self.person_2 = create_person() + self.series_1 = create_series(project=self.project) + self.series_2 = create_series(project=self.project) + create_cover(project=self.project, series=self.series_1) + + for i in range(5): + create_patch( + submitter=self.person_1, + project=self.project, + series=self.series_1, + date=dt(2014, 3, 16, 13, 4, 50, 155643), + ) + create_patch( + submitter=self.person_2, + project=self.project, + series=self.series_2, + date=dt(2014, 3, 16, 13, 4, 50, 155643), + ) + + def test_series_list(self): + requested_url = reverse( + 'series-list', + kwargs={'project_id': self.project.linkname}, + ) + response = self.client.get(requested_url) + + self.assertEqual(response.status_code, 200) diff --git a/patchwork/urls.py b/patchwork/urls.py index ecd3668d..63a2a0e2 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -33,9 +33,19 @@ path('', project_views.project_list, name='project-list'), path( 'project//list/', + patch_views.patch_list_redirect, + name='patch-list-redirect', + ), + path( + 'project//patches/', patch_views.patch_list, name='patch-list', ), + path( + 'project//series/', + series_views.series_list, + name='series-list', + ), path( 'project//bundles/', bundle_views.bundle_list, @@ -110,6 +120,11 @@ name='comment-redirect', ), # series views + path( + 'project//series//', + series_views.series_detail, + name='series-detail', + ), path( 'series//mbox/', series_views.series_mbox, diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index efe94f17..e1f86ef2 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -10,6 +10,7 @@ from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.shortcuts import render +from django.shortcuts import redirect from django.urls import reverse from patchwork.forms import CreateBundleForm @@ -38,6 +39,11 @@ def patch_list(request, project_id): return render(request, 'patchwork/list.html', context) +def patch_list_redirect(request, project_id): + new_url = reverse('patch-list', kwargs={'project_id': project_id}) + return redirect(f'{new_url}?{request.GET.urlencode()}') + + def patch_detail(request, project_id, msgid): project = get_object_or_404(Project, linkname=project_id) db_msgid = Patch.decode_msgid(msgid) @@ -127,6 +133,20 @@ def patch_detail(request, project_id, msgid): if errors: context['errors'] = errors + try: + context['previous_submission'] = Patch.objects.get( + series=patch.series, number=patch.number - 1 + ) + except Patch.DoesNotExist: + context['previous_submission'] = None + + try: + context['next_submission'] = Patch.objects.get( + series=patch.series, number=patch.number + 1 + ) + except Patch.DoesNotExist: + context['next_submission'] = None + return render(request, 'patchwork/submission.html', context) diff --git a/patchwork/views/series.py b/patchwork/views/series.py index a8892ae6..a36b8041 100644 --- a/patchwork/views/series.py +++ b/patchwork/views/series.py @@ -2,12 +2,18 @@ # Copyright (C) 2017 Stephen Finucane # # SPDX-License-Identifier: GPL-2.0-or-later +import collections from django.http import HttpResponse from django.shortcuts import get_object_or_404 +from django.shortcuts import render from patchwork.models import Series +from patchwork.models import Patch +from patchwork.models import Project +from patchwork.views import generic_list from patchwork.views.utils import series_to_mbox +from patchwork.paginator import Paginator def series_mbox(request, series_id): @@ -20,3 +26,64 @@ def series_mbox(request, series_id): ) return response + + +def series_detail(request, project_id, series_id): + series = get_object_or_404(Series, id=series_id) + + patches = Patch.objects.filter(series=series) + + context = generic_list( + request, + series.project, + 'series-detail', + view_args={ + 'project_id': project_id, + 'series_id': series_id, + }, + patches=patches, + ) + + context.update({'series': series}) + + return render(request, 'patchwork/series-detail.html', context) + + +def series_list(request, project_id): + project = get_object_or_404(Project, linkname=project_id) + sort = request.GET.get('order', 'date.desc') + sort_field, sort_dir = sort.split('.') + sort_order = f"{'-' if sort_dir == 'desc' else ''}{sort_field}" + context = {} + series_list = ( + Series.objects.filter(project=project) + .only( + 'submitter', + 'project', + 'version', + 'name', + 'date', + 'id', + 'cover_letter', + ) + .select_related('project', 'submitter', 'cover_letter') + .order_by(sort_order) + ) + + paginator = Paginator(request, series_list) + context.update( + { + 'project': project, + 'projects': Project.objects.all(), + 'series_list': series_list, + 'page': paginator.current_page, + 'order': sort, + 'list_view': { + 'view': 'series-list', + 'view_params': {'project_id': project.linkname}, + 'params': collections.OrderedDict(), + }, + } + ) + + return render(request, 'patchwork/series-list.html', context) diff --git a/releasenotes/notes/add_series_list_view-bf219022216fea6a.yaml b/releasenotes/notes/add_series_list_view-bf219022216fea6a.yaml new file mode 100644 index 00000000..c8b32e6a --- /dev/null +++ b/releasenotes/notes/add_series_list_view-bf219022216fea6a.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + A series view is now available, allowing users to list available series and + view details of individual series. diff --git a/templates/base.html b/templates/base.html index 9519ecc5..49663d7f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -48,6 +48,12 @@ {% block navbarmenu %} {% if project %}
Message ID