Skip to content

Commit

Permalink
Merge pull request #8 from opensafely-core/evansd/minimal-deployable-app
Browse files Browse the repository at this point in the history
Minimal deployable application
  • Loading branch information
evansd authored Jan 19, 2024
2 parents 624b192 + 9edd16c commit 940cfb5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 11 deletions.
14 changes: 7 additions & 7 deletions airlock/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ def get_env_var(name):
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = get_env_var("DJANGO_DEBUG") == "True"

ALLOWED_HOSTS = []
ALLOWED_HOSTS = get_env_var("DJANGO_ALLOWED_HOSTS").split(",")


# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"airlock",
# "django.contrib.auth",
# "django.contrib.contenttypes",
# "django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]
Expand All @@ -73,7 +73,7 @@ def get_env_var(name):
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
# "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
Expand All @@ -89,7 +89,7 @@ def get_env_var(name):
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
# "django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
Expand Down
10 changes: 10 additions & 0 deletions airlock/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>{% block metatitle %}Airlock{% endblock metatitle %}</title>
</head>

<body>
{% block body %}{% endblock %}
</body>
</html>
6 changes: 6 additions & 0 deletions airlock/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "base.html" %}

{% block body %}
<h1>Airlock</h1>
<p>Hello World</p>
{% endblock body %}
5 changes: 3 additions & 2 deletions airlock/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
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

import airlock.views


urlpatterns = [
path("admin/", admin.site.urls),
path("", airlock.views.index, name="home"),
]
5 changes: 5 additions & 0 deletions airlock/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.template.response import TemplateResponse


def index(request):
return TemplateResponse(request, "index.html")
2 changes: 1 addition & 1 deletion dotenv-sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Default environment variables for local development

DJANGO_DEBUG=True

DJANGO_SECRET_KEY="INSECURE-if-you-use-this-in-prod-you-will-have-a-bad-day"
DJANGO_ALLOWED_HOSTS="*"

AIRLOCK_WORK_DIR=workdir/
Empty file added tests/integration/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions tests/integration/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_index(client):
response = client.get("/")
assert "Hello World" in response.rendered_content
2 changes: 1 addition & 1 deletion tests/unit/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# TODO: Stub test to get us started with
def test_urls():
assert resolve("/admin/")
assert resolve("/")

0 comments on commit 940cfb5

Please sign in to comment.