Commit bdd52a80 by Bence Dányi

firewall_gui: list firewall rules

parent 3e5a8828
...@@ -94,4 +94,5 @@ urlpatterns = patterns('', ...@@ -94,4 +94,5 @@ urlpatterns = patterns('',
url(r'^accounts/(?P<site>profile)/$', 'one.views.sites'), url(r'^accounts/(?P<site>profile)/$', 'one.views.sites'),
url(r'^firewall/$', 'firewall_gui.views.index'), url(r'^firewall/$', 'firewall_gui.views.index'),
url(r'^firewall/rules/$', 'firewall_gui.views.list_rules'),
) )
...@@ -14,6 +14,12 @@ import random ...@@ -14,6 +14,12 @@ import random
settings = django.conf.settings.FIREWALL_SETTINGS settings = django.conf.settings.FIREWALL_SETTINGS
class Rule(models.Model): class Rule(models.Model):
"""
Common firewall rule
Rule can be applied to: Host, Firewall, Vlan
"""
CHOICES_type = (('host', 'host'), ('firewall', 'firewall'), CHOICES_type = (('host', 'host'), ('firewall', 'firewall'),
('vlan', 'vlan')) ('vlan', 'vlan'))
CHOICES_proto = (('tcp', 'tcp'), ('udp', 'udp'), ('icmp', 'icmp')) CHOICES_proto = (('tcp', 'tcp'), ('udp', 'udp'), ('icmp', 'icmp'))
......
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% get_current_language as lang %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{% templatetag openblock %} block title {% templatetag closeblock %}{{ project_name }}{% templatetag openblock %} endblock title {% templatetag closeblock %}</title> <title>{% block title %}Firewall GUI{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content=""> <meta name="description" content="">
<meta name="author" content=""> <meta name="author" content="">
<!-- Le styles --> <!-- Le styles -->
<link href="{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}css/bootstrap.min.css" rel="stylesheet"> <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet">
<style> <style>
body { body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */ padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
} }
</style> </style>
<link href="{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="{% static "css/bootstrap-responsive.min.css" %}" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
...@@ -22,11 +26,11 @@ ...@@ -22,11 +26,11 @@
<![endif]--> <![endif]-->
<!-- This file store project specific CSS --> <!-- This file store project specific CSS -->
<link href="{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}css/project.css" rel="stylesheet"> <link href="{% static "css/project.css" %}" rel="stylesheet">
<!-- Use this to quickly test CSS changes in a template, <!-- Use this to quickly test CSS changes in a template,
then move to project.css --> then move to project.css -->
{% templatetag openblock %} block extra_css {% templatetag closeblock %}{% templatetag openblock %} endblock extra_css {% templatetag closeblock %} {% block extra_css %}{% endblock %}
</head> </head>
<body> <body>
...@@ -53,11 +57,11 @@ ...@@ -53,11 +57,11 @@
<div class="container"> <div class="container">
<h1>{% templatetag openblock %} block page_title {% templatetag closeblock %}Example Base Template{% templatetag openblock %} endblock page_title {% templatetag closeblock %}</h1> <h1>{% block page_title %}Example Base Template{% endblock %}</h1>
{% templatetag openblock %} block content {% templatetag closeblock %} {% block content %}
<p>Use this document as a way to quick start any new project.</p> <p>Use this document as a way to quick start any new project.</p>
{% templatetag openblock %} endblock content {% templatetag closeblock %} {% endblock %}
</div> <!-- /container --> </div> <!-- /container -->
...@@ -68,8 +72,8 @@ ...@@ -68,8 +72,8 @@
<script src="{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}js/bootstrap.min.js"></script> <script src="{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}js/bootstrap.min.js"></script>
<!-- place project specific Javascript in this file --> <!-- place project specific Javascript in this file -->
<script src="{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}js/project.js"></script> <script src="{% static "js/project.js" %}"></script>
{% templatetag openblock %} block extra_js {% templatetag closeblock %}{% templatetag openblock %} endblock extra_js {% templatetag closeblock %} {% block extra_js %} {% endblock %}
</body> </body>
</html> </html>
{% extends "base2.html" %}
{% block content %}
{% for rule in rules %}
<li>{{rule}}</li>
{% endfor %}
{% endblock %}
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render
from firewall.fw import *
from firewall.models import *
def index(request): def index(request):
return HttpResponse("Ez itt a bd tuzfaladminja.") return HttpResponse("Ez itt a bd tuzfaladminja.")
def list_rules(request):
rules = Rule.objects.all()
return render(request, 'rule/list.html', {
'rules': rules,
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment