Skip to content

Commit

Permalink
revert(backend): fix rebase problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Vergez committed May 25, 2023
1 parent 70ad9c2 commit 1d5d72e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 230 deletions.
216 changes: 0 additions & 216 deletions backend/geonature/core/gn_permissions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,211 +541,6 @@ def get_query(self):
)


class PermissionAvailableAdmin(CruvedProtectedMixin, ModelView):
module_code = "ADMIN"
object_code = "PERMISSIONS"

column_labels = {
"scope": "Portée",
"object": "Objet",
"scope_filter": "Filtre appartenance",
"sensitivity_filter": "Filtre sensibilité",
}
column_formatters = {
"module": lambda v, c, m, p: m.module.module_code,
"object": lambda v, c, m, p: m.object.code_object,
}
column_sortable_list = (
("module", "module.module_code"),
("object", "object.code_object"),
("action", "action.code_action"),
)
column_default_sort = [
("module.module_code", False),
("object.code_object", False),
("id_action", False),
]
form_columns = ("scope_filter", "sensitivity_filter")


class RolePermAdmin(CruvedProtectedMixin, ModelView):
module_code = "ADMIN"
object_code = "PERMISSIONS"

can_create = False
can_edit = False
can_delete = False
can_export = False
can_view_details = True

column_select_related_list = ("permissions",)
column_labels = {
"nom_role": "Nom",
"prenom_role": "Prénom",
"groups": "Groupes",
"permissions": "Permissions",
"permissions_count": "Nombre de permissions",
}
column_formatters = {
"groups": groups_formatter,
"permissions_count": permissions_count_formatter,
}
column_formatters_detail = {
"groups": groups_formatter,
"permissions": permissions_formatter,
"permissions_count": permissions_count_formatter,
}


class GroupPermAdmin(RolePermAdmin):
column_list = (
"nom_role",
"permissions_count",
)
column_details_list = ("nom_role", "permissions_count", "permissions")

def get_query(self):
# TODO: filter_by_app
return super().get_query().filter_by(groupe=True)


class UserPermAdmin(RolePermAdmin):
column_list = (
"identifiant",
"nom_role",
"prenom_role",
"groups",
"permissions_count",
)
column_labels = {
**RolePermAdmin.column_labels,
"permissions_count": "Nombre de permissions non héritées",
}
column_details_list = (
"identifiant",
"nom_role",
"prenom_role",
"groups",
"permissions_count",
"permissions",
)

def get_query(self):
# TODO: filter_by_app
return super().get_query().filter_by(groupe=False)


admin.add_view(
GroupPermAdmin(
User,
db.session,
name="Groupes",
category="Permissions",
endpoint="permissions/group",
)
)


admin.add_view(
UserPermAdmin(
User,
db.session,
name="Utilisateurs",
category="Permissions",
endpoint="permissions/user",
)
)


class RolePermAdmin(CruvedProtectedMixin, ModelView):
module_code = "ADMIN"
object_code = "PERMISSIONS"

can_create = False
can_edit = False
can_delete = False
can_export = False
can_view_details = True

column_select_related_list = ("permissions",)
column_labels = {
"nom_role": "Nom",
"prenom_role": "Prénom",
"groups": "Groupes",
"permissions": "Permissions",
"permissions_count": "Nombre de permissions",
}
column_formatters = {
"groups": groups_formatter,
"permissions_count": permissions_count_formatter,
}
column_formatters_detail = {
"groups": groups_formatter,
"permissions": permissions_formatter,
"permissions_count": permissions_count_formatter,
}


class GroupPermAdmin(RolePermAdmin):
column_list = (
"nom_role",
"permissions_count",
)
column_details_list = ("nom_role", "permissions_count", "permissions")

def get_query(self):
# TODO: filter_by_app
return super().get_query().filter_by(groupe=True)


class UserPermAdmin(RolePermAdmin):
column_list = (
"identifiant",
"nom_role",
"prenom_role",
"groups",
"permissions_count",
)
column_labels = {
**RolePermAdmin.column_labels,
"permissions_count": "Nombre de permissions non héritées",
}
column_details_list = (
"identifiant",
"nom_role",
"prenom_role",
"groups",
"permissions_count",
"permissions",
)

def get_query(self):
# TODO: filter_by_app
return super().get_query().filter_by(groupe=False)


admin.add_view(
GroupPermAdmin(
User,
db.session,
name="Groupes",
category="Permissions",
endpoint="permissions/group",
)
)


admin.add_view(
UserPermAdmin(
User,
db.session,
name="Utilisateurs",
category="Permissions",
endpoint="permissions/user",
)
)


admin.add_view(
ObjectAdmin(
PermObject,
Expand All @@ -768,17 +563,6 @@ def get_query(self):
)


admin.add_view(
PermissionAvailableAdmin(
PermissionAvailable,
db.session,
name="Permissions disponibles",
category="Permissions",
endpoint="permissions/availablepermission",
)
)


admin.add_view(
PermissionAvailableAdmin(
PermissionAvailable,
Expand Down
14 changes: 0 additions & 14 deletions backend/geonature/core/gn_permissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ class Permission(db.Model):
backref="permissions",
)

availability = db.relationship(
PermissionAvailable,
primaryjoin=sa.and_(
foreign(id_module) == PermissionAvailable.id_module,
foreign(id_object) == PermissionAvailable.id_object,
foreign(id_action) == PermissionAvailable.id_action,
),
)

filters_fields = {
"SCOPE": scope_value,
"SENSITIVITY": sensitivity_filter,
Expand All @@ -242,11 +233,6 @@ def __SENSITIVITY_le__(a, b):
# False only if: A is False and b is True
return (not a) <= (not b)

@staticmethod
def __SENSITIVITY_le__(a, b):
# False only if: A is False and b is True
return (not a) <= (not b)

@staticmethod
def __default_le__(a, b):
return a == b or b is None
Expand Down

0 comments on commit 1d5d72e

Please sign in to comment.