-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import geonature.core.gn_permissions.admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from flask_admin.contrib.sqla import ModelView | ||
|
||
from geonature.utils.env import db | ||
from geonature.core.admin.admin import admin | ||
from geonature.core.admin.utils import CruvedProtectedMixin | ||
from geonature.core.gn_permissions.models import PermObject, Permission | ||
|
||
|
||
class ObjectAdmin(CruvedProtectedMixin, ModelView): | ||
module_code = "ADMIN" | ||
object_code = "PERMISSION" | ||
|
||
column_list = ("code_object", "description_object", "modules") | ||
column_labels = { | ||
"code_object": "Code", | ||
"description_object": "Description", | ||
} | ||
|
||
can_create = False | ||
can_edit = False | ||
can_delete = False | ||
|
||
|
||
class PermissionAdmin(CruvedProtectedMixin, ModelView): | ||
module_code = "ADMIN" | ||
object_code = "PERMISSION" | ||
|
||
column_list = ("role", "module", "object", "action", "scope") | ||
column_labels = { | ||
"role": "Rôle", | ||
"scope": "Porté", | ||
"object": "Objet", | ||
} | ||
column_formatters = { | ||
"module": lambda v, c, m, p: m.module.module_code, | ||
"object": lambda v, c, m, p: m.object.code_object, | ||
} | ||
|
||
|
||
admin.add_view( | ||
ObjectAdmin( | ||
PermObject, | ||
db.session, | ||
name="Objets", | ||
category="Permissions", | ||
) | ||
) | ||
|
||
|
||
admin.add_view( | ||
PermissionAdmin( | ||
Permission, | ||
db.session, | ||
name="Permissions", | ||
category="Permissions", | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters