summaryrefslogtreecommitdiffstats
path: root/virtualenv
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2014-01-22 13:21:58 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2014-01-22 13:21:58 (GMT)
commitcba8a5c9090eec84f4dca3f8db3384083f79c124 (patch)
treebaf3f92fd71df52f14e2801e35e9b8930ac9a9f5 /virtualenv
parent9a6fae60c8516c57f0f36a562347cee8501689c2 (diff)
downloadunivnautes-old-cba8a5c9090eec84f4dca3f8db3384083f79c124.zip
univnautes-old-cba8a5c9090eec84f4dca3f8db3384083f79c124.tar.gz
univnautes-old-cba8a5c9090eec84f4dca3f8db3384083f79c124.tar.bz2
pfidp/users_admin: disable expiration limit
Diffstat (limited to 'virtualenv')
-rw-r--r--virtualenv/pfidp/settings.py4
-rw-r--r--virtualenv/pfidp/users_admin/forms.py2
-rw-r--r--virtualenv/pfidp/users_admin/views.py34
3 files changed, 4 insertions, 36 deletions
diff --git a/virtualenv/pfidp/settings.py b/virtualenv/pfidp/settings.py
index 824a1b1..40831c5 100644
--- a/virtualenv/pfidp/settings.py
+++ b/virtualenv/pfidp/settings.py
@@ -324,8 +324,8 @@ PF_CONFIG_XML = '/conf/config.xml'
# store generated password here
CLEAR_PASSWORD_DIR = '/var/db/univnautes/pfidp/passwords'
-# maximum expiration (0 to disable)
-IDP_UA_MAX_EXPIRES = 7
+# default expiration
+IDP_UA_DEFAULT_EXPIRES = 7
# local_settings.py can be used to override environment-specific settings
# like database and email that differ between development and production.
diff --git a/virtualenv/pfidp/users_admin/forms.py b/virtualenv/pfidp/users_admin/forms.py
index d5655be..aa31e51 100644
--- a/virtualenv/pfidp/users_admin/forms.py
+++ b/virtualenv/pfidp/users_admin/forms.py
@@ -46,7 +46,7 @@ class NewUserForm(UserForm):
help_text="""Si vous n'indiquez pas de mot de passe, un mot de passe aléatoire sera
attribué à chaque utilisateur""",
widget=forms.PasswordInput(attrs={'size':'32', 'autocomplete':'off', 'class':'span3'}))
- expires = forms.DateField(label=u"Date d'expiration", required=(settings.IDP_UA_MAX_EXPIRES > 0),
+ expires = forms.DateField(label=u"Date d'expiration", required=True,
widget=forms.TextInput(attrs={'size':'16', 'class':'span2 datepicker'}))
userset_number = forms.IntegerField(label=u"Nombre d'utilisateur(s) à créer (login-N)",
widget=forms.TextInput(attrs={'size':'5', 'class':'span1'}),
diff --git a/virtualenv/pfidp/users_admin/views.py b/virtualenv/pfidp/users_admin/views.py
index 7b4cab5..95ac34a 100644
--- a/virtualenv/pfidp/users_admin/views.py
+++ b/virtualenv/pfidp/users_admin/views.py
@@ -34,19 +34,6 @@ def create(request):
form = NewUserForm(request.POST)
if form.is_valid():
expires = form.cleaned_data.get('expires')
- # check expiration date
- if settings.IDP_UA_MAX_EXPIRES > 0:
- try:
- delta = expires - datetime.date.today()
- if delta.days > settings.IDP_UA_MAX_EXPIRES:
- form.errors['expires'] = [u"Mauvaise date d'expiration " \
- u"(maximum %d jours à partir d'aujourd'hui)." % settings.IDP_UA_MAX_EXPIRES]
- except:
- form.errors['expires'] = [u"Mauvais format de date d'expiration (jj/mm/aaaa)."]
- if form.errors.get('expires'):
- return render_to_response('users_admin/create.html',
- { 'form': form, },
- context_instance=RequestContext(request))
name = form.cleaned_data.get('name')
password = form.cleaned_data.get('password')
descr = form.cleaned_data.get('descr')
@@ -79,10 +66,7 @@ def create(request):
'userset_number': 1,
'userset_start': 1,
}
- if settings.IDP_UA_MAX_EXPIRES > 0:
- dt = datetime.date.today() + datetime.timedelta(settings.IDP_UA_MAX_EXPIRES)
- else:
- dt = datetime.date.today() + datetime.timedelta(7) # one week, by default
+ dt = datetime.date.today() + datetime.timedelta(settings.IDP_UA_DEFAULT_EXPIRES)
initial['expires'] = dt.strftime('%d/%m/%Y')
form = NewUserForm(initial=initial)
return render_to_response('users_admin/create.html',
@@ -108,23 +92,7 @@ def update(request, name=None):
if request.method == 'POST':
form = UserForm(request.POST)
if form.is_valid():
- # check expiration date
expires = form.cleaned_data.get('expires')
- if settings.IDP_UA_MAX_EXPIRES > 0:
- # check only if the expire change
- if expires != user['expires']:
- try:
- delta = expires - datetime.date.today()
- if delta.days > settings.IDP_UA_MAX_EXPIRES:
- form.errors['expires'] = [u"Mauvaise date d'expiration " \
- u"(maximum %d jours à partir d'aujourd'hui)." % settings.IDP_UA_MAX_EXPIRES]
- except:
- form.errors['expires'] = [u"Mauvais format de date d'expiration (jj/mm/aaaa)."]
- if form.errors.get('expires'):
- return render_to_response('users_admin/update.html',
- { 'form': form, 'user': user, },
- context_instance=RequestContext(request))
- # modify the user
password = form.cleaned_data.get('password')
descr = form.cleaned_data.get('descr')
disabled = form.cleaned_data.get('disabled')