-
Notifications
You must be signed in to change notification settings - Fork 102
Reports Filter Form #39
Description
I have a model with a number of FK and 1to1 fields.
user, department etc.
Reports automatically show these as filters. Awesome.
However, is there a way to not allow 'user' to be a filter?
I have reports where I've set the get_queryset to only allow is_staff to see their own Employee details.
def get_queryset(self): # show only the users own employee record. Superuser can see all.
qs = super().get_queryset() # Can't pass in request without error about too many parameters.
if self.request.user.is_superuser:
logMessage(f'Reports g_qs IS Superuser = {self.request.user}')
return qs # just return everything
adminuser = self.request.user
return qs.filter(user=adminuser)
The Filters at the top of the report show all Users via the Select2.
This is potentially a minor security concern. All Admin users will be a minimum of staff but they can see all the usernames as is.
Also, as they can only see their own record there is no need for this User Filter. It affords a capability they can't use.
I've had an epic 3 day battle using form_class = EmployeeForm where I've built a Custom Form. But I couldn't get it working properly (too many issues to relate) and the change to the Report Filters is quite minor so I don't really need a Custom Form with all the extra work and complexity.
Is there a way of stating in my @register_report_view class EmployeeList(ReportView): to not show a filter?