make authorization rule a plain django form
This commit is contained in:
parent
bb4419d5de
commit
6c4c6a40b2
|
@ -36,6 +36,32 @@ from ..exponential_retry_timeout import ExponentialRetryTimeout
|
|||
OU = get_ou_model()
|
||||
|
||||
|
||||
class AuthorizationRuleCreateForm(forms.Form):
|
||||
"""
|
||||
todo: multiple choices charfield as radio buttons
|
||||
"""
|
||||
SCOPE_READ = 1
|
||||
SCOPE_WRITE = 2
|
||||
AUTHZ_SCOPES_CHOICES = (
|
||||
(SCOPE_READ, "Read"),
|
||||
(SCOPE_WRITE, "Write"),
|
||||
)
|
||||
SERVICE_URM = 1
|
||||
SERVICE_SPORTS = 2
|
||||
SERVICE_CULTURE = 3
|
||||
SERVICE_CATEGORY_CHOICES = (
|
||||
(SERVICE_URM, _("URM Services")),
|
||||
(SERVICE_SPORTS, _("Sports services")),
|
||||
(SERVICE_CULTURE, _("Cultural service")),
|
||||
)
|
||||
scopes = forms.MultipleChoiceField(
|
||||
choices=AUTHZ_SCOPES_CHOICES)
|
||||
validity = forms.SplitDateTimeField()
|
||||
service_categories = forms.MultipleChoiceField(
|
||||
help_text=_('Category of services for which the authorization rule applies'),
|
||||
choices = SERVICE_CATEGORY_CHOICES)
|
||||
|
||||
|
||||
class EmailChangeFormNoPassword(forms.Form):
|
||||
email = forms.EmailField(label=_('New email'))
|
||||
|
||||
|
|
|
@ -29,35 +29,7 @@ from .utils import ServiceAccessDenied
|
|||
|
||||
|
||||
class AuthorizationRule(models.Model):
|
||||
"""
|
||||
todo: multiple choices charfield as radio buttons
|
||||
"""
|
||||
SCOPE_READ = 1
|
||||
SCOPE_WRITE = 2
|
||||
AUTHZ_SCOPES_CHOICES = (
|
||||
(SCOPE_READ, "Read"),
|
||||
(SCOPE_WRITE, "Write"),
|
||||
)
|
||||
SERVICE_URM = 1
|
||||
SERVICE_SPORTS = 2
|
||||
SERVICE_CULTURE = 3
|
||||
SERVICE_CATEGORY_CHOICES = (
|
||||
(SERVICE_URM, _("URM Services")),
|
||||
(SERVICE_SPORTS, _("Sports services")),
|
||||
(SERVICE_CULTURE, _("Cultural service")),
|
||||
)
|
||||
scopes = models.CharField(
|
||||
verbose_name=_('scopes'),
|
||||
choices=AUTHZ_SCOPES_CHOICES,
|
||||
max_length=63)
|
||||
validity = models.DateTimeField(
|
||||
auto_now=True)
|
||||
service_categories = models.CharField(
|
||||
verbose_name=_('Service category'),
|
||||
help_text=_('Category of services for which the authorization rule applies'),
|
||||
choices = SERVICE_CATEGORY_CHOICES,
|
||||
default = SERVICE_URM,
|
||||
max_length=63)
|
||||
pass
|
||||
|
||||
|
||||
class DeletedUser(models.Model):
|
||||
|
|
|
@ -49,11 +49,10 @@ class AuthorizationRuleEditView(UpdateView):
|
|||
authorization_rule_edit_view = login_required(AuthorizationRuleEditView.as_view())
|
||||
|
||||
|
||||
class AuthorizationRuleCreateView(CreateView):
|
||||
model = models.AuthorizationRule
|
||||
class AuthorizationRuleCreateView(FormView):
|
||||
form_class = forms.AuthorizationRuleCreateForm
|
||||
template_name = "authentic2/create_authorization_rule.html"
|
||||
title = _('Create authorization Rule')
|
||||
fields = ['scopes']
|
||||
|
||||
authorization_rule_create_view = login_required(AuthorizationRuleCreateView.as_view())
|
||||
|
||||
|
|
Loading…
Reference in New Issue