mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-06 09:51:00 +00:00
pref: 优化 permission actionss
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
#
|
||||
import json
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import force_text
|
||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common.utils import signer, crypto
|
||||
|
||||
@@ -211,22 +211,28 @@ class BitChoices(models.IntegerChoices):
|
||||
def branches(cls):
|
||||
return [i for i in cls]
|
||||
|
||||
@classmethod
|
||||
def is_tree(cls):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def tree(cls):
|
||||
if not cls.is_tree():
|
||||
return []
|
||||
root = [_("All"), cls.branches()]
|
||||
return cls.render_node(root)
|
||||
return [cls.render_node(root)]
|
||||
|
||||
@classmethod
|
||||
def render_node(cls, node):
|
||||
if isinstance(node, BitChoices):
|
||||
return {
|
||||
"id": node.name,
|
||||
"value": node.name,
|
||||
"label": node.label,
|
||||
}
|
||||
else:
|
||||
name, children = node
|
||||
return {
|
||||
"id": name,
|
||||
"value": name,
|
||||
"label": name,
|
||||
"children": [cls.render_node(child) for child in children],
|
||||
}
|
||||
|
Reference in New Issue
Block a user