Commit bb7b01f1 authored by Bonnegent Sebastien's avatar Bonnegent Sebastien
Browse files

cours 3 corrigé

parent 63322dc5
......@@ -121,6 +121,7 @@ $ pipenv install</code></pre>
<li>Parefeu</li>
<li>Regle</li>
</ul></li>
<li>1er page web</li>
</ul>
</section></section>
<section><section id="clé-étrangère" class="title-slide slide level1"><h1>Clé étrangère</h1></section><section id="foreignkey" class="slide level2">
......@@ -284,7 +285,7 @@ $ pipenv run ./manage.py migrate</code></pre>
<h2>à modifier</h2>
<h3 id="webuimodels.py-4">webui/models.py</h3>
<p>Ajouter Regle.liste_des_services()</p>
<h3 id="webuimodels.py-5">webui/models.py</h3>
<h3 id="webuiadmin.py-3">webui/admin.py</h3>
<p>Ajouter la colonne “liste_des_services” entre “groupe” et “interface”</p>
</section></section>
<section><section id="mvc" class="title-slide slide level1"><h1>MVC</h1></section><section id="modèle-vue-contrôleur" class="slide level2">
......@@ -302,7 +303,6 @@ $ pipenv run ./manage.py migrate</code></pre>
<li>webui/views.py</li>
<li>templates</li>
<li>conf/urls.py</li>
<li>webui/urls.py</li>
</ul>
</section><section id="modèle-vue-contrôleur-2" class="slide level2">
<h2>Modèle Vue Contrôleur</h2>
......@@ -366,31 +366,23 @@ $ pipenv run ./manage.py migrate</code></pre>
</section><section id="templates" class="slide level2">
<h2>Templates</h2>
<h3 id="webuitemplateswebuihome.html">webui/templates/webui/home.html</h3>
<div class="sourceCode" id="cb13"><pre class="sourceCode html"><code class="sourceCode html"><a class="sourceLine" id="cb13-1" title="1">{% load static %}</a>
<a class="sourceLine" id="cb13-2" title="2"><span class="dt">&lt;!doctype </span>html<span class="dt">&gt;</span></a>
<a class="sourceLine" id="cb13-3" title="3"><span class="kw">&lt;html</span><span class="ot"> lang=</span><span class="st">&quot;fr&quot;</span><span class="kw">&gt;&lt;head&gt;</span></a>
<a class="sourceLine" id="cb13-4" title="4"><span class="kw">&lt;meta</span><span class="ot"> charset=</span><span class="st">&quot;utf-8&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb13-5" title="5"><span class="kw">&lt;meta</span><span class="ot"> name=</span><span class="st">&quot;viewport&quot;</span></a>
<a class="sourceLine" id="cb13-6" title="6"><span class="ot"> content=</span><span class="st">&quot;width=device-width, initial-scale=1, </span></a>
<a class="sourceLine" id="cb13-7" title="7"><span class="st"> shrink-to-fit=no&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb13-8" title="8"><span class="kw">&lt;title&gt;</span>Garage<span class="kw">&lt;/title&gt;</span></a>
<a class="sourceLine" id="cb13-9" title="9"><span class="kw">&lt;link</span><span class="ot"> rel=</span><span class="st">&quot;stylesheet&quot;</span></a>
<a class="sourceLine" id="cb13-10" title="10"><span class="ot"> href=</span><span class="st">&quot;{% static &#39;bootstrap/css/bootstrap.min.css&#39; %}&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb13-11" title="11"><span class="kw">&lt;script</span><span class="ot"> defer</span> </a>
<a class="sourceLine" id="cb13-12" title="12"><span class="ot"> src=</span><span class="st">&quot;{% static &#39;fontawesome/js/fontawesome-all.min.js&#39; %}&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb13-13" title="13"><span class="kw">&lt;/script&gt;&lt;/head&gt;</span></a></code></pre></div>
<div class="sourceCode" id="cb13"><pre class="sourceCode html"><code class="sourceCode html"><a class="sourceLine" id="cb13-1" title="1"><span class="dt">&lt;!doctype </span>html<span class="dt">&gt;</span></a>
<a class="sourceLine" id="cb13-2" title="2"><span class="kw">&lt;html</span><span class="ot"> lang=</span><span class="st">&quot;fr&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb13-3" title="3">{% load static %}</a>
<a class="sourceLine" id="cb13-4" title="4"><span class="kw">&lt;head&gt;</span></a>
<a class="sourceLine" id="cb13-5" title="5"> <span class="kw">&lt;title&gt;</span>{% block title %}Parefeux{% endblock %}<span class="kw">&lt;/title&gt;</span></a>
<a class="sourceLine" id="cb13-6" title="6"> <span class="kw">&lt;link</span><span class="ot"> rel=</span><span class="st">&quot;stylesheet&quot;</span><span class="ot"> href=</span><span class="st">&quot;{% static &#39;bootstrap/css/bootstrap.min.css&#39; %}&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb13-7" title="7"> <span class="kw">&lt;script</span><span class="ot"> defer src=</span><span class="st">&quot;{% static &#39;fontawesome/js/all.min.js&#39; %}&quot;</span><span class="kw">&gt;&lt;/script&gt;</span></a>
<a class="sourceLine" id="cb13-8" title="8"><span class="kw">&lt;/head&gt;</span></a>
<a class="sourceLine" id="cb13-9" title="9"><span class="kw">&lt;body&gt;</span></a></code></pre></div>
</section><section id="templates-1" class="slide level2">
<h2>Templates</h2>
<h3 id="webuitemplateswebuihome.html-1">webui/templates/webui/home.html</h3>
<div class="sourceCode" id="cb14"><pre class="sourceCode html"><code class="sourceCode html"><a class="sourceLine" id="cb14-1" title="1"><span class="kw">&lt;body&gt;</span></a>
<a class="sourceLine" id="cb14-2" title="2">{% block content %}<span class="kw">&lt;p&gt;</span>Bienvenue !<span class="kw">&lt;/p&gt;</span>{% endblock %}</a>
<a class="sourceLine" id="cb14-3" title="3"></a>
<a class="sourceLine" id="cb14-4" title="4"><span class="kw">&lt;script</span><span class="ot"> src=</span><span class="st">&quot;{% static &#39;bootstrap/js/jquery.min.js&#39; %}&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb14-5" title="5"><span class="kw">&lt;/script&gt;</span></a>
<a class="sourceLine" id="cb14-6" title="6"><span class="kw">&lt;script</span><span class="ot"> src=</span><span class="st">&quot;{% static &#39;bootstrap/js/bootstrap.min.js&#39; %}&quot;</span><span class="kw">&gt;</span></a>
<a class="sourceLine" id="cb14-7" title="7"><span class="kw">&lt;/script&gt;</span></a>
<a class="sourceLine" id="cb14-8" title="8"><span class="kw">&lt;/body&gt;</span></a>
<a class="sourceLine" id="cb14-9" title="9"><span class="kw">&lt;/html&gt;</span></a></code></pre></div>
<div class="sourceCode" id="cb14"><pre class="sourceCode html"><code class="sourceCode html"><a class="sourceLine" id="cb14-1" title="1">{% block content %}<span class="kw">&lt;p&gt;</span>Bienvenue !<span class="kw">&lt;/p&gt;</span>{% endblock %}</a>
<a class="sourceLine" id="cb14-2" title="2"> <span class="kw">&lt;script</span><span class="ot"> src=</span><span class="st">&quot;{% static &#39;bootstrap/js/jquery.min.js&#39; %}&quot;</span><span class="kw">&gt;&lt;/script&gt;</span></a>
<a class="sourceLine" id="cb14-3" title="3"> <span class="kw">&lt;script</span><span class="ot"> src=</span><span class="st">&quot;{% static &#39;bootstrap/js/bootstrap.min.js&#39; %}&quot;</span><span class="kw">&gt;&lt;/script&gt;</span></a>
<a class="sourceLine" id="cb14-4" title="4"><span class="kw">&lt;/body&gt;</span></a>
<a class="sourceLine" id="cb14-5" title="5"><span class="kw">&lt;/html&gt;</span></a></code></pre></div>
</section><section id="modifier-la-vue" class="slide level2">
<h2>Modifier la vue</h2>
<h3 id="webuiviews.py-1">webui/views.py</h3>
......@@ -398,6 +390,8 @@ $ pipenv run ./manage.py migrate</code></pre>
<a class="sourceLine" id="cb15-2" title="2"></a>
<a class="sourceLine" id="cb15-3" title="3"><span class="kw">def</span> home_v2(request):</a>
<a class="sourceLine" id="cb15-4" title="4"> <span class="cf">return</span> render(request, <span class="st">&#39;webui/home.html&#39;</span>, {}) </a></code></pre></div>
<h3 id="confurls.py-1">conf/urls.py</h3>
<p>Modifier le nom de la fonction</p>
</section><section id="navbar" class="slide level2">
<h2>Navbar</h2>
<h3 id="webuitemplateswebuihome.html-2">webui/templates/webui/home.html</h3>
......@@ -420,30 +414,6 @@ $ pipenv run ./manage.py migrate</code></pre>
<a class="sourceLine" id="cb16-17" title="17"> <span class="kw">&lt;/ul&gt;</span></a>
<a class="sourceLine" id="cb16-18" title="18"> <span class="kw">&lt;/div&gt;</span></a>
<a class="sourceLine" id="cb16-19" title="19"><span class="kw">&lt;/nav&gt;</span></a></code></pre></div>
</section><section id="authentification" class="slide level2">
<h2>Authentification</h2>
<h3 id="confurls.py-1">conf/urls.py</h3>
<div class="sourceCode" id="cb17"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb17-1" title="1"><span class="co"># ...</span></a>
<a class="sourceLine" id="cb17-2" title="2">path(<span class="st">&#39;accounts/&#39;</span>, include(<span class="st">&#39;django.contrib.auth.urls&#39;</span>)),</a>
<a class="sourceLine" id="cb17-3" title="3"><span class="co"># ...</span></a></code></pre></div>
<h3 id="confsettings.py-1">conf/settings.py</h3>
<div class="sourceCode" id="cb18"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb18-1" title="1">LOGOUT_REDIRECT_URL <span class="op">=</span> <span class="st">&#39;/&#39;</span></a>
<a class="sourceLine" id="cb18-2" title="2">LOGIN_REDIRECT_URL <span class="op">=</span> <span class="st">&#39;/&#39;</span></a></code></pre></div>
</section><section id="templates-2" class="slide level2">
<h2>Templates</h2>
<h3 id="webuitemplatesregistrationlogin.html">webui/templates/registration/login.html</h3>
<ul>
<li>le template doit être présent</li>
</ul>
</section><section id="templates-3" class="slide level2">
<h2>Templates</h2>
<h3 id="webuitemplateswebuihome.html-3">webui/templates/webui/home.html</h3>
<pre><code>{% if user.is_authenticated %}
...
{% if user.is_staff %}
...
{% endif %}
{% endif %}</code></pre>
</section></section>
<section><section id="fin" class="title-slide slide level1"><h1>FIN !</h1></section></section>
<section class="footnotes">
......
......@@ -24,6 +24,7 @@ $ pipenv install
- suite des modèles avec relations
- Parefeu
- Regle
- 1er page web
# Clé étrangère
## ForeignKey
......@@ -187,7 +188,7 @@ Modifier l'ordre de tri des Règles pour avoir:
### webui/models.py
Ajouter Regle.liste_des_services()
### webui/models.py
### webui/admin.py
Ajouter la colonne "liste_des_services"
entre "groupe" et "interface"
......@@ -203,7 +204,6 @@ entre "groupe" et "interface"
- webui/views.py
- templates
- conf/urls.py
- webui/urls.py
## Modèle Vue Contrôleur
### Contrôleur
......@@ -273,32 +273,24 @@ INSTALLED_APPS = [
### webui/templates/webui/home.html
~~~html
{% load static %}
<!doctype html>
<html lang="fr"><head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<title>Garage</title>
<link rel="stylesheet"
href="{% static 'bootstrap/css/bootstrap.min.css' %}">
<script defer
src="{% static 'fontawesome/js/fontawesome-all.min.js' %}">
</script></head>
<html lang="fr">
{% load static %}
<head>
<title>{% block title %}Parefeux{% endblock %}</title>
<link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}">
<script defer src="{% static 'fontawesome/js/all.min.js' %}"></script>
</head>
<body>
~~~
## Templates
### webui/templates/webui/home.html
~~~html
<body>
{% block content %}<p>Bienvenue !</p>{% endblock %}
<script src="{% static 'bootstrap/js/jquery.min.js' %}">
</script>
<script src="{% static 'bootstrap/js/bootstrap.min.js' %}">
</script>
<script src="{% static 'bootstrap/js/jquery.min.js' %}"></script>
<script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
</body>
</html>
~~~
......@@ -313,6 +305,9 @@ def home_v2(request):
return render(request, 'webui/home.html', {})
~~~
### conf/urls.py
Modifier le nom de la fonction
## Navbar
### webui/templates/webui/home.html
......@@ -338,34 +333,4 @@ def home_v2(request):
</nav>
~~~
## Authentification
### conf/urls.py
~~~python
# ...
path('accounts/', include('django.contrib.auth.urls')),
# ...
~~~
### conf/settings.py
~~~python
LOGOUT_REDIRECT_URL = '/'
LOGIN_REDIRECT_URL = '/'
~~~
## Templates
### webui/templates/registration/login.html
- le template doit être présent
## Templates
### webui/templates/webui/home.html
~~~
{% if user.is_authenticated %}
...
{% if user.is_staff %}
...
{% endif %}
{% endif %}
~~~
# FIN !
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
django = "*"
django-extensions = "*"
ipython = "*"
django-bootstrap-static = "*"
fontawesome = "*"
[requires]
python_version = "3.6"
{
"_meta": {
"hash": {
"sha256": "5eaa1b0486397527fe82e874288132e34a53a04d2cc347a3af9edd36ac6d4122"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.6"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"backcall": {
"hashes": [
"sha256:38ecd85be2c1e78f77fd91700c76e14667dc21e2713b63876c0eb901196e01e4",
"sha256:bbbf4b1e5cd2bdb08f915895b51081c041bac22394fdfcfdfbe9f14b77c08bf2"
],
"version": "==0.1.0"
},
"decorator": {
"hashes": [
"sha256:54c38050039232e1db4ad7375cfce6748d7b41c29e95a081c8a6d2c30364a2ce",
"sha256:5d19b92a3c8f7f101c8dd86afd86b0f061a8ce4540ab8cd401fa2542756bce6d"
],
"version": "==4.4.1"
},
"django": {
"hashes": [
"sha256:16040e1288c6c9f68c6da2fe75ebde83c0a158f6f5d54f4c5177b0c1478c5b86",
"sha256:89c2007ca4fa5b351a51a279eccff298520783b713bf28efb89dfb81c80ea49b"
],
"index": "pypi",
"version": "==2.2.7"
},
"django-bootstrap-static": {
"hashes": [
"sha256:d9f1f9f7561efb9a73cd80a380d26628047805540ddb12002a453cebb6a74fed",
"sha256:fb8516189604b783f24a76e582ccbd90254ba81499dcf01e04e9016666760e8c"
],
"index": "pypi",
"version": "==4.2.1"
},
"django-extensions": {
"hashes": [
"sha256:a9db7c56a556d244184f589f2437b4228de86ee45e5ebb837fb20c6d54e95ea5",
"sha256:b58320d3fe3d6ae7d1d8e38959713fa92272f4921e662d689058d942a5b444f7"
],
"index": "pypi",
"version": "==2.2.5"
},
"fontawesome": {
"hashes": [
"sha256:1b5e8f2ed12a74b88aef6f404ff770af425324041bc5620523a802d5406595b8",
"sha256:642d74da5f4726bb2c8f035a2f4a98fdc4294d213a291994ee0b3d845166f9e8"
],
"index": "pypi",
"version": "==5.10.1.post1"
},
"ipython": {
"hashes": [
"sha256:dfd303b270b7b5232b3d08bd30ec6fd685d8a58cabd54055e3d69d8f029f7280",
"sha256:ed7ebe1cba899c1c3ccad6f7f1c2d2369464cc77dba8eebc65e2043e19cda995"
],
"index": "pypi",
"version": "==7.9.0"
},
"ipython-genutils": {
"hashes": [
"sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8",
"sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"
],
"version": "==0.2.0"
},
"jedi": {
"hashes": [
"sha256:786b6c3d80e2f06fd77162a07fed81b8baa22dde5d62896a790a331d6ac21a27",
"sha256:ba859c74fa3c966a22f2aeebe1b74ee27e2a462f56d3f5f7ca4a59af61bfe42e"
],
"version": "==0.15.1"
},
"parso": {
"hashes": [
"sha256:63854233e1fadb5da97f2744b6b24346d2750b85965e7e399bec1620232797dc",
"sha256:666b0ee4a7a1220f65d367617f2cd3ffddff3e205f3f16a0284df30e774c2a9c"
],
"version": "==0.5.1"
},
"pexpect": {
"hashes": [
"sha256:2094eefdfcf37a1fdbfb9aa090862c1a4878e5c7e0e7e7088bdb511c558e5cd1",
"sha256:9e2c1fd0e6ee3a49b28f95d4b33bc389c89b20af6a1255906e90ff1262ce62eb"
],
"markers": "sys_platform != 'win32'",
"version": "==4.7.0"
},
"pickleshare": {
"hashes": [
"sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca",
"sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56"
],
"version": "==0.7.5"
},
"prompt-toolkit": {
"hashes": [
"sha256:46642344ce457641f28fc9d1c9ca939b63dadf8df128b86f1b9860e59c73a5e4",
"sha256:e7f8af9e3d70f514373bf41aa51bc33af12a6db3f71461ea47fea985defb2c31",
"sha256:f15af68f66e664eaa559d4ac8a928111eebd5feda0c11738b5998045224829db"
],
"version": "==2.0.10"
},
"ptyprocess": {
"hashes": [
"sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0",
"sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f"
],
"version": "==0.6.0"
},
"pygments": {
"hashes": [
"sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127",
"sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297"
],
"version": "==2.4.2"
},
"pytz": {
"hashes": [
"sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d",
"sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be"
],
"version": "==2019.3"
},
"six": {
"hashes": [
"sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd",
"sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66"
],
"version": "==1.13.0"
},
"sqlparse": {
"hashes": [
"sha256:40afe6b8d4b1117e7dff5504d7a8ce07d9a1b15aeeade8a2d10f130a834f8177",
"sha256:7c3dca29c022744e95b547e867cee89f4fce4373f3549ccd8797d8eb52cdb873"
],
"version": "==0.3.0"
},
"traitlets": {
"hashes": [
"sha256:70b4c6a1d9019d7b4f6846832288f86998aa3b9207c6821f3578a6a6a467fe44",
"sha256:d023ee369ddd2763310e4c3eae1ff649689440d4ae59d7485eb4cfbbe3e359f7"
],
"version": "==4.3.3"
},
"wcwidth": {
"hashes": [
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
"sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"
],
"version": "==0.1.7"
}
},
"develop": {}
}
"""
Django settings for conf project.
Generated by 'django-admin startproject' using Django 2.2.6.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'ldo+99!dbim5qy+es_y(vj6%1+-j5n4lwaops3ovy=rmt&#b1_'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
LOGOUT_REDIRECT_URL = '/'
LOGIN_REDIRECT_URL = '/'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'webui',
'django_extensions',
'bootstrap',
'fontawesome',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'conf.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'conf.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'
"""conf URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from webui import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home_v2, name='home'),
path('accounts/', include('django.contrib.auth.urls')),
]
"""
WSGI config for conf project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conf.settings')
application = get_wsgi_application()
File added
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conf.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
from django.contrib import admin
from .models import Adresse, Port, Service, Groupe, Parefeu, Regle
class AdresseAdmin(admin.ModelAdmin):
list_display = ('nom', 'ip', 'masque')
admin.site.register(Adresse, AdresseAdmin)
class PortAdmin(admin.ModelAdmin):
list_display = ('debut', 'fin', 'protocole')
admin.site.register(Port, PortAdmin)