Skip to content
Snippets Groups Projects
Commit 6e9a9419 authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos
Browse files

Minor fixes. Added expiration date to admin interface. Distinguish between add...

Minor fixes. Added expiration date to admin interface. Distinguish between add and edit in admin. Different handling
parent 5366dc62
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ from django.contrib.auth.admin import UserAdmin
from accounts.models import UserProfile
from flowspy.flowspec.forms import *
import datetime
from django.conf import settings
class RouteAdmin(admin.ModelAdmin):
form = RouteForm
......@@ -21,8 +22,10 @@ class RouteAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
obj.status = "PENDING"
obj.expires = datetime.date.today()
obj.save()
if change:
obj.commit_edit()
else:
obj.commit_add()
def has_delete_permission(self, request, obj=None):
......@@ -35,6 +38,7 @@ class RouteAdmin(admin.ModelAdmin):
("Match", {'fields': ['source', 'sourceport', 'destination', 'destinationport', 'port']}),
('Advanced Match Statements', {'fields': ['dscp', 'fragmenttype', 'icmpcode', 'icmptype', 'packetlength', 'protocol', 'tcpflag'], 'classes': ['collapse']}),
("Then", {'fields': ['then' ]}),
("Expires", {'fields': ['expires' ]}),
(None, {'fields': ['comments',]}),
]
......
......@@ -6,6 +6,7 @@ import json
from celery.task.http import *
from flowspy.utils import beanstalkc
from django.conf import settings
import datetime
import os
......@@ -92,6 +93,7 @@ def batch_delete(routes, **kwargs):
for route in routes:
route.status = status
route.response = response
route.expires = datetime.date.today()
route.save()
subtask(announce).delay("[%s] Rule removal: %s%s- Result %s" %(route.applier, route.name, reason_text, response), route.applier)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment