Revision c2f4725d flowspec/models.py

b/flowspec/models.py
4 4
from django.db import models
5 5
from django.conf import settings
6 6
from django.contrib.auth.models import User
7
from django.utils.translation import ugettext_lazy as _
7 8
from utils import proxy as PR
8 9
from ipaddr import *
9 10
import datetime
......
103 104
        unique_together = ("action", "action_value")
104 105

  
105 106
class Route(models.Model):
106
    name = models.SlugField(max_length=128)
107
    name = models.SlugField(max_length=128, verbose_name=_("Name"))
107 108
    applier = models.ForeignKey(User, blank=True, null=True)
108
    source = models.CharField(max_length=32, help_text=u"Network address. Use address/CIDR notation", verbose_name="Source Address")
109
    sourceport = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchSourcePort", verbose_name="Source Port")
110
    destination = models.CharField(max_length=32, help_text=u"Network address. Use address/CIDR notation", verbose_name="Destination Address")
111
    destinationport = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchDestinationPort", verbose_name="Destination Port")
112
    port = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchPort", verbose_name="Port" )
109
    source = models.CharField(max_length=32, help_text=_("Network address. Use address/CIDR notation"), verbose_name=_("Source Address"))
110
    sourceport = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchSourcePort", verbose_name=_("Source Port"))
111
    destination = models.CharField(max_length=32, help_text=_("Network address. Use address/CIDR notation"), verbose_name=_("Destination Address"))
112
    destinationport = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchDestinationPort", verbose_name=_("Destination Port"))
113
    port = models.ManyToManyField(MatchPort, blank=True, null=True, related_name="matchPort", verbose_name=_("Port"))
113 114
    dscp = models.ManyToManyField(MatchDscp, blank=True, null=True, verbose_name="DSCP")
114 115
    fragmenttype = models.CharField(max_length=20, choices=FRAGMENT_CODES, blank=True, null=True, verbose_name="Fragment Type")
115 116
    icmpcode = models.CharField(max_length=32, blank=True, null=True, verbose_name="ICMP Code")
116 117
    icmptype = models.CharField(max_length=32, blank=True, null=True, verbose_name="ICMP Type")
117 118
    packetlength = models.IntegerField(blank=True, null=True, verbose_name="Packet Length")
118
    protocol = models.ManyToManyField(MatchProtocol, blank=True, null=True, verbose_name="Protocol")
119
    protocol = models.ManyToManyField(MatchProtocol, blank=True, null=True, verbose_name=_("Protocol"))
119 120
    tcpflag = models.CharField(max_length=128, blank=True, null=True, verbose_name="TCP flag")
120
    then = models.ManyToManyField(ThenAction, verbose_name="Then")
121
    then = models.ManyToManyField(ThenAction, verbose_name=_("Then"))
121 122
    filed = models.DateTimeField(auto_now_add=True)
122 123
    last_updated = models.DateTimeField(auto_now=True)
123
    status = models.CharField(max_length=20, choices=ROUTE_STATES, blank=True, null=True, verbose_name="Status", default="PENDING")
124
    status = models.CharField(max_length=20, choices=ROUTE_STATES, blank=True, null=True, verbose_name=_("Status"), default="PENDING")
124 125
#    is_online = models.BooleanField(default=False)
125 126
#    is_active = models.BooleanField(default=False)
126
    expires = models.DateField(default=days_offset)
127
    response = models.CharField(max_length=512, blank=True, null=True)
128
    comments = models.TextField(null=True, blank=True, verbose_name="Comments")
127
    expires = models.DateField(default=days_offset, verbose_name=_("Expires"))
128
    response = models.CharField(max_length=512, blank=True, null=True, verbose_name=_("Response"))
129
    comments = models.TextField(null=True, blank=True, verbose_name=_("Comments"))
129 130

  
130 131
    
131 132
    def __unicode__(self):
......
150 151
                address = IPNetwork(self.destination)
151 152
                self.destination = address.exploded
152 153
            except Exception:
153
                raise ValidationError('Invalid network address format at Destination Field')
154
                raise ValidationError(_('Invalid network address format at Destination Field'))
154 155
        if self.source:
155 156
            try:
156 157
                address = IPNetwork(self.source)
157 158
                self.source = address.exploded
158 159
            except Exception:
159
                raise ValidationError('Invalid network address format at Source Field')
160
                raise ValidationError(_('Invalid network address format at Source Field'))
160 161
   
161 162
    def commit_add(self, *args, **kwargs):
162 163
        peer = self.applier.get_profile().peer.domain_name

Also available in: Unified diff