Browse Source

fix: action

pull/9090/head
feng 2 years ago
parent
commit
ec462e09e0
  1. 2
      apps/common/drf/fields.py
  2. 7
      apps/common/utils/integer.py
  3. 10
      apps/perms/const.py

2
apps/common/drf/fields.py

@ -162,6 +162,8 @@ class BitChoicesField(TreeChoicesMixin, serializers.MultipleChoiceField):
这里将获取到的值再执行一下 to_internal_value 方法, 转化为内部值
"""
data = super().run_validation(data)
if isinstance(data, int):
return data
value = self.to_internal_value(data)
self.run_validators(value)
return value

7
apps/common/utils/integer.py

@ -1,5 +1,4 @@
def bit(x):
if x == 0:
return 0
else:
return 2 ** (x - 1)
if x < 1:
raise ValueError("x must be greater than 1")
return 2 ** (x - 1)

10
apps/perms/const.py

@ -10,11 +10,11 @@ __all__ = ["ActionChoices"]
class ActionChoices(BitChoices):
connect = bit(0), _("Connect")
upload = bit(1), _("Upload")
download = bit(2), _("Download")
copy = bit(3), _("Copy")
paste = bit(4), _("Paste")
connect = bit(1), _("Connect")
upload = bit(2), _("Upload")
download = bit(3), _("Download")
copy = bit(4), _("Copy")
paste = bit(5), _("Paste")
@classmethod
def is_tree(cls):

Loading…
Cancel
Save