Allow any authenticated user to create new Structure entries in autocomplete
This commit is contained in:
@@ -3005,6 +3005,21 @@ class StructureAutocomplete(autocomplete.Select2QuerySetView):
|
|||||||
return Structure.objects.none()
|
return Structure.objects.none()
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
def has_add_permission(self, request):
|
||||||
|
"""Allow any authenticated user to create new Structure entries.
|
||||||
|
|
||||||
|
By default DAL requires the user to have the model add permission.
|
||||||
|
For Anatomy question creation we want any registered user to be
|
||||||
|
able to create structures, so relax that check to only require
|
||||||
|
authentication.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
auth = request.user.is_authenticated
|
||||||
|
except Exception:
|
||||||
|
auth = False
|
||||||
|
|
||||||
|
return bool(auth)
|
||||||
|
|
||||||
|
|
||||||
class SubspecialtyAutocomplete(autocomplete.Select2QuerySetView):
|
class SubspecialtyAutocomplete(autocomplete.Select2QuerySetView):
|
||||||
|
|||||||
Reference in New Issue
Block a user