I am working on the dam_inventory project from your tutorial. For the "App Permissions" part, I created a diviewer without the permission to add dams.
And I updated the code as following:
// app.py
class DamInventory(TethysAppBase):
...
def permissions(self):
"""
Define permissions for the app.
"""
add_dams = Permission(
name='add_dams',
description='Add dams to inventory'
)
admin = PermissionGroup(
name='admin',
permissions=(add_dams,)
)
permissions = (admin,)
return permissions
// controllers.py
@controller(url='dams/add', permission_required='add_dams')
def add_dam(request):
"""
Controller for the Add Dam page.
"""
... # read the form and handle the errros
context = {
...
'can_add_dams': has_permission(request, 'add_dams')
}
return render(request, 'dam_inventory/add_dam.html', context)
Though the Add Dam button is hidden, I can still get in the add_dam page by entering the address https://localhost:8000/apps/dam-inventory/dams/add and add a new dam. So, it seems that the decorator permission_required='add_dams' is not working.
Hello,
I am working on the![image](https://github.com/tethysplatform/tethys/assets/53383436/7dcd2c6d-51ee-48e9-90af-86089b8ed82b)
dam_inventory
project from your tutorial. For the "App Permissions" part, I created adiviewer
without the permission to add dams.And I updated the code as following:
Though the
Add Dam
button is hidden, I can still get in theadd_dam
page by entering the addresshttps://localhost:8000/apps/dam-inventory/dams/add
and add a new dam. So, it seems that the decoratorpermission_required='add_dams'
is not working.