Revision ddffea2d

b/flowspec/templatetags/tofqdn.py
1
from django import template
2
from django.utils.safestring import mark_safe
3
from django.utils.encoding import force_unicode
4
import socket
5

  
6
register = template.Library()
7

  
8
@register.filter
9
def tofqdn(value):
10
    try:
11
        fqdn = socket.getfqdn(value)
12
        if fqdn == value:
13
            return False
14
        else:
15
            return fqdn
16
    except socket.gaierror:
17
        return False
18
        
b/templates/rule_add_mail.txt
1
{% load tofqdn %}
1 2
A new rule creation job has spawned
2 3

  
3 4
Peer: {{route.applier.get_profile.peer.peer_name}}
4
User {{route.applier.username}} requested the application of the following rule from address {{address}} :
5
User {{route.applier.username}} requested the application of the following rule from address {{address}} {% if address|tofqdn %}({{address|tofqdn}}){% endif %}:
5 6

  
6 7
Match
7 8
* Dst Addr:{{route.destination}}
b/templates/rule_delete_mail.txt
1
{% load tofqdn %}
1 2
A new rule removal job has spawned
2 3

  
3 4
Peer: {{route.applier.get_profile.peer.peer_name}}
4
User {{route.applier.username}} requested the removal of the following rule from address {{address}} :
5
User {{route.applier.username}} requested the removal of the following rule from address {{address}} {% if address|tofqdn %}({{address|tofqdn}}){% endif %}:
5 6

  
6 7
Match
7 8
* Dst Addr:{{route.destination}}
b/templates/rule_edit_mail.txt
1
{% load tofqdn %}
1 2
A new rule edit job has spawned
2 3

  
3 4
Peer: {{route.applier.get_profile.peer.peer_name}}
4
User {{route.applier.username}} requested the application of the following rule from address {{address}} :
5
User {{route.applier.username}} requested the application of the following rule from address {{address}} {% if address|tofqdn %}({{address|tofqdn}}){% endif %}:
5 6

  
6 7
Match
7 8
* Dst Addr:{{route.destination}}

Also available in: Unified diff