mirror of https://github.com/jumpserver/jumpserver
perf: 增加分享权限位
parent
5ab8ff4fde
commit
3eb1583c69
|
@ -262,10 +262,8 @@ class BitChoices(models.IntegerChoices, TreeChoices):
|
|||
|
||||
@classmethod
|
||||
def all(cls):
|
||||
value = 0
|
||||
for c in cls:
|
||||
value |= c.value
|
||||
return value
|
||||
# 权限 12 位 最大值
|
||||
return 4095
|
||||
|
||||
|
||||
class PortRangeField(models.CharField):
|
||||
|
|
|
@ -15,6 +15,7 @@ class ActionChoices(BitChoices):
|
|||
copy = bit(4), _("Copy") + " (RDP, VNC)"
|
||||
paste = bit(5), _("Paste") + " (RDP, VNC)"
|
||||
delete = bit(6), _("Delete") + " (SFTP)"
|
||||
share = bit(7), _("Share") + " (SSH)"
|
||||
|
||||
@classmethod
|
||||
def is_tree(cls):
|
||||
|
@ -26,6 +27,7 @@ class ActionChoices(BitChoices):
|
|||
cls.connect,
|
||||
(_("Transfer"), [cls.upload, cls.download, cls.delete]),
|
||||
(_("Clipboard"), [cls.copy, cls.paste]),
|
||||
cls.share
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 4.1.10 on 2023-11-08 08:26
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def migrate_action_all_value(apps, schema_editor):
|
||||
old_max_bit = 63
|
||||
new_max_bit = 4095
|
||||
asset_permission_model = apps.get_model("perms", "AssetPermission")
|
||||
db_alias = schema_editor.connection.alias
|
||||
perms = list(asset_permission_model.objects.using(db_alias).filter(actions=old_max_bit))
|
||||
for perm in perms:
|
||||
perm.actions = new_max_bit
|
||||
asset_permission_model.objects.bulk_update(perms, ['actions'])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('perms', '0035_auto_20231125_1025'),
|
||||
]
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
code=migrate_action_all_value,
|
||||
),
|
||||
]
|
Loading…
Reference in New Issue