-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ Issue #509 + #510] Series views #589
base: main
Are you sure you want to change the base?
Changes from all commits
fe7c868
4770c98
8659bef
ca73edf
c7fb7df
330d2b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 %} | ||
|
||
<div> | ||
<h1>{{ series.name }}</h1> | ||
</div> | ||
|
||
<table class="patch-meta"> | ||
<tr> | ||
<th>Cover Letter</th> | ||
<td>{{ series.cover_letter.content|default:"No cover letter available" }}</td> | ||
</tr> | ||
<tr> | ||
<th>Date</th> | ||
<td>{{ series.date }}</td> | ||
</tr> | ||
<tr> | ||
<th>Submitter</th> | ||
<td>{{ series.submitter }}</td> | ||
</tr> | ||
<tr> | ||
<th>Total</th> | ||
<td>{{ series.patches }}</td> | ||
</tr> | ||
</table> | ||
<br> | ||
<h2>Patches</h2> | ||
<br> | ||
{% include "patchwork/partials/patch-list.html" %} | ||
|
||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" %} | ||
|
||
<input type="hidden" name="form" value="serieslistform"/> | ||
<input type="hidden" name="project" value="{{project.id}}"/> | ||
|
||
<table id="serieslist" class="table table-hover table-extra-condensed table-striped pw-list" data-toggle="checkboxes" data-range="true"> | ||
<thead> | ||
<tr> | ||
{% if user.is_authenticated and user.profile.show_ids %} | ||
<th> | ||
ID | ||
</th> | ||
{% endif %} | ||
|
||
<th> | ||
<span class="series-list-header">Series</span> | ||
</th> | ||
|
||
<th> | ||
Version | ||
</th> | ||
|
||
<th> | ||
<span class="series-list-header">Cover Letter</span> | ||
</th> | ||
|
||
<th> | ||
<span class="series-list-header">Patches</span> | ||
</th> | ||
|
||
<th> | ||
{% if 'date.asc' == order %} | ||
<a href="{% listurl order='date.desc' %}" class="colactive"> | ||
<span class="glyphicon glyphicon-chevron-up"></span> | ||
{% elif 'date.desc' == order %} | ||
<a href="{% listurl order='date.asc' %}" class="colactive"> | ||
<span class="glyphicon glyphicon-chevron-down"></span> | ||
{% endif %} | ||
<span class="series-list-header">Date</span> | ||
{% if 'date.asc' == order or 'date.desc' == order%} | ||
</a> | ||
{% endif %} | ||
</th> | ||
|
||
<th> | ||
<span class="series-list-header">Submitter</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
{% for series in page %} | ||
<tr id="series_row:{{series.id}}"> | ||
{% if user.is_authenticated and user.profile.show_ids %} | ||
<td> | ||
<button type="button" class="btn btn-xs btn-copy" data-clipboard-text="{{ series.id }}" title="Copy to Clipboard"> | ||
{{ series.id }} | ||
</button> | ||
</td> | ||
{% endif %} | ||
<td> | ||
<a href="{% url 'series-detail' project_id=project.linkname series_id=series.id %}?state=*"> | ||
{{ series.name|default:"[no subject]"|truncatechars:100 }} | ||
</a> | ||
</td> | ||
<td> | ||
{{ series.version|default:"-"}} | ||
</td> | ||
|
||
<td> | ||
{% if series.cover_letter.content %} | ||
<b>✓</b> | ||
{% else %} | ||
- | ||
{% endif %} | ||
</td> | ||
<td>{{ series.received_total}}</td> | ||
<td class="text-nowrap">{{ series.date|date:"Y-m-d" }}</td> | ||
<td>{{ series.submitter|personify:project }}</td> | ||
</tr> | ||
{% empty %} | ||
<tr> | ||
<td colspan="8">No series to display</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
{% if page.paginator.count %} | ||
{% include "patchwork/partials/pagination.html" %} | ||
{% endif %} | ||
{% endblock %} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fold this into the previous patch 🙏 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,9 +33,19 @@ | |
path('', project_views.project_list, name='project-list'), | ||
path( | ||
'project/<project_id>/list/', | ||
patch_views.patch_list_redirect, | ||
name='patch-list-redirect', | ||
), | ||
path( | ||
'project/<project_id>/patches/', | ||
patch_views.patch_list, | ||
name='patch-list', | ||
), | ||
path( | ||
'project/<project_id>/series/', | ||
series_views.series_list, | ||
name='series-list', | ||
), | ||
path( | ||
'project/<project_id>/bundles/', | ||
bundle_views.bundle_list, | ||
|
@@ -110,6 +120,11 @@ | |
name='comment-redirect', | ||
), | ||
# series views | ||
path( | ||
'project/<project_id>/series/<int:series_id>/', | ||
series_views.series_detail, | ||
name='series-detail', | ||
), | ||
path( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we have a proper series view, could you add a new view for |
||
'series/<int:series_id>/mbox/', | ||
series_views.series_mbox, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,18 @@ | |
# Copyright (C) 2017 Stephen Finucane <[email protected]> | ||
# | ||
# 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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
features: | ||
- | | ||
A series view is now available, allowing users to list available series and | ||
view details of individual series. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need tests for this also.