-
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 1 commit
1799337
5878433
5cfa0dd
55f0276
ebe0397
edff002
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,98 @@ | ||
{% 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="colinactive">Series</span> | ||
</th> | ||
|
||
<th> | ||
Version | ||
</th> | ||
|
||
<th> | ||
<span class="colinactive">Cover Letter</span> | ||
</th> | ||
|
||
<th> | ||
<span class="colinactive">Patches</span> | ||
</th> | ||
|
||
<th> | ||
<span class="colinactive">Date</span> | ||
</th> | ||
|
||
<th> | ||
<span class="colinactive">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 %}"> | ||
{{ series.name|default:"[no subject]"|truncatechars:100 }} | ||
</a> | ||
Comment on lines
+68
to
+70
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. |
||
</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 %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,15 @@ | |
path('admin/', admin.site.urls), | ||
path('', project_views.project_list, name='project-list'), | ||
path( | ||
'project/<project_id>/list/', | ||
'project/<project_id>/patches/', | ||
patch_views.patch_list, | ||
name='patch-list', | ||
), | ||
Comment on lines
34
to
38
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. If you rename this you need to provide a redirect. There are existing examples of redirects here. Don't forget to preserve query string arguments though since those matter here but didn't matter for fetching e.g. patch mboxes. This should also be a separate commit, ideally placed before this one in the series. |
||
path( | ||
'project/<project_id>/series/', | ||
series_views.series_list, | ||
name='series-list', | ||
), | ||
path( | ||
'project/<project_id>/bundles/', | ||
bundle_views.bundle_list, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,16 @@ | |
# 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 Project | ||
from patchwork.views.utils import series_to_mbox | ||
from patchwork.paginator import Paginator | ||
|
||
|
||
def series_mbox(request, series_id): | ||
|
@@ -20,3 +24,38 @@ def series_mbox(request, series_id): | |
) | ||
|
||
return response | ||
|
||
|
||
def series_list(request, project_id): | ||
project = get_object_or_404(Project, linkname=project_id) | ||
context = {} | ||
series_list = ( | ||
Series.objects.filter(project=project) | ||
.only( | ||
'submitter', | ||
'project', | ||
'version', | ||
'name', | ||
'date', | ||
'id', | ||
) | ||
.select_related('project') | ||
.order_by('date') | ||
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. Should this not be reversed then to sort it from newest to oldest? 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. Agreed. Also, the query needs more work. I'm seeing ~300 queries for listing series (once I remove the lookup for This is a problem. Fortunately it should be easy join. If you click on that SQL tab, you'll see a description of the (many) queries: Clicking on one of these, we can see an example of the kind of issue: That indicates that you need to join on submitter also, which you can do with |
||
) | ||
|
||
paginator = Paginator(request, series_list) | ||
context.update( | ||
{ | ||
'project': project, | ||
'projects': Project.objects.all(), | ||
'series_list': series_list, | ||
'page': paginator.current_page, | ||
'list_view': { | ||
'view': 'series-list', | ||
'view_params': {'project_id': project.linkname}, | ||
'params': collections.OrderedDict(), | ||
}, | ||
} | ||
) | ||
|
||
return render(request, 'patchwork/series-list.html', context) |
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.
You shouldn't need the colinactive stuff since this is only used for bundles, which don't apply to series.
Below also.