Don't show Save Defaults button if no user is logged in.
This commit is contained in:
parent
75c9f9ebc0
commit
e688471732
|
@ -231,6 +231,8 @@ class Grid(object):
|
||||||
"""
|
"""
|
||||||
Check to see if the current user has default settings on file for this grid.
|
Check to see if the current user has default settings on file for this grid.
|
||||||
"""
|
"""
|
||||||
|
if not self.request.user:
|
||||||
|
return False
|
||||||
# User defaults should have all or nothing, so just check one key.
|
# User defaults should have all or nothing, so just check one key.
|
||||||
key = 'tailbone.{0}.grid.{1}.sortkey'.format(self.request.user.uuid, self.key)
|
key = 'tailbone.{0}.grid.{1}.sortkey'.format(self.request.user.uuid, self.key)
|
||||||
return get_setting(Session(), key) is not None
|
return get_setting(Session(), key) is not None
|
||||||
|
@ -517,6 +519,7 @@ class Grid(object):
|
||||||
|
|
||||||
form = filters.GridFiltersForm(self.request, self.filters, defaults=data)
|
form = filters.GridFiltersForm(self.request, self.filters, defaults=data)
|
||||||
|
|
||||||
|
kwargs['request'] = self.request
|
||||||
kwargs['grid'] = self
|
kwargs['grid'] = self
|
||||||
kwargs['form'] = filters.GridFiltersFormRenderer(form)
|
kwargs['form'] = filters.GridFiltersFormRenderer(form)
|
||||||
return render(template, kwargs)
|
return render(template, kwargs)
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
</select>
|
</select>
|
||||||
${form.tag('button', type='button', id='default-filters', c="Default Filters")}
|
${form.tag('button', type='button', id='default-filters', c="Default Filters")}
|
||||||
${form.tag('button', type='button', id='clear-filters', c="Clear Filters")}
|
${form.tag('button', type='button', id='clear-filters', c="Clear Filters")}
|
||||||
|
% if request.user:
|
||||||
${form.tag('button', type='button', id='save-defaults', c="Save Defaults")}
|
${form.tag('button', type='button', id='save-defaults', c="Save Defaults")}
|
||||||
|
% endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${form.end()}
|
${form.end()}
|
||||||
|
|
Loading…
Reference in a new issue