From patchwork Fri Sep 11 15:55:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 516871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DA57914012C for ; Sat, 12 Sep 2015 01:59:52 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id C04071A2AF3 for ; Sat, 12 Sep 2015 01:59:52 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lists.ozlabs.org (Postfix) with ESMTP id 797DA1A2BAF for ; Sat, 12 Sep 2015 01:56:02 +1000 (AEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 11 Sep 2015 08:56:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="559867178" Received: from jeffzhua-mobl.amr.corp.intel.com (HELO strange.amr.corp.intel.com) ([10.254.88.85]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2015 08:56:00 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 28/51] series: Add a first attempt at a Series list view Date: Fri, 11 Sep 2015 16:55:01 +0100 Message-Id: <1441986924-26689-29-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> References: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" It's all good that we can parse emails to build Series in the database, but we also need to view them. This commit introduces a new project/$project/series view that is the list of series. Instead of doing all server side, after the initial page load, we load data through the JSON API. This should hopefully make the editing/sorting/paging a bit less jarring as we're not reloading the whole page anymore. Signed-off-by: Damien Lespiau --- htdocs/js/patchwork.js | 86 ++++++++++++++++++++++++++ patchwork/templates/patchwork/series-list.html | 52 ++++++++++++++++ patchwork/urls.py | 4 ++ patchwork/views/series.py | 30 +++++++++ templates/base.html | 12 ++++ 5 files changed, 184 insertions(+) create mode 100644 htdocs/js/patchwork.js create mode 100644 patchwork/templates/patchwork/series-list.html create mode 100644 patchwork/views/series.py diff --git a/htdocs/js/patchwork.js b/htdocs/js/patchwork.js new file mode 100644 index 0000000..a144232 --- /dev/null +++ b/htdocs/js/patchwork.js @@ -0,0 +1,86 @@ +var pw = (function() { + var _this, + exports = {}, + ctx = { + project: null + }; + + var columnsMap = { + 'Series': 'name', + 'Patches': 'n_patches', + 'Submitter': 'submitter_name', + 'Reviewer': 'reviewer_name', + 'Submitted': 'submitted', + 'Updated': 'last_updated' + }; + + function date_writer(record) { + return record[this.id].substr(0, 10); + } + + function reviewer_writer(record) { + reviewer = record[this.id]; + if (!reviewer) + return 'None'; + else + return reviewer; + } + + exports.init = function(init_ctx) { + _this = this; + + $.extend(ctx, init_ctx); + + $.dynatableSetup({ + dataset: { + perPageDefault: 20, + perPageOptions: [20, 50, 100] + }, + params: { + perPage: 'perpage', + records: 'results', + queryRecordCount: 'count', + totalRecordCount: 'count' + }, + inputs: { + pageText: '', + paginationPrev: '« Previous', + paginationNext: 'Next »', + paginationGap: [1,1,1,1], + }, + writers: { + 'submitted': date_writer, + 'last_updated': date_writer, + 'reviewer_name': reviewer_writer + } + }); + } + + exports.setup_series_list = function(selector) { + var table = $(selector); + + table.bind('dynatable:preinit', function(e, dynatable) { + dynatable.utility.textTransform.PatchworkSeries = function(text) { + return columnsMap[text]; + }; + }).dynatable({ + features: { + search: false, + recordCount: false, + }, + table: { + defaultColumnIdStyle: 'PatchworkSeries', + }, + dataset: { + ajax: true, + ajaxUrl: '/api/1.0/projects/' + ctx.project + '/series/', + ajaxOnLoad: true, + records: [] + } + }); + + table.stickyTableHeaders(); + } + + return exports +}()); diff --git a/patchwork/templates/patchwork/series-list.html b/patchwork/templates/patchwork/series-list.html new file mode 100644 index 0000000..7cf0ba9 --- /dev/null +++ b/patchwork/templates/patchwork/series-list.html @@ -0,0 +1,52 @@ +{% extends "base.html" %} + +{% load person %} + +{% block title %}{{project.name}}{% endblock %} +{% block heading %}{{project.name}}{% endblock %} +{% block headers %} + +{% endblock %} +{% block breadcrumb %}{{ project.name }} series{% endblock %} + +{% block body %} +

Incoming Series

+ + + + + + + + + + + + + + + + + + +
SeriesPatchesReviewerSubmitterSubmittedUpdated
+ + + +{% endblock %} diff --git a/patchwork/urls.py b/patchwork/urls.py index 67c6c6b..0d36ec5 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -22,6 +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 import patchwork.views.api as api # API @@ -57,6 +58,9 @@ urlpatterns = patterns('', (r'^project/(?P[^/]+)/list/$', 'patchwork.views.patch.list'), (r'^project/(?P[^/]+)/$', 'patchwork.views.project.project'), + # series views + (r'^project/(?P[^/]+)/series/$', SeriesListView.as_view()), + # patch views (r'^patch/(?P\d+)/$', 'patchwork.views.patch.patch'), (r'^patch/(?P\d+)/raw/$', 'patchwork.views.patch.content'), diff --git a/patchwork/views/series.py b/patchwork/views/series.py new file mode 100644 index 0000000..0f65c83 --- /dev/null +++ b/patchwork/views/series.py @@ -0,0 +1,30 @@ +# Patchwork - automated patch tracking system +# Copyright (C) 2014 Intel Corporation +# +# This file is part of the Patchwork package. +# +# Patchwork is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Patchwork is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Patchwork; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +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 + +class SeriesListView(View): + def get(self, request, *args, **kwargs): + return render(request, 'patchwork/series-list.html', { + 'project': get_object_or_404(Project, linkname=kwargs['project']), + }) + diff --git a/templates/base.html b/templates/base.html index 6b254f7..18c3ef6 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,6 +8,7 @@ {% block title %}Patchwork{% endblock %} - Patchwork + @@ -22,6 +23,17 @@ + + + {% block headers %}{% endblock %}