fix: 修改 ACL ActionChoices review, accept, reject 引用

pull/9154/head
Bai 2 years ago
parent 2b5bd558f3
commit a69b762f13

@ -30,10 +30,11 @@ def migrate_login_confirm(apps, schema_editor):
if reviewers.count() == 0:
continue
data = {
'user': user,
'name': f'{user.name}-{login_confirm} ({date_created})',
'created_by': instance.created_by,
'action': LoginACL.ActionChoices.confirm,
'action': 'confirm',
'rules': {'ip_group': ['*'], 'time_period': DEFAULT_TIME_PERIODS}
}
instance = login_acl_model.objects.create(**data)
@ -44,7 +45,7 @@ def migrate_ip_group(apps, schema_editor):
login_acl_model = apps.get_model("acls", "LoginACL")
updates = list()
with transaction.atomic():
for instance in login_acl_model.objects.exclude(action=LoginACL.ActionChoices.confirm):
for instance in login_acl_model.objects.exclude(action='confirm'):
instance.rules = {'ip_group': instance.ip_group, 'time_period': DEFAULT_TIME_PERIODS}
updates.append(instance)
login_acl_model.objects.bulk_update(updates, ['rules', ])

@ -36,7 +36,7 @@ class LoginACL(BaseACL):
return
for acl in acl_qs:
if acl.is_action(LoginACL.ActionChoices.confirm) and \
if acl.is_action(LoginACL.ActionChoices.review) and \
not acl.reviewers.exists():
continue
ip_group = acl.rules.get('ip_group')

@ -333,13 +333,13 @@ class AuthACLMixin:
return
acl: LoginACL
if acl.is_action(acl.ActionChoices.allow):
if acl.is_action(acl.ActionChoices.accept):
return
if acl.is_action(acl.ActionChoices.reject):
raise errors.LoginACLIPAndTimePeriodNotAllowed(user.username, request=self.request)
if acl.is_action(acl.ActionChoices.confirm):
if acl.is_action(acl.ActionChoices.review):
self.request.session['auth_confirm_required'] = '1'
self.request.session['auth_acl_id'] = str(acl.id)
return
@ -354,7 +354,7 @@ class AuthACLMixin:
acl = LoginACL.filter_acl(user).filter(id=acl_id).first()
if not acl:
return
if not acl.is_action(acl.ActionChoices.confirm):
if not acl.is_action(acl.ActionChoices.review):
return
self.get_ticket_or_create(acl)
self.check_user_login_confirm()

Loading…
Cancel
Save