Revision 88a6afb7 flowspec/forms.py
b/flowspec/forms.py | ||
---|---|---|
26 | 26 |
|
27 | 27 |
class Meta: |
28 | 28 |
model = Route |
29 |
|
|
29 |
|
|
30 |
def clean_applier(self): |
|
31 |
applier = self.cleaned_data['applier'] |
|
32 |
if applier: |
|
33 |
return self.cleaned_data["applier"] |
|
34 |
else: |
|
35 |
raise forms.ValidationError('This field is required.') |
|
36 |
|
|
30 | 37 |
def clean_source(self): |
31 | 38 |
user = User.objects.get(pk=self.data['applier']) |
32 | 39 |
peer = user.get_profile().peer |
... | ... | |
107 | 114 |
destinationports = self.cleaned_data.get('destinationport', None) |
108 | 115 |
protocols = self.cleaned_data.get('protocol', None) |
109 | 116 |
user = self.cleaned_data.get('applier', None) |
117 |
try: |
|
118 |
issuperuser = self.data['issuperuser'] |
|
119 |
su = User.objects.get(username=issuperuser) |
|
120 |
except: |
|
121 |
issuperuser = None |
|
110 | 122 |
peer = user.get_profile().peer |
111 | 123 |
networks = peer.networks.all() |
112 |
if user.is_superuser:
|
|
124 |
if issuperuser:
|
|
113 | 125 |
networks = PeerRange.objects.filter(peer__in=Peer.objects.all()).distinct() |
114 | 126 |
mynetwork = False |
115 | 127 |
route_pk_list = [] |
... | ... | |
119 | 131 |
if IPNetwork(destination) in net: |
120 | 132 |
mynetwork = True |
121 | 133 |
if not mynetwork: |
122 |
raise forms.ValidationError('Destination address/network should belong to your administrative address space. Check My Profile to review your networks')
|
|
134 |
raise forms.ValidationError('Destination address/network should belong to your administrative address space. Check My Profile to review your networks') |
|
123 | 135 |
if (sourceports and ports): |
124 | 136 |
raise forms.ValidationError('Cannot create rule for source ports and ports at the same time. Select either ports or source ports') |
125 | 137 |
if (destinationports and ports): |
Also available in: Unified diff