fix: action

pull/9090/head
feng 2022-11-16 19:35:16 +08:00
parent 21d24ae4bc
commit ec462e09e0
3 changed files with 10 additions and 9 deletions

View File

@ -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

View File

@ -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)

View File

@ -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):