caluma
caluma copied to clipboard
Hierarchy of visibilities
Currently, the hierarchy of the visibilities is completely random. This makes it very hard to be restrictive without being too specific.
In my example I want everything to be hidden for an anonymous user except one certain form (including docs, answers, questions and options). So my idea would naturally be to use the caluma.caluma_user.visibilities.Authenticated as base class and whitelist the allowed models:
from caluma.caluma_user.visibilities import Authenticated
from caluma.caluma_core.visibilities import filter_queryset_for
from caluma.caluma_form.schema import Form
class CustomVisibility(Authenticated):
@filter_queryset_for(Form)
def filter_queryset_for_form(self, node, queryset, info):
if info.context.user.is_authenticated:
return queryset
return queryset.filter(slug="my-public-form")
# ...
In this example the filter_queryset_for_form method is never even being executed. We should clarify the current hierarchy or enable proper extending.