Skip to content

Commit

Permalink
basic app for council climate plan scoring
Browse files Browse the repository at this point in the history
default app setup plus scss and an index view, also django hosts config
to make it load
  • Loading branch information
struan committed Jan 12, 2022
1 parent 3553f48 commit 001c31f
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 0 deletions.
8 changes: 8 additions & 0 deletions proj/hosts.py
Original file line number Diff line number Diff line change
@@ -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"),
)
11 changes: 11 additions & 0 deletions proj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

SITE_ROOT = os.path.realpath(os.path.dirname(__file__))

ROOT_HOSTCONF = "proj.hosts"
DEFAULT_HOST = "cape"

DEBUG = True

if DEBUG:
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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 = {
Expand All @@ -173,6 +182,7 @@
}

MIDDLEWARE = (
"django_hosts.middleware.HostsRequestMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
Expand All @@ -181,6 +191,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"htmlmin.middleware.HtmlMinifyMiddleware",
"htmlmin.middleware.MarkRequestMiddleware",
"django_hosts.middleware.HostsResponseMiddleware",
)

REST_FRAMEWORK = {
Expand Down
Empty file added scoring/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions scoring/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions scoring/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ScoringConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "scoring"
Empty file added scoring/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions scoring/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
60 changes: 60 additions & 0 deletions scoring/static/scss/scoring.scss
Original file line number Diff line number Diff line change
@@ -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 `<STATIC_ROOT>/sass/main.scss`,
// not `/caps/static/scss/main.scss`.
//
// That’s why `@import "../bootstrap/<whatever>" works – because at the
// point the Sass files are compiled, django.contrib.staticfiles has
// already copied the Bootstrap sass files into `<STATIC_ROOT>/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";
19 changes: 19 additions & 0 deletions scoring/templates/scoring/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% load static %}
{% load pipeline %}

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SCORING</title>

{% stylesheet 'scoring' %}
</head>
<body class="{% block bodyclass %}{% endblock %}">

{% block content %}{% endblock %}

</body>
</html>
8 changes: 8 additions & 0 deletions scoring/templates/scoring/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "scoring/base.html" %}
{% block content %}

<h1>Council Climate Scorecards</h1>

<p>holding page</p>

{% endblock %}
3 changes: 3 additions & 0 deletions scoring/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
8 changes: 8 additions & 0 deletions scoring/urls.py
Original file line number Diff line number Diff line change
@@ -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"),
]
7 changes: 7 additions & 0 deletions scoring/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.shortcuts import render

from django.views.generic import TemplateView


class HomePageView(TemplateView):
template_name = "scoring/home.html"

0 comments on commit 001c31f

Please sign in to comment.