From e6884717325dfe7da990e8c51d849cab16ea9653 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 17 Aug 2015 17:21:41 -0500 Subject: [PATCH] Don't show Save Defaults button if no user is logged in. --- tailbone/newgrids/core.py | 3 +++ tailbone/templates/newgrids/filters.mako | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tailbone/newgrids/core.py b/tailbone/newgrids/core.py index 2d74f9ae..e01160fb 100644 --- a/tailbone/newgrids/core.py +++ b/tailbone/newgrids/core.py @@ -231,6 +231,8 @@ class Grid(object): """ 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. key = 'tailbone.{0}.grid.{1}.sortkey'.format(self.request.user.uuid, self.key) return get_setting(Session(), key) is not None @@ -517,6 +519,7 @@ class Grid(object): form = filters.GridFiltersForm(self.request, self.filters, defaults=data) + kwargs['request'] = self.request kwargs['grid'] = self kwargs['form'] = filters.GridFiltersFormRenderer(form) return render(template, kwargs) diff --git a/tailbone/templates/newgrids/filters.mako b/tailbone/templates/newgrids/filters.mako index 10c77658..13b8bd6e 100644 --- a/tailbone/templates/newgrids/filters.mako +++ b/tailbone/templates/newgrids/filters.mako @@ -29,7 +29,9 @@ ${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='save-defaults', c="Save Defaults")} + % if request.user: + ${form.tag('button', type='button', id='save-defaults', c="Save Defaults")} + % endif ${form.end()}