Commit d03eed3f authored by Ian Hallworth's avatar Ian Hallworth

Disabled dashboard actions for read ony user

parent 120c2678
Pipeline #11266 failed with stages
in 15 minutes and 43 seconds
......@@ -15,6 +15,13 @@ class DashboardView(TemplateView):
"""
context = super(DashboardView, self).get_context_data(**kwargs) or {}
form_disabled = True
if hasattr(self.request, 'user'):
if self.request.user.has_perm('data_layer.change_message'):
form_disabled = False
context['form_disabled'] = form_disabled
# Get dashboard
if 'name' in self.kwargs and self.kwargs['name']:
name = self.kwargs['name']
......
......@@ -188,17 +188,20 @@ class ItemTable(tables.Table):
if category[0] in selected:
selected_long_names.append(category[1].title())
if not hasattr(self, 'context'):
self.context = {}
form_disabled = True
context = self.context
if hasattr(self, 'context'):
form_disabled = self.context.get('form_disabled', True)
context['categories'] = self.categories
context['selected_long_names'] = selected_long_names
context['selected'] = selected
context['record'] = record
ctx = {
'categories': self.categories,
'selected_long_names': selected_long_names,
'selected': selected,
'record': record,
'form_disabled': form_disabled
}
return Template.render(context)
return Template.render(ctx)
def render_feedback_type(self, record, value):
Template = loader.get_template('hid/feedback_type_column.html')
......
......@@ -95,8 +95,9 @@ def test_render_category_passes_context_to_template(mock_loader):
context = {
'categories': categories,
'selected': ['Repatriation'],
'selected_long_names': ['Repatriation'],
'record': record,
'selected_long_names': ['Repatriation']
'form_disabled': True
}
mock_template.render.assert_called_with(context)
......
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