[PATCH 29/51] series: Add a detailed view a Series

Damien Lespiau damien.lespiau at intel.com
Sat Sep 12 01:55:02 AEST 2015


Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 htdocs/js/patchwork.js                    | 32 ++++++++++++
 patchwork/templates/patchwork/series.html | 84 +++++++++++++++++++++++++++++++
 patchwork/urls.py                         |  6 ++-
 patchwork/views/series.py                 | 14 +++++-
 4 files changed, 133 insertions(+), 3 deletions(-)
 create mode 100644 patchwork/templates/patchwork/series.html

diff --git a/htdocs/js/patchwork.js b/htdocs/js/patchwork.js
index a144232..b92b319 100644
--- a/htdocs/js/patchwork.js
+++ b/htdocs/js/patchwork.js
@@ -14,6 +14,10 @@ var pw = (function() {
         'Updated': 'last_updated'
     };
 
+    function series_writer(record) {
+        return '<a href="/series/' + record['id'] + '/">' + record[this.id] + '</a>';
+    }
+
     function date_writer(record) {
         return record[this.id].substr(0, 10);
     }
@@ -49,6 +53,7 @@ var pw = (function() {
                 paginationGap: [1,1,1,1],
             },
             writers: {
+                'name': series_writer,
                 'submitted': date_writer,
                 'last_updated': date_writer,
                 'reviewer_name': reviewer_writer
@@ -82,5 +87,32 @@ var pw = (function() {
         table.stickyTableHeaders();
     }
 
+    exports.setup_series = function(config) {
+        var column_num, column_name;
+
+        column_num = $('#' + config.patches + ' tbody tr td:first-child');
+        column_name = $('#' + config.patches + ' tbody tr td:nth-child(2) a');
+
+        for (i = 0; i < column_num.length; i++) {
+            var name = $(column_name[i]).html();
+            var s = name.split(']');
+
+            if (s.length == 1) {
+                $(column_num[i]).html('1');
+            } else {
+                var matches = s[0].match(/(\d+)\/(\d+)/);
+
+                $(column_name[i]).html(s.slice(1).join(']'));
+
+                if (!matches) {
+                    $(column_num[i]).html('1');
+                    continue;
+                }
+
+                $(column_num[i]).html(matches[1]);
+            }
+        }
+    }
+
     return exports
 }());
diff --git a/patchwork/templates/patchwork/series.html b/patchwork/templates/patchwork/series.html
new file mode 100644
index 0000000..31d779b
--- /dev/null
+++ b/patchwork/templates/patchwork/series.html
@@ -0,0 +1,84 @@
+{% extends "base.html" %}
+
+{% load person %}
+
+{% block title %}{{project.name}}{% endblock %}
+{% block heading %}{{project.name}}{% endblock %}
+{% block headers %}
+<script language="JavaScript" type="text/javascript">
+$(function () {
+    pw.setup_series({ patches: 'series-patchlist' });
+});
+</script>
+{% endblock %}
+{% block breadcrumb %}
+<a href="{% url 'series_list' project=project.linkname %}">{{ project.linkname }} series</a> → {{ series.name }}
+{% endblock %}
+
+{% block body %}
+<h2>{{ series.name }}</h2>
+
+<div class="core-info">
+  <span>Submitted by {{ series.submitter|personify:project }} on {{ series.submitted }}</span>
+</div>
+
+<h2>Details</h2>
+
+<table class="patchmeta">
+  <tr>
+    <th>Reviewer</th>
+{% if series.reviewer %}
+    <td>{{ series.reviewer }}</td>
+{% else %}
+    <td><em class="text-muted">None</em></td>
+{% endif %}
+  </tr>
+  <tr>
+    <th>Submitted</th>
+    <td>{{ series.submitted }}</td>
+  </tr>
+  <tr>
+    <th>Last Updated</th>
+    <td>{{ series.last_updated }}</td>
+  </tr>
+  <tr>
+    <th>Revision</th>
+    <td>{{ series.version }}</td>
+  </tr>
+</table>
+
+{% if cover_letter %}
+<h2>Cover Letter</h2>
+
+<div class="comment">
+  <pre class="content">
+{{ cover_letter }}
+  </pre>
+</div>
+
+{% endif %}
+<h2>Patches</h2>
+
+<table class="table table-hover table-condensed pw-list" id="series-patchlist">
+  <thead>
+    <tr>
+      <th>#</th>
+      <th>Name</th>
+      <th>Submitter</th>
+      <th>State</th>
+    </tr>
+  </thead>
+  <tbody>
+{% for patch in patches %}
+    <tr>
+      <td>.</td>
+      <td><a href="{% url 'patchwork.views.patch.patch' patch_id=patch.id %}"
+        >{{ patch.name|default:"[no subject]"|truncatechars:100 }}</a></td>
+      <td>{{ patch.submitter|personify:project }}</td>
+      <td>{{ patch.state }}</td>
+    <tr>
+{% endfor %}
+  </tbody>
+</table>
+
+{% endblock %}
diff --git a/patchwork/urls.py b/patchwork/urls.py
index 0d36ec5..fc8226c 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -22,7 +22,7 @@ from django.conf import settings
 from django.contrib import admin
 from django.contrib.auth import views as auth_views
 from rest_framework_nested import routers
-from patchwork.views.series import SeriesListView
+from patchwork.views.series import SeriesListView, SeriesView
 import patchwork.views.api as api
 
 # API
@@ -59,7 +59,9 @@ urlpatterns = patterns('',
     (r'^project/(?P<project_id>[^/]+)/$', 'patchwork.views.project.project'),
 
     # series views
-    (r'^project/(?P<project>[^/]+)/series/$', SeriesListView.as_view()),
+    url(r'^project/(?P<project>[^/]+)/series/$', SeriesListView.as_view(),
+     name='series_list'),
+    (r'^series/(?P<series>[^/]+)/$', SeriesView.as_view()),
 
     # patch views
     (r'^patch/(?P<patch_id>\d+)/$', 'patchwork.views.patch.patch'),
diff --git a/patchwork/views/series.py b/patchwork/views/series.py
index 0f65c83..785c3a9 100644
--- a/patchwork/views/series.py
+++ b/patchwork/views/series.py
@@ -20,7 +20,7 @@
 from django.http import HttpResponseRedirect
 from django.shortcuts import render, get_object_or_404
 from django.views.generic import View
-from patchwork.models import Project
+from patchwork.models import Project, Series, SeriesRevision
 
 class SeriesListView(View):
     def get(self, request, *args, **kwargs):
@@ -28,3 +28,15 @@ class SeriesListView(View):
             'project': get_object_or_404(Project, linkname=kwargs['project']),
         })
 
+class SeriesView(View):
+    def get(self, request, *args, **kwargs):
+        series = get_object_or_404(Series, pk=kwargs['series'])
+        revision = get_object_or_404(SeriesRevision,
+                                     series=series,
+                                     version=series.version)
+        return render(request, 'patchwork/series.html', {
+            'series': series,
+            'project': series.project,
+            'cover_letter': revision.cover_letter,
+            'patches': revision.patches.all(),
+        })
-- 
2.1.0



More information about the Patchwork mailing list