mirror of https://github.com/jumpserver/jumpserver
parent
73c2155864
commit
3a62abf381
|
@ -32,3 +32,7 @@ class ActionChoices(BitChoices):
|
|||
def has_perm(cls, action_name, total):
|
||||
action_value = getattr(cls, action_name)
|
||||
return action_value & total == action_value
|
||||
|
||||
@classmethod
|
||||
def display(cls, value):
|
||||
return ', '.join([c.label for c in cls if c.value & value == c.value])
|
||||
|
|
|
@ -18,3 +18,6 @@ class ApplyAssetTicket(Ticket):
|
|||
apply_actions = models.IntegerField(verbose_name=_('Actions'), default=ActionChoices.all())
|
||||
apply_date_start = models.DateTimeField(verbose_name=_('Date start'), null=True)
|
||||
apply_date_expired = models.DateTimeField(verbose_name=_('Date expired'), null=True)
|
||||
|
||||
def get_apply_actions_display(self):
|
||||
return ActionChoices.display(self.apply_actions)
|
||||
|
|
|
@ -398,6 +398,8 @@ class Ticket(StatusMixin, CommonModelMixin):
|
|||
value = self.rel_snapshot[name]
|
||||
elif isinstance(field, related.ManyToManyField):
|
||||
value = ', '.join(self.rel_snapshot[name])
|
||||
elif isinstance(value, list):
|
||||
value = ', '.join(value)
|
||||
return value
|
||||
|
||||
def get_local_snapshot(self):
|
||||
|
|
|
@ -44,8 +44,7 @@ class ApplyAssetSerializer(BaseApplyAssetSerializer, TicketApplySerializer):
|
|||
attrs['type'] = 'apply_asset'
|
||||
attrs = super().validate(attrs)
|
||||
if self.is_final_approval and (
|
||||
not attrs.get('apply_nodes')
|
||||
and not attrs.get('apply_assets')
|
||||
not attrs.get('apply_nodes') and not attrs.get('apply_assets')
|
||||
):
|
||||
raise serializers.ValidationError({
|
||||
'apply_nodes': asset_or_node_help_text,
|
||||
|
|
Loading…
Reference in New Issue