Added FQDN resolving in mail notification templates to denote the host that an action...
[flowspy] / 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