Commit dd3ea79e authored by Damien Lespiau's avatar Damien Lespiau
Browse files

todo: Count and show series in the TODO list


Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
parent 22129160
......@@ -572,6 +572,7 @@ var pw = (function() {
ctx.api_base_url = ctx.base_url + '/api/1.0';
exports.user = ctx.user;
exports.project = ctx.project;
};
exports.init = function(init_ctx) {
......@@ -682,17 +683,20 @@ var pw = (function() {
}).data('selectize');
};
exports.setup_series_list = function(selector, url, ordering) {
exports.setup_series_list = function(selector, url, params) {
var table = $(selector);
if (typeof ordering == 'undefined')
ordering = '-last_updated';
var all_params = {
ordering: '-last_updated',
related: 'expand',
};
$.extend(all_params, params);
if (typeof url == 'undefined') {
url = '/projects/' + ctx.project.name + '/series/';
if (!window.location.search)
history.replaceState(null, null,
'?' + $.param({ ordering: ordering }));
'?' + $.param({ ordering: all_params.ordering }));
}
exports.table = ctx.table = create_table({
......@@ -709,9 +713,7 @@ var pw = (function() {
'Tests':'test_state',
},
'api_url': ctx.api_base_url + url,
'api_params': {
related: 'expand',
}
'api_params': all_params,
});
table.bind('dynatable:preinit', function(e, dynatable) {
......
......@@ -164,8 +164,8 @@ class UserProfile(models.Model):
def sync_person(self):
pass
def n_todo_patches(self):
return self.todo_patches().count()
def n_todo(self):
return self.todo_patches().count() + self.todo_series().count()
def todo_patches(self, project=None):
......@@ -181,6 +181,16 @@ class UserProfile(models.Model):
.values('pk').query)
return qs
def todo_series(self, project=None):
# filter on project, if necessary
if project:
qs = Series.objects.filter(project=project)
else:
qs = Series.objects
qs = qs.filter(reviewer=self.user)
return qs
def __str__(self):
return self.name()
......
......@@ -26,13 +26,13 @@ Contributor to
<div class="leftcol">
<div class="box">
<h2>Todo</h2>
{% if user.profile.n_todo_patches %}
{% if user.profile.n_todo %}
<p>Your <a href="{% url 'patchwork.views.user.todo_lists' %}">todo
list</a> contains {{ user.profile.n_todo_patches }}
patch{{ user.profile.n_todo_patches|pluralize:"es" }}.</p>
list</a> contains {{ user.profile.n_todo }}
patch{{ user.profile.n_todo|pluralize:"es" }}.</p>
{% else %}
<p>Your todo list contains patches that have been delegated to you. You
have no items in your todo list at present.</p>
<p>Your todo list contains patches and series that have been assigned to you.
You have no items in your todo list at present.</p>
{% endif %}
</div>
......
......@@ -4,14 +4,33 @@
{% block title %}{{ user }}'s todo list{% endblock %}
{% block headers %}
<script language="JavaScript" type="text/javascript">
$(function () {
pw.setup_series_list('#serieslist', '/series/', {
project: pw.project.pk,
reviewer: pw.user.pk,
});
});
</script>
{% endblock %}
{% block body %}
<h1>TODO</h1>
<p>A Patchwork Todo-list contains patches that are assigned to you, and
are in an "action required" state
({% for state in action_required_states %}{% if forloop.last and not forloop.first %} or {% endif %}{{ state }}{% if not forloop.last and not forloop.first %}, {%endif %}{% endfor %}), and are not archived.
</p>
<p>The Patchwork TODO-list contains patches and series that are assigned to you
and need your attention. </p>
{% if n_series %}
<h2>Series</h2>
{% include "patchwork/series-list-table.html" %}
{% endif %}
{% if n_patches %}
<h2>Patches</h2>
{% include "patchwork/patch-list.html" %}
{% endif %}
{% endblock %}
......@@ -7,18 +7,20 @@
<h1>TODO</h1>
{% if todo_lists %}
<p>You have multiple todo lists. Each todo list contains patches for a single
project.</p>
<p>You have multiple todo lists. Each todo list contains series and patches for
a single project.</p>
<table class="vertical">
<tr>
<th>project</th>
<th>patches</th>
<th>Project</th>
<th>Series</th>
<th>Patches</th>
</tr>
{% for todo_list in todo_lists %}
<tr>
<td><a
href="{% url 'patchwork.views.user.todo_list' project_id=todo_list.project.linkname %}"
>{{ todo_list.project.name }}</a></td>
<td class="numberformat">{{ todo_list.n_series }}</td>
<td class="numberformat">{{ todo_list.n_patches }}</td>
</tr>
{% endfor %}
......
......@@ -194,10 +194,16 @@ def todo_lists(request):
for project in Project.objects.all():
patches = request.user.profile.todo_patches(project=project)
if not patches.count():
series = request.user.profile.todo_series(project=project)
n_series = series.count()
n_patches = patches.count()
if (n_series + n_patches) == 0:
continue
todo_lists.append({'project': project, 'n_patches': patches.count()})
todo_lists.append({'project': project,
'n_series': n_series,
'n_patches': n_patches})
if len(todo_lists) == 1:
return HttpResponseRedirect(
......@@ -215,6 +221,7 @@ def todo_lists(request):
def todo_list(request, project_id):
project = get_object_or_404(Project, linkname=project_id)
patches = request.user.profile.todo_patches(project=project)
series = request.user.profile.todo_series(project=project)
filter_settings = [(DelegateFilter,
{'delegate': request.user})]
......@@ -226,4 +233,6 @@ def todo_list(request, project_id):
context['action_required_states'] = \
State.objects.filter(action_required=True).all()
context['n_patches'] = patches.count()
context['n_series'] = series.count()
return render_to_response('patchwork/todo-list.html', context)
......@@ -39,6 +39,7 @@
{% endif %}
{% if project %}
, project: {
pk: {{ project.pk }},
name: '{{ project.linkname }}',
is_editable: {{ is_editable|default:"false" }},
},
......@@ -100,14 +101,14 @@
{% if user.is_authenticated %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="badge">{{ user.profile.n_todo_patches }}</span>
<span class="badge">{{ user.profile.n_todo }}</span>
<strong>{{ user.username }}</strong>&nbsp;<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="{% url 'patchwork.views.user.todo_lists' %}">
Reviews pending
<span class="badge">{{ user.profile.n_todo_patches }}</span>
<span class="badge">{{ user.profile.n_todo }}</span>
</a>
</li>
{% if user.is_staff %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment