From 2ab297ce564eeefcc8aa74e77872285c929d5ca9 Mon Sep 17 00:00:00 2001 From: Tomas Cejka <cejkat@cesnet.cz> Date: Wed, 7 Feb 2018 15:11:29 +0100 Subject: [PATCH] rule expiration: make max date configurable using settings.MAX_RULE_EXPIRE_DAYS --- flowspec/views.py | 16 ++++++++++------ flowspy/settings.py.dist | 2 ++ templates/apply.html | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/flowspec/views.py b/flowspec/views.py index 3680fdf5..bdf652a2 100644 --- a/flowspec/views.py +++ b/flowspec/views.py @@ -277,8 +277,10 @@ def add_route(request): if not request.user.is_superuser: form.fields['then'] = forms.ModelMultipleChoiceField(queryset=ThenAction.objects.filter(action__in=settings.UI_USER_THEN_ACTIONS).order_by('action'), required=True) form.fields['protocol'] = forms.ModelMultipleChoiceField(queryset=MatchProtocol.objects.filter(protocol__in=settings.UI_USER_PROTOCOLS).order_by('protocol'), required=False) - return render_to_response('apply.html', {'form': form, 'applier': applier}, - context_instance=RequestContext(request)) + return render_to_response('apply.html', {'form': form, + 'applier': applier, + 'maxexpires': settings.MAX_RULE_EXPIRE_DAYS }, + context_instance=RequestContext(request)) else: request_data = request.POST.copy() @@ -319,8 +321,8 @@ def add_route(request): 'apply.html', { 'form': form, - 'applier': applier - + 'applier': applier, + 'maxexpires': settings.MAX_RULE_EXPIRE_DAYS } ) @@ -401,7 +403,8 @@ def edit_route(request, route_slug): { 'form': form, 'edit': True, - 'applier': applier + 'applier': applier, + 'maxexpires': settings.MAX_RULE_EXPIRE_DAYS }, context_instance=RequestContext(request) ) @@ -425,7 +428,8 @@ def edit_route(request, route_slug): { 'form': form, 'edit': True, - 'applier': applier + 'applier': applier, + 'maxexpires': settings.MAX_RULE_EXPIRE_DAYS }, context_instance=RequestContext(request) ) diff --git a/flowspy/settings.py.dist b/flowspy/settings.py.dist index bfc060e2..27b65820 100644 --- a/flowspy/settings.py.dist +++ b/flowspy/settings.py.dist @@ -273,6 +273,8 @@ CELERY_IMPORTS = ("flowspec.tasks", ) SERVER_EMAIL = "Example FoD Service <noreply@example.com>" EMAIL_SUBJECT_PREFIX = "[FoD] " EXPIRATION_NOTIFY_DAYS = 4 +# max number of days into the future that is allowed to pick in rule expiration datepicker +MAX_RULE_EXPIRE_DAYS = 30 PREFIX_LENGTH = 29 # Shibboleth diff --git a/templates/apply.html b/templates/apply.html index 91cb7d36..74d341bb 100644 --- a/templates/apply.html +++ b/templates/apply.html @@ -94,7 +94,7 @@ $('#id_expires').datepicker({ startDate: '+1d', - endDate: '+10d' + endDate: '+{{maxexpires}}d' }); $('#setFromAll').click(function(){ $("#id_source").val('0.0.0.0/0'); -- GitLab