Revision 370ce61c

b/flowspec/tasks.py
150 150
                    admin_url = "https://%s%s" % \
151 151
                    (fqdn,
152 152
                     "/fod/edit/%s"%route.name)
153
                    mail_body = render_to_string("rule_expiration.txt",
154
                                             {"route": route, 'expiration_days':expiration_days, 'url':admin_url})
153
                    mail_body = render_to_string("rule_action.txt",
154
                                             {"route": route, 'expiration_days':expiration_days, 'action':'expires', 'url':admin_url})
155 155
                    days_num = ' days'
156 156
                    expiration_days_text = "%s %s" %('in',expiration_days)
157 157
                    if expiration_days == 0:
b/flowspec/views.py
118 118
            form.save_m2m()
119 119
            route.commit_add()
120 120
            requesters_address = request.META['HTTP_X_FORWARDED_FOR']
121
            mail_body = render_to_string("rule_add_mail.txt",
122
                                             {"route": route, "address": requesters_address})
121
            fqdn = Site.objects.get_current().domain
122
            admin_url = "https://%s%s" % (fqdn, "/fod/edit/%s"%route.name)
123
            mail_body = render_to_string("rule_action.txt",
124
                                             {"route": route, "address": requesters_address, "action": "creation", "url": admin_url})
123 125
            user_mail = "%s" %route.applier.email
124 126
            user_mail = user_mail.split(';')
125 127
            send_new_mail(settings.EMAIL_SUBJECT_PREFIX + "Rule %s creation request submitted by %s" %(route.name, route.applier.username),
......
189 191
                form.save_m2m()
190 192
                route.commit_edit()
191 193
                requesters_address = request.META['HTTP_X_FORWARDED_FOR']
192
                mail_body = render_to_string("rule_edit_mail.txt",
193
                                             {"route": route, "address": requesters_address})
194
                fqdn = Site.objects.get_current().domain
195
                admin_url = "https://%s%s" % (fqdn, "/fod/edit/%s"%route.name)
196
                mail_body = render_to_string("rule_action.txt",
197
                                             {"route": route, "address": requesters_address, "action": "edit", "url": admin_url})
194 198
                user_mail = "%s" %route.applier.email
195 199
                user_mail = user_mail.split(';')
196 200
                send_new_mail(settings.EMAIL_SUBJECT_PREFIX + "Rule %s edit request submitted by %s" %(route.name, route.applier.username),
......
239 243
            route.save()
240 244
            route.commit_delete()
241 245
            requesters_address = request.META['HTTP_X_FORWARDED_FOR']
242
            mail_body = render_to_string("rule_delete_mail.txt",
243
                                             {"route": route, "address": requesters_address})
246
            fqdn = Site.objects.get_current().domain
247
            admin_url = "https://%s%s" % (fqdn, "/fod/edit/%s"%route.name)
248
            mail_body = render_to_string("rule_action.txt",
249
                                             {"route": route, "address": requesters_address, "action": "removal", "url": admin_url})
244 250
            user_mail = "%s" %route.applier.email
245 251
            user_mail = user_mail.split(';')
246 252
            send_new_mail(settings.EMAIL_SUBJECT_PREFIX + "Rule %s removal request submitted by %s" %(route.name, route.applier.username), 
b/templates/rule_action.txt
1
{% load tofqdn %}{% ifequal action 'expires' %}Rule {{route.name}} expires {% ifequal expiration_days 0 %}today{% else%}in {{expiration_days}} day{{ expiration_days|pluralize }}{% endifequal %}{% else %}A new rule {{action}} job has spawned
2

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

  
6
Rule name: {{route.name}}{% endifequal %}
7

  
8
Match Statements:
9
* Source Address: {{route.source}}
10
* Destination Address: {{route.destination}}
11
* Protocol: {% if route.protocol.all %}{% for protocol in route.protocol.all %}{{ protocol }}{% if not forloop.last %}, {% endif %}{% endfor %}{% else %}any{% endif %}
12
* Ports: {% if route.sourceport.all or route.destinationport.all %}Defined by source/destination ports{% else %}{% if route.port.all %}{% for port in route.port.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}{% else %}any{% endif %}{% endif %}
13
* Source Ports: {% if route.port.all %}same as ports{% else %}{% if route.sourceport.all %}{% for port in route.sourceport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}{% else %}any{% endif %}{% endif %}
14
* Destination Ports: {% if route.port.all %}same as ports{% else %}{% if route.destinationport.all %}{% for port in route.destinationport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}{% else %}any{% endif %}{% endif %}
15

  
16
Then Actions:
17
* Action:{% for then in route.then.all %}{{ then }}{% if not forloop.last %}, {% endif %}{% endfor %}
18

  
19
Comments: {% if route.comments %}{{route.comments}}{% else %}-{% endif %}
20

  
21
Expires: {% ifequal action 'removal' %}Now, removal requested{%else%}{{route.expires}}{% endifequal %}
22

  
23
Rule url: {{url}}
24

  
/dev/null
1
{% load tofqdn %}
2
A new rule creation job has spawned
3

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

  
7
Match
8
* Dst Addr:{{route.destination}}
9
* Src Addr: {{route.source}}
10
* Protocol:{% for protocol in route.protocol.all %}{{ protocol }}{% if not forloop.last %}, {% endif %}{% endfor %}
11
* Ports:{% for port in route.ports.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
12
* Source Ports:{% for port in route.sourceport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
13
* Destination Ports:{% for port in route.destinationport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
14

  
15
*Then:{% for then in route.then.all %}{{ then }}{% if not forloop.last %}, {% endif %}{% endfor %}
/dev/null
1
{% load tofqdn %}
2
A new rule removal job has spawned
3

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

  
7
Match
8
* Dst Addr:{{route.destination}}
9
* Src Addr: {{route.source}}
10
* Protocol:{% for protocol in route.protocol.all %}{{ protocol }}{% if not forloop.last %}, {% endif %}{% endfor %}
11
* Ports:{% for port in route.ports.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
12
* Source Ports:{% for port in route.sourceport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
13
* Destination Ports:{% for port in route.destinationport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
14

  
15
*Then:{% for then in route.then.all %}{{ then }}{% if not forloop.last %}, {% endif %}{% endfor %}
/dev/null
1
{% load tofqdn %}
2
A new rule edit job has spawned
3

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

  
7
Match
8
* Dst Addr:{{route.destination}}
9
* Src Addr: {{route.source}}
10
* Protocol:{% for protocol in route.protocol.all %}{{ protocol }}{% if not forloop.last %}, {% endif %}{% endfor %}
11
* Ports:{% for port in route.ports.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
12
* Source Ports:{% for port in route.sourceport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
13
* Destination Ports:{% for port in route.destinationport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
14

  
15
* Then:{% for then in route.then.all %}{{ then }}{% if not forloop.last %}, {% endif %}{% endfor %}
/dev/null
1
Rule {{route.name}} expires {% ifequal expiration_days 0 %}today{% else%}in {{expiration_days}} day{{ expiration_days|pluralize }}{% endifequal %}
2

  
3
Match
4
* Dst Addr:{{route.destination}}
5
* Src Addr: {{route.source}}
6
* Protocol:{% for protocol in route.protocol.all %}{{ protocol }}{% if not forloop.last %}, {% endif %}{% endfor %}
7
* Ports:{% for port in route.ports.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
8
* Source Ports:{% for port in route.sourceport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
9
* Destination Ports:{% for port in route.destinationport.all %}{{ port }}{% if not forloop.last %}, {% endif %}{% endfor %}
10

  
11
*Then:{% for then in route.then.all %}{{ then }}{% if not forloop.last %}, {% endif %}{% endfor %}
12

  
13
Visit {{url}} to edit the rule.

Also available in: Unified diff