Revision 243819e7
b/accounts/serializers.py | ||
---|---|---|
1 |
from rest_framework import serializers |
|
2 |
from django.contrib.auth.models import User |
|
3 |
|
|
4 |
|
|
5 |
class UserSerializer(serializers.HyperlinkedModelSerializer): |
|
6 |
class Meta: |
|
7 |
model = User |
|
8 |
fields = ('url', 'username', 'email', 'is_staff') |
b/accounts/viewsets.py | ||
---|---|---|
1 |
from rest_framework import viewsets |
|
2 |
from django.contrib.auth.models import User |
|
3 |
from accounts.serializers import UserSerializer |
|
4 |
|
|
5 |
|
|
6 |
class UserViewSet(viewsets.ModelViewSet): |
|
7 |
queryset = User.objects.all() |
|
8 |
serializer_class = UserSerializer |
b/flowspec/serializers.py | ||
---|---|---|
1 |
from rest_framework import serializers |
|
2 |
from flowspec.models import ( |
|
3 |
MatchProtocol, |
|
4 |
FragmentType, |
|
5 |
ThenAction, |
|
6 |
Route, |
|
7 |
MatchPort |
|
8 |
) |
|
9 |
|
|
10 |
|
|
11 |
class MatchProtocolSerializer(serializers.HyperlinkedModelSerializer): |
|
12 |
class Meta: |
|
13 |
model = MatchProtocol |
|
14 |
fields = ('protocol',) |
|
15 |
|
|
16 |
|
|
17 |
class FragmentTypeSerializer(serializers.HyperlinkedModelSerializer): |
|
18 |
class Meta: |
|
19 |
model = FragmentType |
|
20 |
fields = ('fragmenttype',) |
|
21 |
|
|
22 |
|
|
23 |
class ThenActionSerializer(serializers.HyperlinkedModelSerializer): |
|
24 |
class Meta: |
|
25 |
model = ThenAction |
|
26 |
fields = ('action', 'action_value') |
|
27 |
|
|
28 |
|
|
29 |
class RouteSerializer(serializers.HyperlinkedModelSerializer): |
|
30 |
class Meta: |
|
31 |
model = Route |
|
32 |
fields = ('name', 'applier', 'source', 'sourceport', 'destination', 'destinationport', 'port', 'dscp', 'fragmenttype', 'protocol', 'then', 'status', 'comments', 'expires') |
|
33 |
|
|
34 |
|
|
35 |
class PortSerializer(serializers.HyperlinkedModelSerializer): |
|
36 |
class Meta: |
|
37 |
model = MatchPort |
|
38 |
fields = ('port',) |
b/flowspec/viewsets.py | ||
---|---|---|
1 |
from rest_framework import viewsets |
|
2 |
from flowspec.serializers import ( |
|
3 |
MatchProtocolSerializer, |
|
4 |
FragmentTypeSerializer, |
|
5 |
ThenActionSerializer, |
|
6 |
RouteSerializer, |
|
7 |
PortSerializer |
|
8 |
) |
|
9 |
|
|
10 |
|
|
11 |
from flowspec.models import ( |
|
12 |
MatchProtocol, |
|
13 |
FragmentType, |
|
14 |
ThenAction, |
|
15 |
Route, |
|
16 |
MatchPort |
|
17 |
) |
|
18 |
|
|
19 |
|
|
20 |
class MatchProtocolViewSet(viewsets.ModelViewSet): |
|
21 |
queryset = MatchProtocol.objects.all() |
|
22 |
serializer_class = MatchProtocolSerializer |
|
23 |
|
|
24 |
|
|
25 |
class FragmentTypeViewSet(viewsets.ModelViewSet): |
|
26 |
queryset = FragmentType.objects.all() |
|
27 |
serializer_class = FragmentTypeSerializer |
|
28 |
|
|
29 |
|
|
30 |
class ThenActionViewSet(viewsets.ModelViewSet): |
|
31 |
queryset = ThenAction.objects.all() |
|
32 |
serializer_class = ThenActionSerializer |
|
33 |
|
|
34 |
|
|
35 |
class RouteViewSet(viewsets.ModelViewSet): |
|
36 |
queryset = Route.objects.all() |
|
37 |
serializer_class = RouteSerializer |
|
38 |
|
|
39 |
|
|
40 |
class PortViewSet(viewsets.ModelViewSet): |
|
41 |
queryset = MatchPort.objects.all() |
|
42 |
serializer_class = PortSerializer |
b/flowspy/settings.py.dist | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- vim:fileencoding=utf-8: |
2 | 2 |
# vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab |
3 | 3 |
# Django settings for flowspy project. |
4 |
# Copyright © 2011-2014 Greek Research and Technology Network (GRNET S.A.)
|
|
4 |
# Copyright © 2011-2015 Greek Research and Technology Network (GRNET S.A.)
|
|
5 | 5 |
# Copyright © 2011-2014 Leonidas Poulopoulos (@leopoul) |
6 |
# |
|
6 |
# Copyright © 2014-2015 Stavros Kroustouris (@kroustou) |
|
7 |
# |
|
7 | 8 |
# Permission to use, copy, modify, and/or distribute this software for any |
8 | 9 |
# purpose with or without fee is hereby granted, provided that the above |
9 | 10 |
# copyright notice and this permission notice appear in all copies. |
10 |
#
|
|
11 |
# |
|
11 | 12 |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD |
12 | 13 |
# TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
13 | 14 |
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR |
... | ... | |
65 | 66 |
# http://www.i18nguy.com/unicode/language-identifiers.html |
66 | 67 |
LANGUAGE_CODE = 'en' |
67 | 68 |
|
68 |
LOCALE_PATHS = (
|
|
69 |
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'locale'),
|
|
69 |
LOCALE_PATHS = ( |
|
70 |
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'locale'), |
|
70 | 71 |
) |
71 | 72 |
|
72 | 73 |
SITE_ID = 1 |
... | ... | |
162 | 163 |
|
163 | 164 |
TEMPLATE_DIRS = ( |
164 | 165 |
'/path/to/templates/', |
166 |
'/path/to/rest_framework/templates/', |
|
165 | 167 |
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". |
166 | 168 |
# Always use forward slashes, even on Windows. |
167 | 169 |
# Don't forget to use absolute paths, not relative paths. |
... | ... | |
321 | 323 |
LOG_FILE_LOCATION = "/var/log/fod" |
322 | 324 |
|
323 | 325 |
# Change the following values only if you know what you are doing!!! |
324 |
# To integrate FoD with tables (Peer, Networks, Contacts)
|
|
325 |
# from your CRM platform, set the following values to False and create the views that are
|
|
326 |
# To integrate FoD with tables (Peer, Networks, Contacts) |
|
327 |
# from your CRM platform, set the following values to False and create the views that are |
|
326 | 328 |
# exact matches of the tables in peers/models.py |
327 | 329 |
PEER_MANAGED_TABLE = True |
328 | 330 |
PEER_RANGE_MANAGED_TABLE = True |
b/flowspy/urls.py.dist | ||
---|---|---|
1 | 1 |
from django.conf.urls import patterns, include, url |
2 | 2 |
from django.views.generic.simple import direct_to_template |
3 |
from django.conf import settings |
|
4 | 3 |
# Uncomment the next two lines to enable the admin: |
5 | 4 |
from django.contrib import admin |
6 | 5 |
admin.autodiscover() |
7 | 6 |
|
7 |
from rest_framework import routers |
|
8 |
from flowspec.viewsets import ( |
|
9 |
MatchProtocolViewSet, |
|
10 |
RouteViewSet, |
|
11 |
PortViewSet, |
|
12 |
FragmentTypeViewSet, |
|
13 |
ThenActionViewSet |
|
14 |
) |
|
15 |
|
|
16 |
from accounts.viewsets import UserViewSet |
|
17 |
|
|
18 |
|
|
19 |
# Routers provide an easy way of automatically determining the URL conf. |
|
20 |
router = routers.DefaultRouter() |
|
21 |
router.register(r'users', UserViewSet) |
|
22 |
router.register(r'routes', RouteViewSet) |
|
23 |
router.register(r'ports', PortViewSet) |
|
24 |
router.register(r'fragmenttypes', FragmentTypeViewSet) |
|
25 |
router.register(r'matchprotocols', MatchProtocolViewSet) |
|
26 |
router.register(r'then_action', ThenActionViewSet) |
|
27 |
|
|
8 | 28 |
urlpatterns = patterns('', |
9 |
# Example: |
|
10 | 29 |
(r'^poll/', include('poller.urls')), |
11 | 30 |
url(r'^/?$', 'flowspec.views.group_routes', name="group-routes"), |
12 | 31 |
url(r'^routes_ajax/?$', 'flowspec.views.group_routes_ajax', name="group-routes-ajax"), |
... | ... | |
22 | 41 |
url(r'^welcome/?', 'flowspec.views.welcome', name="welcome"), |
23 | 42 |
url(r'^logout/?', 'flowspec.views.user_logout', name="logout"), |
24 | 43 |
(r'^setlang/?$', 'django.views.i18n.set_language'), |
25 |
# Uncomment the admin/doc line below to enable admin documentation: |
|
26 | 44 |
(r'^admin/doc/', include('django.contrib.admindocs.urls')), |
27 |
url(r'^load_js/(?P<file>[\w\s\d_-]+)/$', 'flowspec.views.load_jscript', name="load-js"),
|
|
28 |
url(r'^selectinst/?$', 'flowspec.views.selectinst', name="selectinst"),
|
|
45 |
url(r'^load_js/(?P<file>[\w\s\d_-]+)/$', 'flowspec.views.load_jscript', name="load-js"), |
|
46 |
url(r'^selectinst/?$', 'flowspec.views.selectinst', name="selectinst"),
|
|
29 | 47 |
url(r'^accounts/activate/(?P<activation_key>\w+)/$', 'accounts.views.activate', name='activate_account'), |
30 | 48 |
url(r'^activate/complete/$', |
31 | 49 |
direct_to_template, |
... | ... | |
34 | 52 |
|
35 | 53 |
# Uncomment the next line to enable the admin: |
36 | 54 |
(r'^admin/', include(admin.site.urls)), |
37 |
(r'^tinymce/', include('tinymce.urls')),
|
|
38 |
|
|
39 |
|
|
55 |
(r'^tinymce/', include('tinymce.urls')),
|
|
56 |
|
|
57 |
|
|
40 | 58 |
url(r'^altlogin/?', 'django.contrib.auth.views.login', {'template_name': 'overview/login.html'}, name="altlogin"), |
41 | 59 |
url(r'^overview/?$', 'flowspec.views.overview', name="overview"), |
60 |
|
|
61 |
url(r'^api/v1/', include(router.urls)), |
|
62 |
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) |
|
42 | 63 |
) |
43 | 64 |
|
44 | 65 |
|
Also available in: Unified diff