Skip to content

Commit

Permalink
series: Don't show checkboxes when the user is not a maintainer
Browse files Browse the repository at this point in the history
Right now, we only allow maintainers to use the API entry points
modifying data.

Make sure we only show the mechanism to change series fields is the user
can actually do something about it.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Fixes: #142
  • Loading branch information
Damien Lespiau committed Feb 9, 2016
1 parent a8af1e4 commit afef3db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions htdocs/js/patchwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ var pw = (function() {
};

o._refresh_select_checkboxes = function() {
if (!this.ctx.user.is_authenticated) {
if (!this.ctx.project.is_editable) {
$('#css-table-select').html('.table-select { display: none; }');
return;
}
Expand Down Expand Up @@ -596,7 +596,7 @@ var pw = (function() {
ordering = '-last_updated';

if (typeof url == 'undefined') {
url = '/projects/' + ctx.project + '/series/';
url = '/projects/' + ctx.project.name + '/series/';
if (!window.location.search)
history.replaceState(null, null,
'?' + $.param({ ordering: ordering }));
Expand Down
5 changes: 4 additions & 1 deletion patchwork/views/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@

class SeriesListView(View):
def get(self, request, *args, **kwargs):
project = get_object_or_404(Project, linkname=kwargs['project'])
is_editable = 'true' if project.is_editable(request.user) else 'false'
return render(request, 'patchwork/series-list.html', {
'project': get_object_or_404(Project, linkname=kwargs['project']),
'project': project,
'is_editable': is_editable,
'default_patches_per_page': settings.DEFAULT_PATCHES_PER_PAGE,
})

Expand Down
5 changes: 4 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
}
{% endif %}
{% if project %}
, project: '{{ project.linkname }}'
, project: {
name: '{{ project.linkname }}',
is_editable: {{ is_editable|default:"false" }},
},
{% endif %}
});
});
Expand Down

0 comments on commit afef3db

Please sign in to comment.