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

fix/prefix_overlap_handling: fix url escaped formatting with newer Django version

parent 4ceda3ff
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
from django import forms from django import forms
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.html import format_html
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy from django.utils.translation import ugettext_lazy
from django.template.defaultfilters import filesizeformat from django.template.defaultfilters import filesizeformat
...@@ -217,10 +218,11 @@ class RouteForm(forms.ModelForm): ...@@ -217,10 +218,11 @@ class RouteForm(forms.ModelForm):
existing_url = reverse('edit-route', args=[route.name]) existing_url = reverse('edit-route', args=[route.name])
net_route_destination = ip_network(route.destination, strict=False) net_route_destination = ip_network(route.destination, strict=False)
#if net_destination==net_route_destination or net_destination in net_route_destination or net_route_destination in net_destination: #if net_destination==net_route_destination or net_destination in net_route_destination or net_route_destination in net_destination:
route_name_fmted=format_html(route.name)
if net_destination==net_route_destination: if net_destination==net_route_destination:
raise forms.ValidationError('Found an exactly matching %s rule, %s with destination prefix %s<br>To avoid overlapping try editing rule <a href=\'%s\'>%s</a>' % (route.status, route.name, route.destination, existing_url, route.name)) raise forms.ValidationError(mark_safe('Found an exactly matching %s rule, %s with destination prefix %s<br>To avoid overlapping try editing rule <a href=\'%s\'>%s</a>' % (route.status, route_name_fmted, route.destination, existing_url, route_name_fmted)))
elif net_destination.overlaps(net_route_destination): elif net_destination.overlaps(net_route_destination):
raise forms.ValidationError('Found an overlapping %s rule, %s with destination prefix %s<br>To avoid overlapping try editing rule <a href=\'%s\'>%s</a>' % (route.status, route.name, route.destination, existing_url, route.name)) raise forms.ValidationError(mark_safe('Found an overlapping %s rule, %s with destination prefix %s<br>To avoid overlapping try editing rule <a href=\'%s\'>%s</a>' % (route.status, route_name_fmted, route.destination, existing_url, route_name_fmted)))
return self.cleaned_data return self.cleaned_data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment