Skip to content
Snippets Groups Projects
Commit cab516e7 authored by David Schmitz's avatar David Schmitz
Browse files

fix combination

parent de533f8a
No related branches found
No related tags found
No related merge requests found
......@@ -70,6 +70,9 @@ class RouteSerializer(serializers.HyperlinkedModelSerializer):
if "applier" not in validated_data:
u = self.context.get('request').user
validated_data["applier"] = u
if "expires" not in validated_data and "isnonexpire" not in validated_data :
#validated_data["isnonexpire"] = True
validated_data["expires"] = "2999-01-01"
protocol = validated_data.pop('protocol', set())
then = validated_data.pop('then')
fragmenttype = validated_data.pop('fragmenttype', set())
......@@ -140,6 +143,9 @@ class RouteSerializer(serializers.HyperlinkedModelSerializer):
def update(self, instance, validated_data):
if 'name' in validated_data:
del validated_data["name"]
if "expires" not in validated_data and "isnonexpire" not in validated_data :
#validated_data["isnonexpire"] = True
validated_data["expires"] = "2999-01-01"
protocol = validated_data.pop('protocol', None)
if protocol:
instance.protocol.set(protocol)
......
......@@ -130,10 +130,10 @@ def delete(routepk, **kwargs):
commit, response = applier.apply(operation="delete")
reason_text = ''
logger.info("tasks::delete(): initial_status="+str(initial_status))
if commit:
if commit and initial_status == "PENDING_TODELETE": # special new case for fully deleting a rule via REST API (only for users/admins authorized by special settings)
route.status="INACTIVE"
msg1 = "[%s] Fully deleted route : %s%s- Result %s" % (route.applier, route.name, reason_text, response)
logger.info("tasks::delete(): DELETED msg="+msg1)
logger.info("tasks::delete(): FULLY DELETED msg="+msg1)
announce(msg1, route.applier, route)
try:
snmp_add_initial_zero_value(str(route.id), False)
......@@ -141,7 +141,19 @@ def delete(routepk, **kwargs):
logger.error("edit(): route="+str(route)+", INACTIVE, add_null_value failed: "+str(e))
route.delete()
return
else:
elif commit: # commit worked, but rule should stay in DB (NOT PENDING_TODELETE)
route.status="INACTIVE"
msg1 = "[%s] Deleted route : %s%s- Result %s" % (route.applier, route.name, reason_text, response)
logger.info("tasks::delete(): DELETED msg="+msg1)
announce(msg1, route.applier, route)
try:
snmp_add_initial_zero_value(str(route.id), False)
except Exception as e:
logger.error("edit(): route="+str(route)+", INACTIVE, add_null_value failed: "+str(e))
route.response = response
route.save()
return
else: # removing rule in NETCONF failed, it is still ACTIVE and also collects statistics
# NETCONF "delete" operation failed, keep the object in DB
if "reason" in kwargs and kwargs['reason'] == 'EXPIRED':
status = 'EXPIRED'
......
......@@ -21,7 +21,7 @@ function myreloadPage() {
<div class="row">
<div class="col-md-12">
<div>
<i class="fa fa-clock-o"></i> {% trans "Expires" %}: {{ route.expires|date:"d M y" }}
<i class="fa fa-clock-o"></i> {% trans "Expires" %}: {% if not route.is_no_expire %}{{ route.expires|date:"d M y" }}{% else %}{% trans "No" %}{% endif %}
</div>
</div>
<div class="col-md-12">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment