From 001c31ffc1b7b505a81e1c0ad902b6acb16587e9 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 14 Dec 2021 15:27:35 +0000 Subject: [PATCH] basic app for council climate plan scoring default app setup plus scss and an index view, also django hosts config to make it load --- proj/hosts.py | 8 ++++ proj/settings.py | 11 ++++++ scoring/__init__.py | 0 scoring/admin.py | 3 ++ scoring/apps.py | 6 +++ scoring/migrations/__init__.py | 0 scoring/models.py | 3 ++ scoring/static/scss/scoring.scss | 60 +++++++++++++++++++++++++++++ scoring/templates/scoring/base.html | 19 +++++++++ scoring/templates/scoring/home.html | 8 ++++ scoring/tests.py | 3 ++ scoring/urls.py | 8 ++++ scoring/views.py | 7 ++++ 13 files changed, 136 insertions(+) create mode 100644 proj/hosts.py create mode 100644 scoring/__init__.py create mode 100644 scoring/admin.py create mode 100644 scoring/apps.py create mode 100644 scoring/migrations/__init__.py create mode 100644 scoring/models.py create mode 100644 scoring/static/scss/scoring.scss create mode 100644 scoring/templates/scoring/base.html create mode 100644 scoring/templates/scoring/home.html create mode 100644 scoring/tests.py create mode 100644 scoring/urls.py create mode 100644 scoring/views.py diff --git a/proj/hosts.py b/proj/hosts.py new file mode 100644 index 000000000..14b08b7de --- /dev/null +++ b/proj/hosts.py @@ -0,0 +1,8 @@ +from django.conf import settings +from django_hosts import patterns, host + +host_patterns = patterns( + "", + host(r"data.climateemergency.uk", settings.ROOT_URLCONF, name="cape"), + host(r"((?:www.)?councilclimatescorecards)", "scoring.urls", name="scoring"), +) diff --git a/proj/settings.py b/proj/settings.py index 1e80d5acb..70b2ff089 100755 --- a/proj/settings.py +++ b/proj/settings.py @@ -20,6 +20,9 @@ SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) +ROOT_HOSTCONF = "proj.hosts" +DEFAULT_HOST = "cape" + DEBUG = True if DEBUG: @@ -99,6 +102,10 @@ "source_filenames": ("scss/main.scss",), "output_filename": "css/main.css", }, + "scoring": { + "source_filenames": ("scss/scoring.scss",), + "output_filename": "css/scoring.css", + }, }, "JAVASCRIPT": { "main": { @@ -145,12 +152,14 @@ "django.contrib.staticfiles", "django.contrib.humanize", "django_filters", + "django_hosts", "haystack", "pipeline", "bootstrap4", "rest_framework", "simple_history", "caps", + "scoring", ] HAYSTACK_CONNECTIONS = { @@ -173,6 +182,7 @@ } MIDDLEWARE = ( + "django_hosts.middleware.HostsRequestMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", @@ -181,6 +191,7 @@ "django.middleware.clickjacking.XFrameOptionsMiddleware", "htmlmin.middleware.HtmlMinifyMiddleware", "htmlmin.middleware.MarkRequestMiddleware", + "django_hosts.middleware.HostsResponseMiddleware", ) REST_FRAMEWORK = { diff --git a/scoring/__init__.py b/scoring/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/scoring/admin.py b/scoring/admin.py new file mode 100644 index 000000000..8c38f3f3d --- /dev/null +++ b/scoring/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/scoring/apps.py b/scoring/apps.py new file mode 100644 index 000000000..2da81b5ef --- /dev/null +++ b/scoring/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ScoringConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "scoring" diff --git a/scoring/migrations/__init__.py b/scoring/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/scoring/models.py b/scoring/models.py new file mode 100644 index 000000000..71a836239 --- /dev/null +++ b/scoring/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/scoring/static/scss/scoring.scss b/scoring/static/scss/scoring.scss new file mode 100644 index 000000000..95bdf317d --- /dev/null +++ b/scoring/static/scss/scoring.scss @@ -0,0 +1,60 @@ +@charset "utf-8"; + +// A NOTE ABOUT FILE PATHS +// +// django.contrib.staticfiles copies this file into the `STATIC_ROOT` +// (along with any other files/directories defined in `STATICFILES_DIRS`) +// and then django-pipeline compiles the Sass files from there. +// +// So imports in this file are relative to `/sass/main.scss`, +// not `/caps/static/scss/main.scss`. +// +// That’s why `@import "../bootstrap/" works – because at the +// point the Sass files are compiled, django.contrib.staticfiles has +// already copied the Bootstrap sass files into `/bootstrap/`. +// +// Note that this doesn't work on a dev thing with standard django-pipeline +// due to this issue: https://github.com/jazzband/django-pipeline/issues/749 +// so we are using a fork with the patch from the above issue + +@import "variables"; + +@import "../bootstrap/functions"; +@import "../bootstrap/variables"; +@import "../bootstrap/mixins"; +@import "../bootstrap/root"; +@import "../bootstrap/reboot"; +@import "../bootstrap/type"; +@import "../bootstrap/images"; +@import "../bootstrap/code"; +@import "../bootstrap/grid"; +@import "../bootstrap/tables"; +@import "../bootstrap/forms"; +@import "../bootstrap/buttons"; +@import "../bootstrap/transitions"; +// @import "../bootstrap/dropdown"; +// @import "../bootstrap/button-group"; +// @import "../bootstrap/input-group"; +// @import "../bootstrap/custom-forms"; +@import "../bootstrap/nav"; +@import "../bootstrap/navbar"; +@import "../bootstrap/card"; +// @import "../bootstrap/breadcrumb"; +// @import "../bootstrap/pagination"; +@import "../bootstrap/badge"; +// @import "../bootstrap/jumbotron"; +// @import "../bootstrap/alert"; +@import "../bootstrap/progress"; +// @import "../bootstrap/media"; +// @import "../bootstrap/list-group"; +// @import "../bootstrap/close"; +// @import "../bootstrap/toasts"; +@import "../bootstrap/modal"; +@import "../bootstrap/tooltip"; +// @import "../bootstrap/popover"; +// @import "../bootstrap/carousel"; +@import "../bootstrap/spinners"; +@import "../bootstrap/utilities"; +@import "../bootstrap/print"; + +@import "mysociety-standard-footer"; diff --git a/scoring/templates/scoring/base.html b/scoring/templates/scoring/base.html new file mode 100644 index 000000000..306f2eabb --- /dev/null +++ b/scoring/templates/scoring/base.html @@ -0,0 +1,19 @@ +{% load static %} +{% load pipeline %} + + + + + + + + SCORING + + {% stylesheet 'scoring' %} + + + +{% block content %}{% endblock %} + + + diff --git a/scoring/templates/scoring/home.html b/scoring/templates/scoring/home.html new file mode 100644 index 000000000..9b6439898 --- /dev/null +++ b/scoring/templates/scoring/home.html @@ -0,0 +1,8 @@ +{% extends "scoring/base.html" %} +{% block content %} + +

Council Climate Scorecards

+ +

holding page

+ +{% endblock %} diff --git a/scoring/tests.py b/scoring/tests.py new file mode 100644 index 000000000..7ce503c2d --- /dev/null +++ b/scoring/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/scoring/urls.py b/scoring/urls.py new file mode 100644 index 000000000..a5d062d57 --- /dev/null +++ b/scoring/urls.py @@ -0,0 +1,8 @@ +from django.urls import include, path +from django.contrib import admin + +import scoring.views as views + +urlpatterns = [ + path("", views.HomePageView.as_view(), name="home"), +] diff --git a/scoring/views.py b/scoring/views.py new file mode 100644 index 000000000..23983c34f --- /dev/null +++ b/scoring/views.py @@ -0,0 +1,7 @@ +from django.shortcuts import render + +from django.views.generic import TemplateView + + +class HomePageView(TemplateView): + template_name = "scoring/home.html"