initial commit.
This commit is contained in:
commit
69633a52e7
22 changed files with 600 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
db.sqlite3
|
||||
static
|
||||
media
|
21
manage.py
Executable file
21
manage.py
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sdbs_infra.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()
|
142
poetry.lock
generated
Normal file
142
poetry.lock
generated
Normal file
|
@ -0,0 +1,142 @@
|
|||
[[package]]
|
||||
category = "main"
|
||||
description = "ASGI specs, helper code, and adapters"
|
||||
name = "asgiref"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
version = "3.2.7"
|
||||
|
||||
[package.extras]
|
||||
tests = ["pytest (>=4.3.0,<4.4.0)", "pytest-asyncio (>=0.10.0,<0.11.0)"]
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Screen-scraping library"
|
||||
name = "beautifulsoup4"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "4.9.1"
|
||||
|
||||
[package.dependencies]
|
||||
soupsieve = [">1.2", "<2.0"]
|
||||
|
||||
[package.extras]
|
||||
html5lib = ["html5lib"]
|
||||
lxml = ["lxml"]
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "A high-level Python Web framework that encourages rapid development and clean, pragmatic design."
|
||||
name = "django"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
version = "3.0.7"
|
||||
|
||||
[package.dependencies]
|
||||
asgiref = ">=3.2,<4.0"
|
||||
pytz = "*"
|
||||
sqlparse = ">=0.2.2"
|
||||
|
||||
[package.extras]
|
||||
argon2 = ["argon2-cffi (>=16.1.0)"]
|
||||
bcrypt = ["bcrypt"]
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Allows Django models to be ordered and provides a simple admin interface for reordering them."
|
||||
name = "django-ordered-model"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "3.4.1"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python Imaging Library (Fork)"
|
||||
name = "pillow"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
version = "7.1.2"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "World timezone definitions, modern and historical"
|
||||
name = "pytz"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "2020.1"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "A modern CSS selector implementation for Beautiful Soup."
|
||||
name = "soupsieve"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "1.9.6"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Non-validating SQL parser"
|
||||
name = "sqlparse"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
version = "0.3.1"
|
||||
|
||||
[metadata]
|
||||
content-hash = "e59cbc9240f4a13c17bade71c39a64fe70c17eaf4746afc82fc9a36b5fa4ae10"
|
||||
python-versions = "^3.7"
|
||||
|
||||
[metadata.files]
|
||||
asgiref = [
|
||||
{file = "asgiref-3.2.7-py2.py3-none-any.whl", hash = "sha256:9ca8b952a0a9afa61d30aa6d3d9b570bb3fd6bafcf7ec9e6bed43b936133db1c"},
|
||||
{file = "asgiref-3.2.7.tar.gz", hash = "sha256:8036f90603c54e93521e5777b2b9a39ba1bad05773fcf2d208f0299d1df58ce5"},
|
||||
]
|
||||
beautifulsoup4 = [
|
||||
{file = "beautifulsoup4-4.9.1-py2-none-any.whl", hash = "sha256:e718f2342e2e099b640a34ab782407b7b676f47ee272d6739e60b8ea23829f2c"},
|
||||
{file = "beautifulsoup4-4.9.1-py3-none-any.whl", hash = "sha256:a6237df3c32ccfaee4fd201c8f5f9d9df619b93121d01353a64a73ce8c6ef9a8"},
|
||||
{file = "beautifulsoup4-4.9.1.tar.gz", hash = "sha256:73cc4d115b96f79c7d77c1c7f7a0a8d4c57860d1041df407dd1aae7f07a77fd7"},
|
||||
]
|
||||
django = [
|
||||
{file = "Django-3.0.7-py3-none-any.whl", hash = "sha256:e1630333248c9b3d4e38f02093a26f1e07b271ca896d73097457996e0fae12e8"},
|
||||
{file = "Django-3.0.7.tar.gz", hash = "sha256:5052b34b34b3425233c682e0e11d658fd6efd587d11335a0203d827224ada8f2"},
|
||||
]
|
||||
django-ordered-model = [
|
||||
{file = "django-ordered-model-3.4.1.tar.gz", hash = "sha256:d867166ed4dd12501139e119cbbc5b4d19798a3e72740aef0af4879ba97102cf"},
|
||||
{file = "django_ordered_model-3.4.1-py3-none-any.whl", hash = "sha256:29af6624cf3505daaf0df00e2df1d0726dd777b95e08f304d5ad0264092aa934"},
|
||||
]
|
||||
pillow = [
|
||||
{file = "Pillow-7.1.2-cp35-cp35m-macosx_10_10_intel.whl", hash = "sha256:ae2b270f9a0b8822b98655cb3a59cdb1bd54a34807c6c56b76dd2e786c3b7db3"},
|
||||
{file = "Pillow-7.1.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:d23e2aa9b969cf9c26edfb4b56307792b8b374202810bd949effd1c6e11ebd6d"},
|
||||
{file = "Pillow-7.1.2-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:b532bcc2f008e96fd9241177ec580829dee817b090532f43e54074ecffdcd97f"},
|
||||
{file = "Pillow-7.1.2-cp35-cp35m-win32.whl", hash = "sha256:12e4bad6bddd8546a2f9771485c7e3d2b546b458ae8ff79621214119ac244523"},
|
||||
{file = "Pillow-7.1.2-cp35-cp35m-win_amd64.whl", hash = "sha256:9744350687459234867cbebfe9df8f35ef9e1538f3e729adbd8fde0761adb705"},
|
||||
{file = "Pillow-7.1.2-cp36-cp36m-macosx_10_10_x86_64.whl", hash = "sha256:f54be399340aa602066adb63a86a6a5d4f395adfdd9da2b9a0162ea808c7b276"},
|
||||
{file = "Pillow-7.1.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:1f694e28c169655c50bb89a3fa07f3b854d71eb47f50783621de813979ba87f3"},
|
||||
{file = "Pillow-7.1.2-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:f784aad988f12c80aacfa5b381ec21fd3f38f851720f652b9f33facc5101cf4d"},
|
||||
{file = "Pillow-7.1.2-cp36-cp36m-win32.whl", hash = "sha256:b37bb3bd35edf53125b0ff257822afa6962649995cbdfde2791ddb62b239f891"},
|
||||
{file = "Pillow-7.1.2-cp36-cp36m-win_amd64.whl", hash = "sha256:b67a6c47ed963c709ed24566daa3f95a18f07d3831334da570c71da53d97d088"},
|
||||
{file = "Pillow-7.1.2-cp37-cp37m-macosx_10_10_x86_64.whl", hash = "sha256:eaa83729eab9c60884f362ada982d3a06beaa6cc8b084cf9f76cae7739481dfa"},
|
||||
{file = "Pillow-7.1.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:f46e0e024346e1474083c729d50de909974237c72daca05393ee32389dabe457"},
|
||||
{file = "Pillow-7.1.2-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:0e2a3bceb0fd4e0cb17192ae506d5f082b309ffe5fc370a5667959c9b2f85fa3"},
|
||||
{file = "Pillow-7.1.2-cp37-cp37m-win32.whl", hash = "sha256:ccc9ad2460eb5bee5642eaf75a0438d7f8887d484490d5117b98edd7f33118b7"},
|
||||
{file = "Pillow-7.1.2-cp37-cp37m-win_amd64.whl", hash = "sha256:b943e71c2065ade6fef223358e56c167fc6ce31c50bc7a02dd5c17ee4338e8ac"},
|
||||
{file = "Pillow-7.1.2-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:04766c4930c174b46fd72d450674612ab44cca977ebbcc2dde722c6933290107"},
|
||||
{file = "Pillow-7.1.2-cp38-cp38-manylinux1_i686.whl", hash = "sha256:f455efb7a98557412dc6f8e463c1faf1f1911ec2432059fa3e582b6000fc90e2"},
|
||||
{file = "Pillow-7.1.2-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:ee94fce8d003ac9fd206496f2707efe9eadcb278d94c271f129ab36aa7181344"},
|
||||
{file = "Pillow-7.1.2-cp38-cp38-win32.whl", hash = "sha256:4b02b9c27fad2054932e89f39703646d0c543f21d3cc5b8e05434215121c28cd"},
|
||||
{file = "Pillow-7.1.2-cp38-cp38-win_amd64.whl", hash = "sha256:3d25dd8d688f7318dca6d8cd4f962a360ee40346c15893ae3b95c061cdbc4079"},
|
||||
{file = "Pillow-7.1.2-pp373-pypy36_pp73-win32.whl", hash = "sha256:0f01e63c34f0e1e2580cc0b24e86a5ccbbfa8830909a52ee17624c4193224cd9"},
|
||||
{file = "Pillow-7.1.2-py3.8-macosx-10.9-x86_64.egg", hash = "sha256:70e3e0d99a0dcda66283a185f80697a9b08806963c6149c8e6c5f452b2aa59c0"},
|
||||
{file = "Pillow-7.1.2.tar.gz", hash = "sha256:a0b49960110bc6ff5fead46013bcb8825d101026d466f3a4de3476defe0fb0dd"},
|
||||
]
|
||||
pytz = [
|
||||
{file = "pytz-2020.1-py2.py3-none-any.whl", hash = "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed"},
|
||||
{file = "pytz-2020.1.tar.gz", hash = "sha256:c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048"},
|
||||
]
|
||||
soupsieve = [
|
||||
{file = "soupsieve-1.9.6-py2.py3-none-any.whl", hash = "sha256:feb1e937fa26a69e08436aad4a9037cd7e1d4c7212909502ba30701247ff8abd"},
|
||||
{file = "soupsieve-1.9.6.tar.gz", hash = "sha256:7985bacc98c34923a439967c1a602dc4f1e15f923b6fcf02344184f86cc7efaa"},
|
||||
]
|
||||
sqlparse = [
|
||||
{file = "sqlparse-0.3.1-py2.py3-none-any.whl", hash = "sha256:022fb9c87b524d1f7862b3037e541f68597a730a8843245c349fc93e1643dc4e"},
|
||||
{file = "sqlparse-0.3.1.tar.gz", hash = "sha256:e162203737712307dfe78860cc56c8da8a852ab2ee33750e33aeadf38d12c548"},
|
||||
]
|
18
pyproject.toml
Normal file
18
pyproject.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
[tool.poetry]
|
||||
name = "sdbs_infra"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Tomáš Mládek <t@mldk.cz>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.7"
|
||||
django = "^3.0.7"
|
||||
django-ordered-model = "^3.4.1"
|
||||
Pillow = "^7.1.2"
|
||||
beautifulsoup4 = "^4.9.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
0
sdbs_infra/__init__.py
Normal file
0
sdbs_infra/__init__.py
Normal file
16
sdbs_infra/asgi.py
Normal file
16
sdbs_infra/asgi.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
ASGI config for sdbs_infra project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sdbs_infra.settings')
|
||||
|
||||
application = get_asgi_application()
|
0
sdbs_infra/dashboard/__init__.py
Normal file
0
sdbs_infra/dashboard/__init__.py
Normal file
11
sdbs_infra/dashboard/admin.py
Normal file
11
sdbs_infra/dashboard/admin.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from django.contrib import admin
|
||||
from ordered_model.admin import OrderedModelAdmin
|
||||
|
||||
from sdbs_infra.dashboard.models import Service
|
||||
|
||||
|
||||
class ServiceAdmin(OrderedModelAdmin):
|
||||
list_display = ('short_name', 'url', 'move_up_down_links')
|
||||
|
||||
|
||||
admin.site.register(Service, ServiceAdmin)
|
5
sdbs_infra/dashboard/apps.py
Normal file
5
sdbs_infra/dashboard/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class DashboardConfig(AppConfig):
|
||||
name = 'dashboard'
|
28
sdbs_infra/dashboard/migrations/0001_initial.py
Normal file
28
sdbs_infra/dashboard/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-13 20:17
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Service',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('order', models.PositiveIntegerField(db_index=True, editable=False, verbose_name='order')),
|
||||
('short_name', models.CharField(max_length=64)),
|
||||
('description', models.TextField()),
|
||||
('url', models.URLField()),
|
||||
],
|
||||
options={
|
||||
'ordering': ('order',),
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
18
sdbs_infra/dashboard/migrations/0002_service_image.py
Normal file
18
sdbs_infra/dashboard/migrations/0002_service_image.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-13 20:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dashboard', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='service',
|
||||
name='image',
|
||||
field=models.FileField(null=True, upload_to=''),
|
||||
),
|
||||
]
|
23
sdbs_infra/dashboard/migrations/0003_auto_20200613_2021.py
Normal file
23
sdbs_infra/dashboard/migrations/0003_auto_20200613_2021.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-13 20:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dashboard', '0002_service_image'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='service',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='service',
|
||||
name='image',
|
||||
field=models.FileField(blank=True, null=True, upload_to=''),
|
||||
),
|
||||
]
|
18
sdbs_infra/dashboard/migrations/0004_auto_20200613_2022.py
Normal file
18
sdbs_infra/dashboard/migrations/0004_auto_20200613_2022.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-13 20:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dashboard', '0003_auto_20200613_2021'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='service',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, null=True, upload_to=''),
|
||||
),
|
||||
]
|
18
sdbs_infra/dashboard/migrations/0005_auto_20200613_2032.py
Normal file
18
sdbs_infra/dashboard/migrations/0005_auto_20200613_2032.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-13 20:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dashboard', '0004_auto_20200613_2022'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='service',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='services'),
|
||||
),
|
||||
]
|
0
sdbs_infra/dashboard/migrations/__init__.py
Normal file
0
sdbs_infra/dashboard/migrations/__init__.py
Normal file
53
sdbs_infra/dashboard/models.py
Normal file
53
sdbs_infra/dashboard/models.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
import urllib.request
|
||||
from enum import Enum
|
||||
from urllib.error import URLError
|
||||
from urllib.request import Request
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from django.db import models
|
||||
from django.utils.functional import cached_property
|
||||
from ordered_model.models import OrderedModel
|
||||
|
||||
|
||||
class ServiceStatus(Enum):
|
||||
OK = 'ok'
|
||||
DOWN = 'down'
|
||||
UNKNOWN = 'unknown'
|
||||
|
||||
|
||||
class Service(OrderedModel):
|
||||
short_name = models.CharField(null=False, max_length=64)
|
||||
image = models.ImageField(null=True, blank=True, upload_to='services')
|
||||
description = models.TextField(null=True, blank=True)
|
||||
url = models.URLField()
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.short_name} ({self.url})"
|
||||
|
||||
@cached_property
|
||||
def index_request(self):
|
||||
try:
|
||||
request = Request(self.url, headers={'User-Agent': 'its just me humble status page'})
|
||||
return urllib.request.urlopen(request)
|
||||
except URLError:
|
||||
return None
|
||||
|
||||
def get_status(self):
|
||||
if self.index_request and self.index_request.getcode() == 200:
|
||||
return ServiceStatus.OK
|
||||
else:
|
||||
return ServiceStatus.DOWN
|
||||
|
||||
@cached_property
|
||||
def image_or_favicon(self):
|
||||
if self.image:
|
||||
return self.image.url
|
||||
|
||||
if self.index_request:
|
||||
parsed_html = BeautifulSoup(self.index_request, features="html.parser")
|
||||
link_tags = parsed_html.find_all('link')
|
||||
for rel in ['apple-touch-icon', 'shortcut', 'icon']:
|
||||
for link_tag in link_tags:
|
||||
if rel in link_tag.attrs['rel']:
|
||||
result = link_tag.attrs['href']
|
||||
return (self.url + result) if self.url not in result else result
|
37
sdbs_infra/dashboard/templates/index.html
Normal file
37
sdbs_infra/dashboard/templates/index.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>/-\ infra status page</title>
|
||||
<link rel="stylesheet" href="{% static "main.css" %}">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>/-\ infrastructure</h1>
|
||||
<h2>status page</h2>
|
||||
</header>
|
||||
<main>
|
||||
{% for service in services %}
|
||||
<a class="service status-{{ service.get_status.value }}" href="{{ service.url }}">
|
||||
<section class="service-content">
|
||||
{% if service.image_or_favicon %}
|
||||
<div class="image">
|
||||
<img src="{{ service.image_or_favicon }}" alt="image for {{ service }}"/>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="label">
|
||||
<h3>{{ service.short_name }}</h3>
|
||||
{% if service.description %}
|
||||
<p class="description">{{ service.description }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
<section class="service-status">
|
||||
STATUS: {{ service.get_status.value }}
|
||||
</section>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
3
sdbs_infra/dashboard/tests.py
Normal file
3
sdbs_infra/dashboard/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
13
sdbs_infra/dashboard/views.py
Normal file
13
sdbs_infra/dashboard/views.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from django.views.decorators.cache import cache_page
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from sdbs_infra.dashboard.models import Service
|
||||
|
||||
|
||||
class IndexView(TemplateView):
|
||||
template_name = "index.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
return {
|
||||
'services': Service.objects.all()
|
||||
}
|
127
sdbs_infra/settings.py
Normal file
127
sdbs_infra/settings.py
Normal file
|
@ -0,0 +1,127 @@
|
|||
"""
|
||||
Django settings for sdbs_infra project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.0.7.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.0/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/3.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'c1*&au6fevdetq2#1g0c3qai4-!)r**j%u%vmrkgtairox3^t5'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.staticfiles',
|
||||
'ordered_model',
|
||||
'sdbs_infra.dashboard'
|
||||
]
|
||||
|
||||
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 = 'sdbs_infra.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 = 'sdbs_infra.wsgi.application'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
if DEBUG:
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
||||
}
|
||||
}
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.0/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/3.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = "static"
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = "media"
|
30
sdbs_infra/urls.py
Normal file
30
sdbs_infra/urls.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"""sdbs_infra URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/3.0/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.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
from sdbs_infra import settings
|
||||
from sdbs_infra.dashboard.views import IndexView
|
||||
|
||||
urlpatterns = [
|
||||
path('', cache_page(10)(IndexView.as_view())),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
16
sdbs_infra/wsgi.py
Normal file
16
sdbs_infra/wsgi.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
WSGI config for sdbs_infra 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/3.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sdbs_infra.settings')
|
||||
|
||||
application = get_wsgi_application()
|
Loading…
Reference in a new issue