-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
184 changed files
with
5,794 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[run] | ||
branch = True | ||
source = | ||
config | ||
pikau | ||
static | ||
templates | ||
utils | ||
omit = | ||
# Omit migration files | ||
*/migrations/* | ||
# Omit settings files for local and production environments | ||
# TODO: Add integration tests for local and production environments | ||
*/config/settings/* | ||
# Omit pregenerated files | ||
*/config/wsgi.py | ||
|
||
[report] | ||
fail_under=20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,3 +99,6 @@ ENV/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
db.sqlite3 | ||
staticfiles/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
dist: trusty | ||
sudo: required | ||
language: python | ||
python: | ||
- "3.6" | ||
env: | ||
- DJANGO_SETTINGS_MODULE=config.settings.testing | ||
install: | ||
- pip install -r requirements/testing.txt | ||
- python manage.py collectstatic --no-input --clear | ||
- python manage.py migrate | ||
jobs: | ||
include: | ||
- stage: test | ||
script: coverage run --rcfile=.coveragerc manage.py test tests --settings=config.settings.testing -v=3 | ||
- script: python manage.py loadpikau | ||
- script: flake8 | ||
- script: pydocstyle --count --explain | ||
after_success: | ||
- coverage xml -i | ||
- coverage report -m --skip-covered | ||
- bash <(curl -s https://codecov.io/bash) | ||
notifications: | ||
email: false | ||
slack: | ||
rooms: deptfunstuff:abJKvzApk5SKtcEyAgtswXAv | ||
on_success: change | ||
on_failure: change |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
release: ./release.sh | ||
web: gunicorn config.wsgi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
# Kia Takatū ā-Matihiko content by UCCSER | ||
# Kia Takatū ā-Matihiko - Content Pipeline Assistant | ||
|
||
This repository contains open source content for [Kia Takatū ā-Matihiko](http://www.kiatakatu.ac.nz/), the New Zealand National Digital Readiness programme, produced by the [University of Canterbury Computer Science Education Research Group](http://www.canterbury.ac.nz/engineering/schools/csse/research/cse/). | ||
This website has been developed to assist authors to efficiently create and develop content for [Kia Takatū ā-Matihiko](http://www.kiatakatu.ac.nz/), the National Digital Readiness programme. | ||
|
||
Goals of website: | ||
|
||
- Track content as it is developed, from draft to release. | ||
- Allow authors to see the links between content, and travel through these links. | ||
- Allow authors to see coverage of content against specific goals. | ||
|
||
## License | ||
|
||
The content of this project itself is licensed under the | ||
[Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license](https://creativecommons.org/licenses/by-sa/4.0/) | ||
(`LICENSE-CONTENT` file). | ||
This license applies to the following contents of this project: | ||
|
||
- Text within HTML templates. | ||
- Markdown and YAML files within the `pikau/content`. | ||
|
||
The rest of the project, which is the underlying source code used to manage | ||
and display this content, is licensed under the | ||
[MIT license](https://opensource.org/licenses/MIT) (`LICENSE` file). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""Module for Django system configuration.""" | ||
|
||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Configuration of authentication system.""" | ||
|
||
from django import forms | ||
from django.utils.translation import ugettext_lazy | ||
from allauth.account.adapter import DefaultAccountAdapter | ||
from allauth.account.forms import SignupForm | ||
|
||
VALID_EMAIL_DOMAIN = "@kiatakatu.ac.nz" | ||
INVALID_EMAIL_MESSAGE = ugettext_lazy("Only {} emails addresses are currently allowed".format(VALID_EMAIL_DOMAIN)) | ||
|
||
|
||
class CustomAccountAdapter(DefaultAccountAdapter): | ||
"""Custom adapter used for accounts.""" | ||
|
||
def clean_email(self, email): | ||
"""Validate the email value. | ||
Args: | ||
email (str): String of email address. | ||
Returns: | ||
String of valid email. | ||
""" | ||
if not email.endswith(VALID_EMAIL_DOMAIN): | ||
raise forms.ValidationError(INVALID_EMAIL_MESSAGE) | ||
return email | ||
|
||
|
||
class CustomSignupForm(SignupForm): | ||
"""Custom registration form that includes first and last names.""" | ||
|
||
first_name = forms.CharField(max_length=50, label="First name") | ||
last_name = forms.CharField(max_length=50, label="Last name") | ||
|
||
def signup(self, request, user): | ||
"""Save custom form data to user. | ||
Args: | ||
request (Request): Request object. | ||
user (User): User object. | ||
""" | ||
user.first_name = self.cleaned_data["first_name"] | ||
user.last_name = self.cleaned_data["last_name"] | ||
user.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Context processor for displaying version number.""" | ||
|
||
from config import __version__ | ||
|
||
|
||
def version_number(request): | ||
"""Return a dictionary containing system version number. | ||
Returns: | ||
Dictionary containing version number to add to context. | ||
""" | ||
return { | ||
"VERSION_NUMBER": __version__ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Django settings for kia-takatu-a-matihiko project.""" | ||
|
||
import environ | ||
import os | ||
|
||
BASE_DIR_PATH = environ.Path(__file__) - 3 | ||
BASE_DIR = str(BASE_DIR_PATH) | ||
|
||
# Load operating system environment variables and then prepare to use them | ||
env = environ.Env() | ||
|
||
# APP CONFIGURATION | ||
# ---------------------------------------------------------------------------- | ||
DJANGO_APPS = [ | ||
"django.contrib.admin", | ||
"django.contrib.auth", | ||
"django.contrib.contenttypes", | ||
"django.contrib.sessions", | ||
"django.contrib.messages", | ||
"django.contrib.sites", | ||
"whitenoise.runserver_nostatic", | ||
"django.contrib.staticfiles", | ||
] | ||
|
||
THIRD_PARTY_APPS = [ | ||
"django_bootstrap_breadcrumbs", | ||
"crispy_forms", | ||
"allauth", | ||
"allauth.account", | ||
"allauth.socialaccount", | ||
] | ||
|
||
# Apps specific for this project go here. | ||
LOCAL_APPS = [ | ||
"pikau.apps.PikauConfig", | ||
] | ||
|
||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps | ||
INSTALLED_APPS = THIRD_PARTY_APPS + DJANGO_APPS + LOCAL_APPS | ||
|
||
MIDDLEWARE = [ | ||
"django.middleware.security.SecurityMiddleware", | ||
"whitenoise.middleware.WhiteNoiseMiddleware", | ||
"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", | ||
|
||
] | ||
|
||
# Allow all host headers | ||
ALLOWED_HOSTS = ["*"] | ||
|
||
# DATABASE | ||
# ---------------------------------------------------------------------------- | ||
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"), | ||
} | ||
} | ||
SECRET_KEY = "localsecretkey" | ||
|
||
# DEBUG | ||
# ---------------------------------------------------------------------------- | ||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug | ||
DEBUG = False | ||
|
||
# GENERAL CONFIGURATION | ||
# ---------------------------------------------------------------------------- | ||
TIME_ZONE = "NZ" | ||
LANGUAGE_CODE = "en-NZ" | ||
USE_I18N = True | ||
USE_L10N = False | ||
USE_TZ = True | ||
TIME_FORMAT = "fA" | ||
SITE_ID = 1 | ||
DATE_FORMAT = "jS F, Y" | ||
|
||
DATETIME_INPUT_FORMATS = [ | ||
"%d/%m/%Y %H:%M:%S", | ||
"%d/%m/%Y %H:%M:%S.%f", | ||
"%d/%m/%Y %H:%M", | ||
"%d/%m/%Y", | ||
"%d/%m/%y %H:%M:%S", | ||
"%d/%m/%y %H:%M:%S.%f", | ||
"%d/%m/%y %H:%M", | ||
"%d/%m/%y", | ||
"%d-%m-%Y %H:%M:%S", | ||
"%d-%m-%Y %H:%M:%S.%f", | ||
"%d-%m-%Y %H:%M", | ||
"%d-%m-%Y", | ||
] | ||
|
||
DATE_INPUT_FORMATS = [ | ||
"%d/%m/%Y", | ||
"%d/%m/%y", | ||
"%d-%m-%Y", | ||
"%d-%m-%y", | ||
] | ||
|
||
TIME_INPUT_FORMATS = [ | ||
"%H:%M:%S", | ||
"%H:%M", | ||
] | ||
|
||
# TEMPLATE CONFIGURATION | ||
# ---------------------------------------------------------------------------- | ||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#templates | ||
TEMPLATES = [ | ||
{ | ||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND | ||
"BACKEND": "django.template.backends.django.DjangoTemplates", | ||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs | ||
"DIRS": [ | ||
str(os.path.join(BASE_DIR, "templates")), | ||
], | ||
"OPTIONS": { | ||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug | ||
"debug": DEBUG, | ||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders | ||
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types | ||
"loaders": [ | ||
"django.template.loaders.filesystem.Loader", | ||
"django.template.loaders.app_directories.Loader", | ||
], | ||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors | ||
"context_processors": [ | ||
"django.template.context_processors.debug", | ||
"django.template.context_processors.request", | ||
"django.contrib.auth.context_processors.auth", | ||
"django.template.context_processors.i18n", | ||
"django.template.context_processors.static", | ||
"django.template.context_processors.tz", | ||
"django.contrib.messages.context_processors.messages", | ||
"config.context_processors.version_number.version_number", | ||
], | ||
"libraries": { | ||
"render_html_field": "config.templatetags.render_html_field", | ||
"get_item": "config.templatetags.get_item", | ||
}, | ||
}, | ||
}, | ||
] | ||
|
||
# STATIC FILE CONFIGURATION | ||
# ------------------------------------------------------------------------------ | ||
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") | ||
STATIC_URL = "/static/" | ||
STATICFILES_DIRS = [ | ||
os.path.join(BASE_DIR, "static"), | ||
] | ||
STATICFILES_FINDERS = [ | ||
"django.contrib.staticfiles.finders.FileSystemFinder", | ||
"django.contrib.staticfiles.finders.AppDirectoriesFinder", | ||
] | ||
# Simplified static file serving. | ||
# https://warehouse.python.org/project/whitenoise/ | ||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" | ||
|
||
# URL Configuration | ||
# ------------------------------------------------------------------------------ | ||
ROOT_URLCONF = "config.urls" | ||
|
||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application | ||
WSGI_APPLICATION = "config.wsgi.application" | ||
|
||
# PASSWORD VALIDATION | ||
# https://docs.djangoproject.com/en/dev/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", | ||
}, | ||
] | ||
|
||
# PASSWORD STORAGE SETTINGS | ||
# ------------------------------------------------------------------------------ | ||
# See https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django | ||
PASSWORD_HASHERS = [ | ||
"django.contrib.auth.hashers.Argon2PasswordHasher", | ||
"django.contrib.auth.hashers.PBKDF2PasswordHasher", | ||
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher", | ||
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher", | ||
"django.contrib.auth.hashers.BCryptPasswordHasher", | ||
] | ||
|
||
# AUTH | ||
# ------------------------------------------------------------------------------ | ||
AUTHENTICATION_BACKENDS = ( | ||
"django.contrib.auth.backends.ModelBackend", | ||
"allauth.account.auth_backends.AuthenticationBackend", | ||
) | ||
LOGIN_REDIRECT_URL = "index" | ||
ACCOUNT_AUTHENTICATION_METHOD = "email" | ||
ACCOUNT_EMAIL_REQUIRED = True | ||
ACCOUNT_EMAIL_VERIFICATION = "mandatory" | ||
ACCOUNT_USERNAME_REQUIRED = False | ||
ACCOUNT_FORMS = { | ||
"signup": "config.allauth.CustomSignupForm" | ||
} | ||
ACCOUNT_ADAPTER = "config.allauth.CustomAccountAdapter" | ||
CRISPY_TEMPLATE_PACK = "bootstrap4" | ||
|
||
# OTHER SETTINGS | ||
# ------------------------------------------------------------------------------ | ||
PIKAU_CONTENT_BASE_PATH = os.path.join(BASE_DIR, "pikau/content") | ||
CUSTOM_VERTO_TEMPLATES = os.path.join(BASE_DIR, "utils/custom_converter_templates/") | ||
BREADCRUMBS_TEMPLATE = "django_bootstrap_breadcrumbs/bootstrap4.html" |
Oops, something went wrong.