root / flowspec / admin.py @ d50fd7b6
History | View | Annotate | Download (2.2 kB)
1 |
from django.contrib import admin |
---|---|
2 |
from flowspy.flowspec.models import * |
3 |
from flowspy.accounts.models import * |
4 |
from utils import proxy as PR |
5 |
from flowspec.tasks import * |
6 |
from django.contrib.auth.models import User |
7 |
from django.contrib.auth.admin import UserAdmin |
8 |
from accounts.models import UserProfile |
9 |
|
10 |
|
11 |
class RouteAdmin(admin.ModelAdmin): |
12 |
|
13 |
actions = ['deactivate']
|
14 |
|
15 |
def deactivate(self, request, queryset): |
16 |
response = batch_delete.delay(queryset, reason="ADMININACTIVE")
|
17 |
self.message_user(request, "Added request %s to job que. Check in a while for result" % response) |
18 |
deactivate.short_description = "Remove selected routes from network"
|
19 |
|
20 |
list_display = ('name', 'status', 'applier' , 'applier_peer', 'get_match', 'get_then', 'response') |
21 |
fieldsets = [ |
22 |
(None, {'fields': ['name','applier']}), |
23 |
("Match", {'fields': ['source', 'sourceport', 'destination', 'destinationport', 'port']}), |
24 |
('Advanced Match Statements', {'fields': ['dscp', 'fragmenttype', 'icmpcode', 'icmptype', 'packetlength', 'protocol', 'tcpflag'], 'classes': ['collapse']}), |
25 |
("Then", {'fields': ['then' ]}), |
26 |
(None, {'fields': ['comments',]}), |
27 |
|
28 |
] |
29 |
|
30 |
class UserProfileInline(admin.StackedInline): |
31 |
model = UserProfile |
32 |
|
33 |
class UserProfileAdmin(UserAdmin): |
34 |
inlines = [UserProfileInline] |
35 |
# fields = ('name', 'applier', 'expires')
|
36 |
|
37 |
#def formfield_for_dbfield(self, db_field, **kwargs):
|
38 |
# if db_field.name == 'password':
|
39 |
# kwargs['widget'] = PasswordInput
|
40 |
# return db_field.formfield(**kwargs)
|
41 |
|
42 |
#admin.site.register(MatchAddress)
|
43 |
admin.site.unregister(User) |
44 |
admin.site.register(MatchPort) |
45 |
admin.site.register(MatchDscp) |
46 |
admin.site.register(UserProfile) |
47 |
#admin.site.register(MatchFragmentType)
|
48 |
#admin.site.register(MatchIcmpCode)
|
49 |
#admin.site.register(MatchIcmpType)
|
50 |
#admin.site.register(MatchPacketLength)
|
51 |
#admin.site.register(MatchProtocol)
|
52 |
#admin.site.register(MatchTcpFlag)
|
53 |
admin.site.register(ThenAction) |
54 |
#admin.site.register(ThenStatement)
|
55 |
#admin.site.register(MatchStatement)
|
56 |
admin.site.register(Route, RouteAdmin) |
57 |
admin.site.register(User, UserProfileAdmin) |
58 |
admin.site.disable_action('delete_selected')
|
59 |
|
60 |
|