aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.coveragerc5
-rw-r--r--.editorconfig39
-rw-r--r--.gitattributes1
-rw-r--r--.gitignore286
-rw-r--r--.pre-commit-config.yaml19
-rw-r--r--.pylintrc14
-rw-r--r--.travis.yml17
-rw-r--r--CONTRIBUTORS.txt1
-rw-r--r--LICENSE10
-rw-r--r--README.rst81
-rw-r--r--config/__init__.py0
-rw-r--r--config/settings/__init__.py0
-rw-r--r--config/settings/base.py268
-rw-r--r--config/settings/local.py54
-rw-r--r--config/settings/production.py180
-rw-r--r--config/settings/test.py51
-rw-r--r--config/urls.py45
-rw-r--r--config/wsgi.py39
-rw-r--r--ctrack/__init__.py7
-rw-r--r--ctrack/conftest.py20
-rw-r--r--ctrack/contrib/__init__.py5
-rw-r--r--ctrack/contrib/sites/__init__.py5
-rw-r--r--ctrack/contrib/sites/migrations/0001_initial.py42
-rw-r--r--ctrack/contrib/sites/migrations/0002_alter_domain_unique.py20
-rw-r--r--ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py34
-rw-r--r--ctrack/contrib/sites/migrations/__init__.py5
-rw-r--r--ctrack/static/css/project.css13
-rw-r--r--ctrack/static/fonts/.gitkeep0
-rw-r--r--ctrack/static/images/favicons/favicon.icobin0 -> 8348 bytes
-rw-r--r--ctrack/static/js/project.js1
-rw-r--r--ctrack/static/sass/custom_bootstrap_vars.scss0
-rw-r--r--ctrack/static/sass/project.scss37
-rw-r--r--ctrack/templates/403.html9
-rw-r--r--ctrack/templates/404.html9
-rw-r--r--ctrack/templates/500.html13
-rw-r--r--ctrack/templates/account/account_inactive.html12
-rw-r--r--ctrack/templates/account/base.html10
-rw-r--r--ctrack/templates/account/email.html80
-rw-r--r--ctrack/templates/account/email_confirm.html32
-rw-r--r--ctrack/templates/account/login.html48
-rw-r--r--ctrack/templates/account/logout.html22
-rw-r--r--ctrack/templates/account/password_change.html17
-rw-r--r--ctrack/templates/account/password_reset.html26
-rw-r--r--ctrack/templates/account/password_reset_done.html17
-rw-r--r--ctrack/templates/account/password_reset_from_key.html25
-rw-r--r--ctrack/templates/account/password_reset_from_key_done.html10
-rw-r--r--ctrack/templates/account/password_set.html17
-rw-r--r--ctrack/templates/account/signup.html23
-rw-r--r--ctrack/templates/account/signup_closed.html12
-rw-r--r--ctrack/templates/account/verification_sent.html13
-rw-r--r--ctrack/templates/account/verified_email_required.html24
-rw-r--r--ctrack/templates/base.html114
-rw-r--r--ctrack/templates/pages/about.html1
-rw-r--r--ctrack/templates/pages/home.html1
-rw-r--r--ctrack/templates/users/user_detail.html36
-rw-r--r--ctrack/templates/users/user_form.html17
-rw-r--r--ctrack/users/__init__.py0
-rw-r--r--ctrack/users/adapters.py16
-rw-r--r--ctrack/users/admin.py17
-rw-r--r--ctrack/users/apps.py13
-rw-r--r--ctrack/users/forms.py30
-rw-r--r--ctrack/users/migrations/0001_initial.py132
-rw-r--r--ctrack/users/migrations/__init__.py0
-rw-r--r--ctrack/users/models.py14
-rw-r--r--ctrack/users/tests/__init__.py0
-rw-r--r--ctrack/users/tests/factories.py27
-rw-r--r--ctrack/users/tests/test_forms.py40
-rw-r--r--ctrack/users/tests/test_models.py9
-rw-r--r--ctrack/users/tests/test_urls.py24
-rw-r--r--ctrack/users/tests/test_views.py46
-rw-r--r--ctrack/users/urls.py14
-rw-r--r--ctrack/users/views.py50
-rw-r--r--ctrack/utils/__init__.py0
-rw-r--r--ctrack/utils/context_processors.py5
-rw-r--r--docs/Makefile153
-rw-r--r--docs/__init__.py1
-rw-r--r--docs/conf.py255
-rw-r--r--docs/index.rst20
-rw-r--r--docs/make.bat190
-rw-r--r--locale/README.rst6
-rwxr-xr-xmanage.py30
-rw-r--r--pytest.ini3
-rw-r--r--requirements.txt3
-rw-r--r--requirements/base.txt18
-rw-r--r--requirements/local.txt30
-rw-r--r--requirements/production.txt12
-rw-r--r--setup.cfg23
-rwxr-xr-xutility/install_os_dependencies.sh96
-rwxr-xr-xutility/install_python_dependencies.sh39
-rw-r--r--utility/requirements-bionic.apt23
-rw-r--r--utility/requirements-buster.apt23
-rw-r--r--utility/requirements-jessie.apt23
-rw-r--r--utility/requirements-stretch.apt23
-rw-r--r--utility/requirements-trusty.apt23
-rw-r--r--utility/requirements-xenial.apt23
95 files changed, 3341 insertions, 0 deletions
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..7309959
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,5 @@
+[run]
+include = ctrack/*
+omit = *migrations*, *tests*
+plugins =
+ django_coverage_plugin
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..77ad96d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,39 @@
+# http://editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{py,rst,ini}]
+indent_style = space
+indent_size = 4
+
+[*.py]
+line_length = 120
+known_first_party = ctrack
+multi_line_output = 3
+default_section = THIRDPARTY
+recursive = true
+skip = venv/
+skip_glob = **/migrations/*.py
+include_trailing_comma = true
+force_grid_wrap = 0
+use_parentheses = true
+
+[*.{html,css,scss,json,yml}]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
+
+[Makefile]
+indent_style = tab
+
+[nginx.conf]
+indent_style = space
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1f37b67
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,286 @@
+### Python template
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+staticfiles/
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# pyenv
+.python-version
+
+
+
+# Environments
+.venv
+venv/
+ENV/
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+
+
+### Node template
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# nyc test coverage
+.nyc_output
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# Typescript v1 declaration files
+typings/
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+
+### Linux template
+*~
+
+# temporary files which can be created if a process still has a handle open of a deleted file
+.fuse_hidden*
+
+# KDE directory preferences
+.directory
+
+# Linux trash folder which might appear on any partition or disk
+.Trash-*
+
+# .nfs files are created when an open file is removed but is still being accessed
+.nfs*
+
+
+### VisualStudioCode template
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+
+
+
+
+### Windows template
+# Windows thumbnail cache files
+Thumbs.db
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+
+### macOS template
+# General
+*.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+
+### SublimeText template
+# Cache files for Sublime Text
+*.tmlanguage.cache
+*.tmPreferences.cache
+*.stTheme.cache
+
+# Workspace files are user-specific
+*.sublime-workspace
+
+# Project files should be checked into the repository, unless a significant
+# proportion of contributors will probably not be using Sublime Text
+# *.sublime-project
+
+# SFTP configuration file
+sftp-config.json
+
+# Package control specific files
+Package Control.last-run
+Package Control.ca-list
+Package Control.ca-bundle
+Package Control.system-ca-bundle
+Package Control.cache/
+Package Control.ca-certs/
+Package Control.merged-ca-bundle
+Package Control.user-ca-bundle
+oscrypto-ca-bundle.crt
+bh_unicode_properties.cache
+
+# Sublime-github package stores a github token in this file
+# https://packagecontrol.io/packages/sublime-github
+GitHub.sublime-settings
+
+
+### Vim template
+# Swap
+[._]*.s[a-v][a-z]
+[._]*.sw[a-p]
+[._]s[a-v][a-z]
+[._]sw[a-p]
+
+# Session
+Session.vim
+
+# Temporary
+.netrwhist
+
+# Auto-generated tag files
+tags
+
+
+### VirtualEnv template
+# Virtualenv
+[Bb]in
+[Ii]nclude
+[Ll]ib
+[Ll]ib64
+[Ss]cripts
+pyvenv.cfg
+pip-selfcheck.json
+.env
+
+
+### Project template
+
+ctrack/media/
+
+.pytest_cache/
+
+
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..b9d69a9
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,19 @@
+exclude: 'docs|node_modules|migrations|.git|.tox'
+default_stages: [commit]
+fail_fast: true
+
+repos:
+- repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: master
+ hooks:
+ - id: trailing-whitespace
+ files: (^|/)a/.+\.(py|html|sh|css|js)$
+
+- repo: local
+ hooks:
+ - id: flake8
+ name: flake8
+ entry: flake8
+ language: python
+ types: [python]
+
diff --git a/.pylintrc b/.pylintrc
new file mode 100644
index 0000000..e0faac0
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,14 @@
+[MASTER]
+load-plugins=pylint_django
+
+[FORMAT]
+max-line-length=120
+
+[MESSAGES CONTROL]
+disable=missing-docstring,invalid-name
+
+[DESIGN]
+max-parents=13
+
+[TYPECHECK]
+generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..31695e4
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+dist: xenial
+services:
+ - postgresql
+before_install:
+ - sudo apt-get update -qq
+ - sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb
+ - sudo apt-get install -qq libjpeg8-dev libfreetype6-dev libwebp-dev
+ - sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip
+ - sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev
+ - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm
+language: python
+python:
+ - "3.7"
+install:
+ - pip install -r requirements/local.txt
+script:
+ - "pytest"
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
new file mode 100644
index 0000000..ea22a30
--- /dev/null
+++ b/CONTRIBUTORS.txt
@@ -0,0 +1 @@
+Matt Lemon
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..109ed7d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,10 @@
+
+The MIT License (MIT)
+Copyright (c) 2020, Matt Lemon
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..832ba9d
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,81 @@
+ctrack
+======
+
+CCT tracker
+
+.. image:: https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg
+ :target: https://github.com/pydanny/cookiecutter-django/
+ :alt: Built with Cookiecutter Django
+.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
+ :target: https://github.com/ambv/black
+ :alt: Black code style
+
+
+:License: MIT
+
+
+Settings
+--------
+
+Moved to settings_.
+
+.. _settings: http://cookiecutter-django.readthedocs.io/en/latest/settings.html
+
+Basic Commands
+--------------
+
+Setting Up Your Users
+^^^^^^^^^^^^^^^^^^^^^
+
+* To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
+
+* To create an **superuser account**, use this command::
+
+ $ python manage.py createsuperuser
+
+For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
+
+Type checks
+^^^^^^^^^^^
+
+Running type checks with mypy:
+
+::
+
+ $ mypy ctrack
+
+Test coverage
+^^^^^^^^^^^^^
+
+To run the tests, check your test coverage, and generate an HTML coverage report::
+
+ $ coverage run -m pytest
+ $ coverage html
+ $ open htmlcov/index.html
+
+Running tests with py.test
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+ $ pytest
+
+Live reloading and Sass CSS compilation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Moved to `Live reloading and SASS compilation`_.
+
+.. _`Live reloading and SASS compilation`: http://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html
+
+
+
+
+
+Deployment
+----------
+
+The following details how to deploy this application.
+
+
+
+
diff --git a/config/__init__.py b/config/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/config/__init__.py
diff --git a/config/settings/__init__.py b/config/settings/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/config/settings/__init__.py
diff --git a/config/settings/base.py b/config/settings/base.py
new file mode 100644
index 0000000..5dea850
--- /dev/null
+++ b/config/settings/base.py
@@ -0,0 +1,268 @@
+"""
+Base settings to build other settings files upon.
+"""
+
+import environ
+
+ROOT_DIR = (
+ environ.Path(__file__) - 3
+) # (ctrack/config/settings/base.py - 3 = ctrack/)
+APPS_DIR = ROOT_DIR.path("ctrack")
+
+env = environ.Env()
+
+READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False)
+if READ_DOT_ENV_FILE:
+ # OS environment variables take precedence over variables from .env
+ env.read_env(str(ROOT_DIR.path(".env")))
+
+# GENERAL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#debug
+DEBUG = env.bool("DJANGO_DEBUG", False)
+# Local time zone. Choices are
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# though not all of them may be available with every OS.
+# In Windows, this must be set to your system time zone.
+TIME_ZONE = "UTC"
+# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
+LANGUAGE_CODE = "en-us"
+# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
+SITE_ID = 1
+# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
+USE_I18N = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
+USE_L10N = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
+USE_TZ = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#locale-paths
+LOCALE_PATHS = [ROOT_DIR.path("locale")]
+
+# DATABASES
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#databases
+
+DATABASES = {
+ "default": env.db("DATABASE_URL", default="postgres:///ctrack")
+}
+DATABASES["default"]["ATOMIC_REQUESTS"] = True
+
+# URLS
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
+ROOT_URLCONF = "config.urls"
+# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
+WSGI_APPLICATION = "config.wsgi.application"
+
+# APPS
+# ------------------------------------------------------------------------------
+DJANGO_APPS = [
+ "django.contrib.auth",
+ "django.contrib.contenttypes",
+ "django.contrib.sessions",
+ "django.contrib.sites",
+ "django.contrib.messages",
+ "django.contrib.staticfiles",
+ # "django.contrib.humanize", # Handy template tags
+ "django.contrib.admin",
+]
+THIRD_PARTY_APPS = [
+ "crispy_forms",
+ "allauth",
+ "allauth.account",
+ "allauth.socialaccount",
+ "rest_framework",
+]
+
+LOCAL_APPS = [
+ "ctrack.users.apps.UsersConfig",
+ # Your stuff: custom apps go here
+]
+# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
+INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
+
+# MIGRATIONS
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
+MIGRATION_MODULES = {"sites": "ctrack.contrib.sites.migrations"}
+
+# AUTHENTICATION
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#authentication-backends
+AUTHENTICATION_BACKENDS = [
+ "django.contrib.auth.backends.ModelBackend",
+ "allauth.account.auth_backends.AuthenticationBackend",
+]
+# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
+AUTH_USER_MODEL = "users.User"
+# https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
+LOGIN_REDIRECT_URL = "users:redirect"
+# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
+LOGIN_URL = "account_login"
+
+# PASSWORDS
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
+PASSWORD_HASHERS = [
+ # https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
+ "django.contrib.auth.hashers.Argon2PasswordHasher",
+ "django.contrib.auth.hashers.PBKDF2PasswordHasher",
+ "django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
+ "django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
+]
+# 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"},
+]
+
+# MIDDLEWARE
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
+MIDDLEWARE = [
+ "django.middleware.security.SecurityMiddleware",
+ "django.contrib.sessions.middleware.SessionMiddleware",
+ "django.middleware.locale.LocaleMiddleware",
+ "django.middleware.common.CommonMiddleware",
+ "django.middleware.csrf.CsrfViewMiddleware",
+ "django.contrib.auth.middleware.AuthenticationMiddleware",
+ "django.contrib.messages.middleware.MessageMiddleware",
+ "django.middleware.common.BrokenLinkEmailsMiddleware",
+ "django.middleware.clickjacking.XFrameOptionsMiddleware",
+]
+
+# STATIC
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#static-root
+STATIC_ROOT = str(ROOT_DIR("staticfiles"))
+# https://docs.djangoproject.com/en/dev/ref/settings/#static-url
+STATIC_URL = "/static/"
+# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
+STATICFILES_DIRS = [str(APPS_DIR.path("static"))]
+# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
+STATICFILES_FINDERS = [
+ "django.contrib.staticfiles.finders.FileSystemFinder",
+ "django.contrib.staticfiles.finders.AppDirectoriesFinder",
+]
+
+# MEDIA
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#media-root
+MEDIA_ROOT = str(APPS_DIR("media"))
+# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
+MEDIA_URL = "/media/"
+
+# TEMPLATES
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#templates
+TEMPLATES = [
+ {
+ # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
+ # https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
+ "DIRS": [str(APPS_DIR.path("templates"))],
+ "OPTIONS": {
+ # 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",
+ ],
+ # 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.media",
+ "django.template.context_processors.static",
+ "django.template.context_processors.tz",
+ "django.contrib.messages.context_processors.messages",
+ "ctrack.utils.context_processors.settings_context",
+ ],
+ },
+ }
+]
+# http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
+CRISPY_TEMPLATE_PACK = "bootstrap4"
+
+# FIXTURES
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
+FIXTURE_DIRS = (str(APPS_DIR.path("fixtures")),)
+
+# SECURITY
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
+SESSION_COOKIE_HTTPONLY = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
+CSRF_COOKIE_HTTPONLY = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#secure-browser-xss-filter
+SECURE_BROWSER_XSS_FILTER = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
+X_FRAME_OPTIONS = "DENY"
+
+# EMAIL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
+EMAIL_BACKEND = env(
+ "DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend"
+)
+# https://docs.djangoproject.com/en/2.2/ref/settings/#email-timeout
+EMAIL_TIMEOUT = 5
+
+# ADMIN
+# ------------------------------------------------------------------------------
+# Django Admin URL.
+ADMIN_URL = "admin/"
+# https://docs.djangoproject.com/en/dev/ref/settings/#admins
+ADMINS = [("""Matt Lemon""", "matt@matthewlemon.com")]
+# https://docs.djangoproject.com/en/dev/ref/settings/#managers
+MANAGERS = ADMINS
+
+# LOGGING
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#logging
+# See https://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+LOGGING = {
+ "version": 1,
+ "disable_existing_loggers": False,
+ "formatters": {
+ "verbose": {
+ "format": "%(levelname)s %(asctime)s %(module)s "
+ "%(process)d %(thread)d %(message)s"
+ }
+ },
+ "handlers": {
+ "console": {
+ "level": "DEBUG",
+ "class": "logging.StreamHandler",
+ "formatter": "verbose",
+ }
+ },
+ "root": {"level": "INFO", "handlers": ["console"]},
+}
+
+
+# django-allauth
+# ------------------------------------------------------------------------------
+ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
+# https://django-allauth.readthedocs.io/en/latest/configuration.html
+ACCOUNT_AUTHENTICATION_METHOD = "username"
+# https://django-allauth.readthedocs.io/en/latest/configuration.html
+ACCOUNT_EMAIL_REQUIRED = True
+# https://django-allauth.readthedocs.io/en/latest/configuration.html
+ACCOUNT_EMAIL_VERIFICATION = "mandatory"
+# https://django-allauth.readthedocs.io/en/latest/configuration.html
+ACCOUNT_ADAPTER = "ctrack.users.adapters.AccountAdapter"
+# https://django-allauth.readthedocs.io/en/latest/configuration.html
+SOCIALACCOUNT_ADAPTER = "ctrack.users.adapters.SocialAccountAdapter"
+
+
+# Your stuff...
+# ------------------------------------------------------------------------------
diff --git a/config/settings/local.py b/config/settings/local.py
new file mode 100644
index 0000000..311fb77
--- /dev/null
+++ b/config/settings/local.py
@@ -0,0 +1,54 @@
+from .base import * # noqa
+from .base import env
+
+# GENERAL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#debug
+DEBUG = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
+SECRET_KEY = env(
+ "DJANGO_SECRET_KEY",
+ default="VWMf2IWTRhWmbM8Bu3Opy7GZa9auuQpIYLNltIEUbutegXp610DWCRQeW8AHWRZD",
+)
+# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
+ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]
+
+# CACHES
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#caches
+CACHES = {
+ "default": {
+ "BACKEND": "django.core.cache.backends.locmem.LocMemCache",
+ "LOCATION": "",
+ }
+}
+
+# EMAIL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
+EMAIL_BACKEND = env(
+ "DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend"
+)
+
+# django-debug-toolbar
+# ------------------------------------------------------------------------------
+# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites
+INSTALLED_APPS += ["debug_toolbar"] # noqa F405
+# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware
+MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"] # noqa F405
+# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config
+DEBUG_TOOLBAR_CONFIG = {
+ "DISABLE_PANELS": ["debug_toolbar.panels.redirects.RedirectsPanel"],
+ "SHOW_TEMPLATE_CONTEXT": True,
+}
+# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
+INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]
+
+
+# django-extensions
+# ------------------------------------------------------------------------------
+# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
+INSTALLED_APPS += ["django_extensions"] # noqa F405
+
+# Your stuff...
+# ------------------------------------------------------------------------------
diff --git a/config/settings/production.py b/config/settings/production.py
new file mode 100644
index 0000000..ffce376
--- /dev/null
+++ b/config/settings/production.py
@@ -0,0 +1,180 @@
+from .base import * # noqa
+from .base import env
+
+# GENERAL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
+SECRET_KEY = env("DJANGO_SECRET_KEY")
+# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
+ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["ctrackdft.net"])
+
+# DATABASES
+# ------------------------------------------------------------------------------
+DATABASES["default"] = env.db("DATABASE_URL") # noqa F405
+DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405
+DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # noqa F405
+
+# CACHES
+# ------------------------------------------------------------------------------
+CACHES = {
+ "default": {
+ "BACKEND": "django_redis.cache.RedisCache",
+ "LOCATION": env("REDIS_URL"),
+ "OPTIONS": {
+ "CLIENT_CLASS": "django_redis.client.DefaultClient",
+ # Mimicing memcache behavior.
+ # http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
+ "IGNORE_EXCEPTIONS": True,
+ },
+ }
+}
+
+# SECURITY
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
+SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
+# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
+SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=True)
+# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
+SESSION_COOKIE_SECURE = True
+# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
+CSRF_COOKIE_SECURE = True
+# https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
+# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds
+# TODO: set this to 60 seconds first and then to 518400 once you prove the former works
+SECURE_HSTS_SECONDS = 60
+# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
+SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
+ "DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True
+)
+# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
+SECURE_HSTS_PRELOAD = env.bool("DJANGO_SECURE_HSTS_PRELOAD", default=True)
+# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
+SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
+ "DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
+)
+
+# STORAGES
+# ------------------------------------------------------------------------------
+# https://django-storages.readthedocs.io/en/latest/#installation
+INSTALLED_APPS += ["storages"] # noqa F405
+GS_BUCKET_NAME = env("DJANGO_GCP_STORAGE_BUCKET_NAME")
+GS_DEFAULT_ACL = "publicRead"
+# STATIC
+# ------------------------
+STATICFILES_STORAGE = "config.settings.production.StaticRootGoogleCloudStorage"
+COLLECTFAST_STRATEGY = "collectfast.strategies.gcloud.GoogleCloudStrategy"
+STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/"
+# MEDIA
+# ------------------------------------------------------------------------------
+from storages.backends.gcloud import GoogleCloudStorage # noqa E402
+
+
+class StaticRootGoogleCloudStorage(GoogleCloudStorage):
+ location = "static"
+ default_acl = "publicRead"
+
+
+class MediaRootGoogleCloudStorage(GoogleCloudStorage):
+ location = "media"
+ file_overwrite = False
+
+
+DEFAULT_FILE_STORAGE = "config.settings.production.MediaRootGoogleCloudStorage"
+MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/"
+
+# TEMPLATES
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#templates
+TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] # noqa F405
+ (
+ "django.template.loaders.cached.Loader",
+ [
+ "django.template.loaders.filesystem.Loader",
+ "django.template.loaders.app_directories.Loader",
+ ],
+ )
+]
+
+# EMAIL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
+DEFAULT_FROM_EMAIL = env(
+ "DJANGO_DEFAULT_FROM_EMAIL", default="ctrack <noreply@ctrackdft.net>"
+)
+# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
+SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
+# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
+EMAIL_SUBJECT_PREFIX = env(
+ "DJANGO_EMAIL_SUBJECT_PREFIX", default="[ctrack]"
+)
+
+# ADMIN
+# ------------------------------------------------------------------------------
+# Django Admin URL regex.
+ADMIN_URL = env("DJANGO_ADMIN_URL")
+
+# Anymail (Mailgun)
+# ------------------------------------------------------------------------------
+# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
+INSTALLED_APPS += ["anymail"] # noqa F405
+EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
+# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
+ANYMAIL = {
+ "MAILGUN_API_KEY": env("MAILGUN_API_KEY"),
+ "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"),
+ "MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"),
+}
+
+# Collectfast
+# ------------------------------------------------------------------------------
+# https://github.com/antonagestam/collectfast#installation
+INSTALLED_APPS = ["collectfast"] + INSTALLED_APPS # noqa F405
+
+# LOGGING
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#logging
+# See https://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+# A sample logging configuration. The only tangible logging
+# performed by this configuration is to send an email to
+# the site admins on every HTTP 500 error when DEBUG=False.
+LOGGING = {
+ "version": 1,
+ "disable_existing_loggers": False,
+ "filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
+ "formatters": {
+ "verbose": {
+ "format": "%(levelname)s %(asctime)s %(module)s "
+ "%(process)d %(thread)d %(message)s"
+ }
+ },
+ "handlers": {
+ "mail_admins": {
+ "level": "ERROR",
+ "filters": ["require_debug_false"],
+ "class": "django.utils.log.AdminEmailHandler",
+ },
+ "console": {
+ "level": "DEBUG",
+ "class": "logging.StreamHandler",
+ "formatter": "verbose",
+ },
+ },
+ "root": {"level": "INFO", "handlers": ["console"]},
+ "loggers": {
+ "django.request": {
+ "handlers": ["mail_admins"],
+ "level": "ERROR",
+ "propagate": True,
+ },
+ "django.security.DisallowedHost": {
+ "level": "ERROR",
+ "handlers": ["console", "mail_admins"],
+ "propagate": True,
+ },
+ },
+}
+
+# Your stuff...
+# ------------------------------------------------------------------------------
diff --git a/config/settings/test.py b/config/settings/test.py
new file mode 100644
index 0000000..718cbdb
--- /dev/null
+++ b/config/settings/test.py
@@ -0,0 +1,51 @@
+"""
+With these settings, tests run faster.
+"""
+
+from .base import * # noqa
+from .base import env
+
+# GENERAL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
+SECRET_KEY = env(
+ "DJANGO_SECRET_KEY",
+ default="YjL0TsaerybdulEyjn4hxDZ3207sgDVpr7NOoSuzAJHMAL5GNbHdKwFrsyptQ0Je",
+)
+# https://docs.djangoproject.com/en/dev/ref/settings/#test-runner
+TEST_RUNNER = "django.test.runner.DiscoverRunner"
+
+# CACHES
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#caches
+CACHES = {
+ "default": {
+ "BACKEND": "django.core.cache.backends.locmem.LocMemCache",
+ "LOCATION": "",
+ }
+}
+
+# PASSWORDS
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
+PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
+
+# TEMPLATES
+# ------------------------------------------------------------------------------
+TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] # noqa F405
+ (
+ "django.template.loaders.cached.Loader",
+ [
+ "django.template.loaders.filesystem.Loader",
+ "django.template.loaders.app_directories.Loader",
+ ],
+ )
+]
+
+# EMAIL
+# ------------------------------------------------------------------------------
+# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
+EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
+
+# Your stuff...
+# ------------------------------------------------------------------------------
diff --git a/config/urls.py b/config/urls.py
new file mode 100644
index 0000000..2e9f883
--- /dev/null
+++ b/config/urls.py
@@ -0,0 +1,45 @@
+from django.conf import settings
+from django.urls import include, path
+from django.conf.urls.static import static
+from django.contrib import admin
+from django.views.generic import TemplateView
+from django.views import defaults as default_views
+
+urlpatterns = [
+ path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
+ path(
+ "about/", TemplateView.as_view(template_name="pages/about.html"), name="about"
+ ),
+ # Django Admin, use {% url 'admin:index' %}
+ path(settings.ADMIN_URL, admin.site.urls),
+ # User management
+ path("users/", include("ctrack.users.urls", namespace="users")),
+ path("accounts/", include("allauth.urls")),
+ # Your stuff: custom urls includes go here
+] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+
+if settings.DEBUG:
+ # This allows the error pages to be debugged during development, just visit
+ # these url in browser to see how these error pages look like.
+ urlpatterns += [
+ path(
+ "400/",
+ default_views.bad_request,
+ kwargs={"exception": Exception("Bad Request!")},
+ ),
+ path(
+ "403/",
+ default_views.permission_denied,
+ kwargs={"exception": Exception("Permission Denied")},
+ ),
+ path(
+ "404/",
+ default_views.page_not_found,
+ kwargs={"exception": Exception("Page not Found")},
+ ),
+ path("500/", default_views.server_error),
+ ]
+ if "debug_toolbar" in settings.INSTALLED_APPS:
+ import debug_toolbar
+
+ urlpatterns = [path("__debug__/", include(debug_toolbar.urls))] + urlpatterns
diff --git a/config/wsgi.py b/config/wsgi.py
new file mode 100644
index 0000000..e0c17b0
--- /dev/null
+++ b/config/wsgi.py
@@ -0,0 +1,39 @@
+"""
+WSGI config for ctrack project.
+
+This module contains the WSGI application used by Django's development server
+and any production WSGI deployments. It should expose a module-level variable
+named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
+this application via the ``WSGI_APPLICATION`` setting.
+
+Usually you will have the standard Django WSGI application here, but it also
+might make sense to replace the whole Django WSGI application with a custom one
+that later delegates to the Django one. For example, you could introduce WSGI
+middleware here, or combine a Django application with an application of another
+framework.
+
+"""
+import os
+import sys
+
+from django.core.wsgi import get_wsgi_application
+
+# This allows easy placement of apps within the interior
+# ctrack directory.
+app_path = os.path.abspath(
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)
+)
+sys.path.append(os.path.join(app_path, "ctrack"))
+# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
+# if running multiple sites in the same mod_wsgi process. To fix this, use
+# mod_wsgi daemon mode with each site in its own daemon process, or use
+# os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production"
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
+
+# This application object is used by any WSGI server configured to use this
+# file. This includes Django's development server, if the WSGI_APPLICATION
+# setting points here.
+application = get_wsgi_application()
+# Apply WSGI middleware here.
+# from helloworld.wsgi import HelloWorldApplication
+# application = HelloWorldApplication(application)
diff --git a/ctrack/__init__.py b/ctrack/__init__.py
new file mode 100644
index 0000000..e1d8615
--- /dev/null
+++ b/ctrack/__init__.py
@@ -0,0 +1,7 @@
+__version__ = "0.1.0"
+__version_info__ = tuple(
+ [
+ int(num) if num.isdigit() else num
+ for num in __version__.replace("-", ".", 1).split(".")
+ ]
+)
diff --git a/ctrack/conftest.py b/ctrack/conftest.py
new file mode 100644
index 0000000..b994f24
--- /dev/null
+++ b/ctrack/conftest.py
@@ -0,0 +1,20 @@
+import pytest
+from django.test import RequestFactory
+
+from ctrack.users.models import User
+from ctrack.users.tests.factories import UserFactory
+
+
+@pytest.fixture(autouse=True)
+def media_storage(settings, tmpdir):
+ settings.MEDIA_ROOT = tmpdir.strpath
+
+
+@pytest.fixture
+def user() -> User:
+ return UserFactory()
+
+
+@pytest.fixture
+def request_factory() -> RequestFactory:
+ return RequestFactory()
diff --git a/ctrack/contrib/__init__.py b/ctrack/contrib/__init__.py
new file mode 100644
index 0000000..1c7ecc8
--- /dev/null
+++ b/ctrack/contrib/__init__.py
@@ -0,0 +1,5 @@
+"""
+To understand why this file is here, please read:
+
+http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
+"""
diff --git a/ctrack/contrib/sites/__init__.py b/ctrack/contrib/sites/__init__.py
new file mode 100644
index 0000000..1c7ecc8
--- /dev/null
+++ b/ctrack/contrib/sites/__init__.py
@@ -0,0 +1,5 @@
+"""
+To understand why this file is here, please read:
+
+http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
+"""
diff --git a/ctrack/contrib/sites/migrations/0001_initial.py b/ctrack/contrib/sites/migrations/0001_initial.py
new file mode 100644
index 0000000..304cd6d
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/0001_initial.py
@@ -0,0 +1,42 @@
+import django.contrib.sites.models
+from django.contrib.sites.models import _simple_domain_name_validator
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = []
+
+ operations = [
+ migrations.CreateModel(
+ name="Site",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ verbose_name="ID",
+ serialize=False,
+ auto_created=True,
+ primary_key=True,
+ ),
+ ),
+ (
+ "domain",
+ models.CharField(
+ max_length=100,
+ verbose_name="domain name",
+ validators=[_simple_domain_name_validator],
+ ),
+ ),
+ ("name", models.CharField(max_length=50, verbose_name="display name")),
+ ],
+ options={
+ "ordering": ("domain",),
+ "db_table": "django_site",
+ "verbose_name": "site",
+ "verbose_name_plural": "sites",
+ },
+ bases=(models.Model,),
+ managers=[("objects", django.contrib.sites.models.SiteManager())],
+ )
+ ]
diff --git a/ctrack/contrib/sites/migrations/0002_alter_domain_unique.py b/ctrack/contrib/sites/migrations/0002_alter_domain_unique.py
new file mode 100644
index 0000000..2c8d6da
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/0002_alter_domain_unique.py
@@ -0,0 +1,20 @@
+import django.contrib.sites.models
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [("sites", "0001_initial")]
+
+ operations = [
+ migrations.AlterField(
+ model_name="site",
+ name="domain",
+ field=models.CharField(
+ max_length=100,
+ unique=True,
+ validators=[django.contrib.sites.models._simple_domain_name_validator],
+ verbose_name="domain name",
+ ),
+ )
+ ]
diff --git a/ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py b/ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py
new file mode 100644
index 0000000..e81e91e
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py
@@ -0,0 +1,34 @@
+"""
+To understand why this file is here, please read:
+
+http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
+"""
+from django.conf import settings
+from django.db import migrations
+
+
+def update_site_forward(apps, schema_editor):
+ """Set site domain and name."""
+ Site = apps.get_model("sites", "Site")
+ Site.objects.update_or_create(
+ id=settings.SITE_ID,
+ defaults={
+ "domain": "ctrackdft.net",
+ "name": "ctrack",
+ },
+ )
+
+
+def update_site_backward(apps, schema_editor):
+ """Revert site domain and name to default."""
+ Site = apps.get_model("sites", "Site")
+ Site.objects.update_or_create(
+ id=settings.SITE_ID, defaults={"domain": "example.com", "name": "example.com"}
+ )
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [("sites", "0002_alter_domain_unique")]
+
+ operations = [migrations.RunPython(update_site_forward, update_site_backward)]
diff --git a/ctrack/contrib/sites/migrations/__init__.py b/ctrack/contrib/sites/migrations/__init__.py
new file mode 100644
index 0000000..1c7ecc8
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/__init__.py
@@ -0,0 +1,5 @@
+"""
+To understand why this file is here, please read:
+
+http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
+"""
diff --git a/ctrack/static/css/project.css b/ctrack/static/css/project.css
new file mode 100644
index 0000000..f1d543d
--- /dev/null
+++ b/ctrack/static/css/project.css
@@ -0,0 +1,13 @@
+/* These styles are generated from project.scss. */
+
+.alert-debug {
+ color: black;
+ background-color: white;
+ border-color: #d6e9c6;
+}
+
+.alert-error {
+ color: #b94a48;
+ background-color: #f2dede;
+ border-color: #eed3d7;
+}
diff --git a/ctrack/static/fonts/.gitkeep b/ctrack/static/fonts/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/static/fonts/.gitkeep
diff --git a/ctrack/static/images/favicons/favicon.ico b/ctrack/static/images/favicons/favicon.ico
new file mode 100644
index 0000000..e1c1dd1
--- /dev/null
+++ b/ctrack/static/images/favicons/favicon.ico
Binary files differ
diff --git a/ctrack/static/js/project.js b/ctrack/static/js/project.js
new file mode 100644
index 0000000..d26d23b
--- /dev/null
+++ b/ctrack/static/js/project.js
@@ -0,0 +1 @@
+/* Project specific Javascript goes here. */
diff --git a/ctrack/static/sass/custom_bootstrap_vars.scss b/ctrack/static/sass/custom_bootstrap_vars.scss
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/static/sass/custom_bootstrap_vars.scss
diff --git a/ctrack/static/sass/project.scss b/ctrack/static/sass/project.scss
new file mode 100644
index 0000000..3c8f261
--- /dev/null
+++ b/ctrack/static/sass/project.scss
@@ -0,0 +1,37 @@
+
+
+
+
+// project specific CSS goes here
+
+////////////////////////////////
+ //Variables//
+////////////////////////////////
+
+// Alert colors
+
+$white: #fff;
+$mint-green: #d6e9c6;
+$black: #000;
+$pink: #f2dede;
+$dark-pink: #eed3d7;
+$red: #b94a48;
+
+////////////////////////////////
+ //Alerts//
+////////////////////////////////
+
+// bootstrap alert CSS, translated to the django-standard levels of
+// debug, info, success, warning, error
+
+.alert-debug {
+ background-color: $white;
+ border-color: $mint-green;
+ color: $black;
+}
+
+.alert-error {
+ background-color: $pink;
+ border-color: $dark-pink;
+ color: $red;
+}
diff --git a/ctrack/templates/403.html b/ctrack/templates/403.html
new file mode 100644
index 0000000..77db8ae
--- /dev/null
+++ b/ctrack/templates/403.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block title %}Forbidden (403){% endblock %}
+
+{% block content %}
+<h1>Forbidden (403)</h1>
+
+<p>CSRF verification failed. Request aborted.</p>
+{% endblock content %}
diff --git a/ctrack/templates/404.html b/ctrack/templates/404.html
new file mode 100644
index 0000000..98327cd
--- /dev/null
+++ b/ctrack/templates/404.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block title %}Page not found{% endblock %}
+
+{% block content %}
+<h1>Page not found</h1>
+
+<p>This is not the page you were looking for.</p>
+{% endblock content %}
diff --git a/ctrack/templates/500.html b/ctrack/templates/500.html
new file mode 100644
index 0000000..21df606
--- /dev/null
+++ b/ctrack/templates/500.html
@@ -0,0 +1,13 @@
+{% extends "base.html" %}
+
+{% block title %}Server Error{% endblock %}
+
+{% block content %}
+<h1>Ooops!!! 500</h1>
+
+<h3>Looks like something went wrong!</h3>
+
+<p>We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing.</p>
+{% endblock content %}
+
+
diff --git a/ctrack/templates/account/account_inactive.html b/ctrack/templates/account/account_inactive.html
new file mode 100644
index 0000000..17c2157
--- /dev/null
+++ b/ctrack/templates/account/account_inactive.html
@@ -0,0 +1,12 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% trans "Account Inactive" %}{% endblock %}
+
+{% block inner %}
+<h1>{% trans "Account Inactive" %}</h1>
+
+<p>{% trans "This account is inactive." %}</p>
+{% endblock %}
+
diff --git a/ctrack/templates/account/base.html b/ctrack/templates/account/base.html
new file mode 100644
index 0000000..8e1f260
--- /dev/null
+++ b/ctrack/templates/account/base.html
@@ -0,0 +1,10 @@
+{% extends "base.html" %}
+{% block title %}{% block head_title %}{% endblock head_title %}{% endblock title %}
+
+{% block content %}
+<div class="row">
+ <div class="col-md-6 offset-md-3">
+ {% block inner %}{% endblock %}
+ </div>
+</div>
+{% endblock %}
diff --git a/ctrack/templates/account/email.html b/ctrack/templates/account/email.html
new file mode 100644
index 0000000..0dc8d14
--- /dev/null
+++ b/ctrack/templates/account/email.html
@@ -0,0 +1,80 @@
+
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load crispy_forms_tags %}
+
+{% block head_title %}{% trans "Account" %}{% endblock %}
+
+{% block inner %}
+<h1>{% trans "E-mail Addresses" %}</h1>
+
+{% if user.emailaddress_set.all %}
+<p>{% trans 'The following e-mail addresses are associated with your account:' %}</p>
+
+<form action="{% url 'account_email' %}" class="email_list" method="post">
+{% csrf_token %}
+<fieldset class="blockLabels">
+
+ {% for emailaddress in user.emailaddress_set.all %}
+<div class="radio">
+ <label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">
+
+ <input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/>
+
+ {{ emailaddress.email }}
+ {% if emailaddress.verified %}
+ <span class="verified">{% trans "Verified" %}</span>
+ {% else %}
+ <span class="unverified">{% trans "Unverified" %}</span>
+ {% endif %}
+ {% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
+ </label>
+</div>
+ {% endfor %}
+
+<div class="form-group">
+ <button class="secondaryAction btn btn-primary" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button>
+ <button class="secondaryAction btn btn-primary" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button>
+ <button class="primaryAction btn btn-primary" type="submit" name="action_remove" >{% trans 'Remove' %}</button>
+</div>
+
+</fieldset>
+</form>
+
+{% else %}
+<p><strong>{% trans 'Warning:'%}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}</p>
+
+{% endif %}
+
+
+ <h2>{% trans "Add E-mail Address" %}</h2>
+
+ <form method="post" action="{% url 'account_email' %}" class="add_email">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <button class="btn btn-primary" name="action_add" type="submit">{% trans "Add E-mail" %}</button>
+ </form>
+
+{% endblock %}
+
+
+{% block javascript %}
+{{ block.super }}
+<script type="text/javascript">
+(function() {
+ var message = "{% trans 'Do you really want to remove the selected e-mail address?' %}";
+ var actions = document.getElementsByName('action_remove');
+ if (actions.length) {
+ actions[0].addEventListener("click", function(e) {
+ if (! confirm(message)) {
+ e.preventDefault();
+ }
+ });
+ }
+})();
+
+$('.form-group').removeClass('row');
+</script>
+{% endblock %}
+
diff --git a/ctrack/templates/account/email_confirm.html b/ctrack/templates/account/email_confirm.html
new file mode 100644
index 0000000..46c7812
--- /dev/null
+++ b/ctrack/templates/account/email_confirm.html
@@ -0,0 +1,32 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load account %}
+
+{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %}
+
+
+{% block inner %}
+<h1>{% trans "Confirm E-mail Address" %}</h1>
+
+{% if confirmation %}
+
+{% user_display confirmation.email_address.user as user_display %}
+
+<p>{% blocktrans with confirmation.email_address.email as email %}Please confirm that <a href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user {{ user_display }}.{% endblocktrans %}</p>
+
+<form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
+{% csrf_token %}
+ <button class="btn btn-primary" type="submit">{% trans 'Confirm' %}</button>
+</form>
+
+{% else %}
+
+{% url 'account_email' as email_url %}
+
+<p>{% blocktrans %}This e-mail confirmation link expired or is invalid. Please <a href="{{ email_url }}">issue a new e-mail confirmation request</a>.{% endblocktrans %}</p>
+
+{% endif %}
+
+{% endblock %}
+
diff --git a/ctrack/templates/account/login.html b/ctrack/templates/account/login.html
new file mode 100644
index 0000000..2cadea6
--- /dev/null
+++ b/ctrack/templates/account/login.html
@@ -0,0 +1,48 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load account socialaccount %}
+{% load crispy_forms_tags %}
+
+{% block head_title %}{% trans "Sign In" %}{% endblock %}
+
+{% block inner %}
+
+<h1>{% trans "Sign In" %}</h1>
+
+{% get_providers as socialaccount_providers %}
+
+{% if socialaccount_providers %}
+<p>{% blocktrans with site.name as site_name %}Please sign in with one
+of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
+for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
+
+<div class="socialaccount_ballot">
+
+ <ul class="socialaccount_providers">
+ {% include "socialaccount/snippets/provider_list.html" with process="login" %}
+ </ul>
+
+ <div class="login-or">{% trans 'or' %}</div>
+
+</div>
+
+{% include "socialaccount/snippets/login_extra.html" %}
+
+{% else %}
+<p>{% blocktrans %}If you have not created an account yet, then please
+<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
+{% endif %}
+
+<form class="login" method="POST" action="{% url 'account_login' %}">
+ {% csrf_token %}
+ {{ form|crispy }}
+ {% if redirect_field_value %}
+ <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
+ {% endif %}
+ <a class="button secondaryAction" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
+ <button class="primaryAction btn btn-primary" type="submit">{% trans "Sign In" %}</button>
+</form>
+
+{% endblock %}
+
diff --git a/ctrack/templates/account/logout.html b/ctrack/templates/account/logout.html
new file mode 100644
index 0000000..8e2e675
--- /dev/null
+++ b/ctrack/templates/account/logout.html
@@ -0,0 +1,22 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% trans "Sign Out" %}{% endblock %}
+
+{% block inner %}
+<h1>{% trans "Sign Out" %}</h1>
+
+<p>{% trans 'Are you sure you want to sign out?' %}</p>
+
+<form method="post" action="{% url 'account_logout' %}">
+ {% csrf_token %}
+ {% if redirect_field_value %}
+ <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
+ {% endif %}
+ <button class="btn btn-danger" type="submit">{% trans 'Sign Out' %}</button>
+</form>
+
+
+{% endblock %}
+
diff --git a/ctrack/templates/account/password_change.html b/ctrack/templates/account/password_change.html
new file mode 100644
index 0000000..b72ca06
--- /dev/null
+++ b/ctrack/templates/account/password_change.html
@@ -0,0 +1,17 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load crispy_forms_tags %}
+
+{% block head_title %}{% trans "Change Password" %}{% endblock %}
+
+{% block inner %}
+ <h1>{% trans "Change Password" %}</h1>
+
+ <form method="POST" action="{% url 'account_change_password' %}" class="password_change">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <button class="btn btn-primary" type="submit" name="action">{% trans "Change Password" %}</button>
+ </form>
+{% endblock %}
+
diff --git a/ctrack/templates/account/password_reset.html b/ctrack/templates/account/password_reset.html
new file mode 100644
index 0000000..845bbda
--- /dev/null
+++ b/ctrack/templates/account/password_reset.html
@@ -0,0 +1,26 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load account %}
+{% load crispy_forms_tags %}
+
+{% block head_title %}{% trans "Password Reset" %}{% endblock %}
+
+{% block inner %}
+
+ <h1>{% trans "Password Reset" %}</h1>
+ {% if user.is_authenticated %}
+ {% include "account/snippets/already_logged_in.html" %}
+ {% endif %}
+
+ <p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}</p>
+
+ <form method="POST" action="{% url 'account_reset_password' %}" class="password_reset">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <input class="btn btn-primary" type="submit" value="{% trans 'Reset My Password' %}" />
+ </form>
+
+ <p>{% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %}</p>
+{% endblock %}
+
diff --git a/ctrack/templates/account/password_reset_done.html b/ctrack/templates/account/password_reset_done.html
new file mode 100644
index 0000000..c59534a
--- /dev/null
+++ b/ctrack/templates/account/password_reset_done.html
@@ -0,0 +1,17 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load account %}
+
+{% block head_title %}{% trans "Password Reset" %}{% endblock %}
+
+{% block inner %}
+ <h1>{% trans "Password Reset" %}</h1>
+
+ {% if user.is_authenticated %}
+ {% include "account/snippets/already_logged_in.html" %}
+ {% endif %}
+
+ <p>{% blocktrans %}We have sent you an e-mail. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}</p>
+{% endblock %}
+
diff --git a/ctrack/templates/account/password_reset_from_key.html b/ctrack/templates/account/password_reset_from_key.html
new file mode 100644
index 0000000..4abdb56
--- /dev/null
+++ b/ctrack/templates/account/password_reset_from_key.html
@@ -0,0 +1,25 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load crispy_forms_tags %}
+{% block head_title %}{% trans "Change Password" %}{% endblock %}
+
+{% block inner %}
+ <h1>{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}</h1>
+
+ {% if token_fail %}
+ {% url 'account_reset_password' as passwd_reset_url %}
+ <p>{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a <a href="{{ passwd_reset_url }}">new password reset</a>.{% endblocktrans %}</p>
+ {% else %}
+ {% if form %}
+ <form method="POST" action=".">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <input class="btn btn-primary" type="submit" name="action" value="{% trans 'change password' %}"/>
+ </form>
+ {% else %}
+ <p>{% trans 'Your password is now changed.' %}</p>
+ {% endif %}
+ {% endif %}
+{% endblock %}
+
diff --git a/ctrack/templates/account/password_reset_from_key_done.html b/ctrack/templates/account/password_reset_from_key_done.html
new file mode 100644
index 0000000..89be086
--- /dev/null
+++ b/ctrack/templates/account/password_reset_from_key_done.html
@@ -0,0 +1,10 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% block head_title %}{% trans "Change Password" %}{% endblock %}
+
+{% block inner %}
+ <h1>{% trans "Change Password" %}</h1>
+ <p>{% trans 'Your password is now changed.' %}</p>
+{% endblock %}
+
diff --git a/ctrack/templates/account/password_set.html b/ctrack/templates/account/password_set.html
new file mode 100644
index 0000000..2232223
--- /dev/null
+++ b/ctrack/templates/account/password_set.html
@@ -0,0 +1,17 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load crispy_forms_tags %}
+
+{% block head_title %}{% trans "Set Password" %}{% endblock %}
+
+{% block inner %}
+ <h1>{% trans "Set Password" %}</h1>
+
+ <form method="POST" action="{% url 'account_set_password' %}" class="password_set">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <input class="btn btn-primary" type="submit" name="action" value="{% trans 'Set Password' %}"/>
+ </form>
+{% endblock %}
+
diff --git a/ctrack/templates/account/signup.html b/ctrack/templates/account/signup.html
new file mode 100644
index 0000000..6a2954e
--- /dev/null
+++ b/ctrack/templates/account/signup.html
@@ -0,0 +1,23 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+{% load crispy_forms_tags %}
+
+{% block head_title %}{% trans "Signup" %}{% endblock %}
+
+{% block inner %}
+<h1>{% trans "Sign Up" %}</h1>
+
+<p>{% blocktrans %}Already have an account? Then please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>
+
+<form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
+ {% csrf_token %}
+ {{ form|crispy }}
+ {% if redirect_field_value %}
+ <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
+ {% endif %}
+ <button class="btn btn-primary" type="submit">{% trans "Sign Up" %} &raquo;</button>
+</form>
+
+{% endblock %}
+
diff --git a/ctrack/templates/account/signup_closed.html b/ctrack/templates/account/signup_closed.html
new file mode 100644
index 0000000..2322f17
--- /dev/null
+++ b/ctrack/templates/account/signup_closed.html
@@ -0,0 +1,12 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% trans "Sign Up Closed" %}{% endblock %}
+
+{% block inner %}
+<h1>{% trans "Sign Up Closed" %}</h1>
+
+<p>{% trans "We are sorry, but the sign up is currently closed." %}</p>
+{% endblock %}
+
diff --git a/ctrack/templates/account/verification_sent.html b/ctrack/templates/account/verification_sent.html
new file mode 100644
index 0000000..ad093fd
--- /dev/null
+++ b/ctrack/templates/account/verification_sent.html
@@ -0,0 +1,13 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %}
+
+{% block inner %}
+ <h1>{% trans "Verify Your E-mail Address" %}</h1>
+
+ <p>{% blocktrans %}We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}</p>
+
+{% endblock %}
+
diff --git a/ctrack/templates/account/verified_email_required.html b/ctrack/templates/account/verified_email_required.html
new file mode 100644
index 0000000..09d4fde
--- /dev/null
+++ b/ctrack/templates/account/verified_email_required.html
@@ -0,0 +1,24 @@
+{% extends "account/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %}
+
+{% block inner %}
+<h1>{% trans "Verify Your E-mail Address" %}</h1>
+
+{% url 'account_email' as email_url %}
+
+<p>{% blocktrans %}This part of the site requires us to verify that
+you are who you claim to be. For this purpose, we require that you
+verify ownership of your e-mail address. {% endblocktrans %}</p>
+
+<p>{% blocktrans %}We have sent an e-mail to you for
+verification. Please click on the link inside this e-mail. Please
+contact us if you do not receive it within a few minutes.{% endblocktrans %}</p>
+
+<p>{% blocktrans %}<strong>Note:</strong> you can still <a href="{{ email_url }}">change your e-mail address</a>.{% endblocktrans %}</p>
+
+
+{% endblock %}
+
diff --git a/ctrack/templates/base.html b/ctrack/templates/base.html
new file mode 100644
index 0000000..fbe9d86
--- /dev/null
+++ b/ctrack/templates/base.html
@@ -0,0 +1,114 @@
+{% load static i18n %}<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
+ <title>{% block title %}ctrack{% endblock title %}</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
+ <!--[if lt IE 9]>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
+ <![endif]-->
+
+ <link rel="icon" href="{% static 'images/favicons/favicon.ico' %}">
+
+ {% block css %}
+
+ <!-- Latest compiled and minified Bootstrap CSS -->
+ <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
+
+
+ <!-- Your stuff: Third-party CSS libraries go here -->
+
+ <!-- This file stores project-specific CSS -->
+
+ <link href="{% static 'css/project.css' %}" rel="stylesheet">
+
+
+ {% endblock %}
+
+ </head>
+
+ <body>
+
+ <div class="mb-1">
+ <nav class="navbar navbar-expand-md navbar-light bg-light">
+ <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
+ <span class="navbar-toggler-icon"></span>
+ </button>
+ <a class="navbar-brand" href="{% url 'home' %}">ctrack</a>
+
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
+ <ul class="navbar-nav mr-auto">
+ <li class="nav-item active">
+ <a class="nav-link" href="{% url 'home' %}">Home <span class="sr-only">(current)</span></a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'about' %}">About</a>
+ </li>
+ {% if request.user.is_authenticated %}
+ <li class="nav-item">
+ {# URL provided by django-allauth/account/urls.py #}
+ <a class="nav-link" href="{% url 'users:detail' request.user.username %}">{% trans "My Profile" %}</a>
+ </li>
+ <li class="nav-item">
+ {# URL provided by django-allauth/account/urls.py #}
+ <a class="nav-link" href="{% url 'account_logout' %}">{% trans "Sign Out" %}</a>
+ </li>
+ {% else %}
+ <li class="nav-item">
+ {# URL provided by django-allauth/account/urls.py #}
+ <a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}">{% trans "Sign Up" %}</a>
+ </li>
+ <li class="nav-item">
+ {# URL provided by django-allauth/account/urls.py #}
+ <a id="log-in-link" class="nav-link" href="{% url 'account_login' %}">{% trans "Sign In" %}</a>
+ </li>
+ {% endif %}
+ </ul>
+ </div>
+ </nav>
+
+ </div>
+
+ <div class="container">
+
+ {% if messages %}
+ {% for message in messages %}
+ <div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %}">{{ message }}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>
+ {% endfor %}
+ {% endif %}
+
+ {% block content %}
+ <p>Use this document as a way to quick start any new project.</p>
+ {% endblock content %}
+
+ </div> <!-- /container -->
+
+ {% block modal %}{% endblock modal %}
+
+ <!-- Le javascript
+ ================================================== -->
+ <!-- Placed at the end of the document so the pages load faster -->
+ {% block javascript %}
+
+ <!-- Bootstrap JS and its dependencies-->
+ <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
+
+ <!-- Your stuff: Third-party javascript libraries go here -->
+
+
+ <!-- place project specific Javascript in this file -->
+
+ <script src="{% static 'js/project.js' %}"></script>
+
+
+ {% endblock javascript %}
+ </body>
+</html>
+
diff --git a/ctrack/templates/pages/about.html b/ctrack/templates/pages/about.html
new file mode 100644
index 0000000..63913c1
--- /dev/null
+++ b/ctrack/templates/pages/about.html
@@ -0,0 +1 @@
+{% extends "base.html" %} \ No newline at end of file
diff --git a/ctrack/templates/pages/home.html b/ctrack/templates/pages/home.html
new file mode 100644
index 0000000..63913c1
--- /dev/null
+++ b/ctrack/templates/pages/home.html
@@ -0,0 +1 @@
+{% extends "base.html" %} \ No newline at end of file
diff --git a/ctrack/templates/users/user_detail.html b/ctrack/templates/users/user_detail.html
new file mode 100644
index 0000000..e86eda1
--- /dev/null
+++ b/ctrack/templates/users/user_detail.html
@@ -0,0 +1,36 @@
+{% extends "base.html" %}
+{% load static %}
+
+{% block title %}User: {{ object.username }}{% endblock %}
+
+{% block content %}
+<div class="container">
+
+ <div class="row">
+ <div class="col-sm-12">
+
+ <h2>{{ object.username }}</h2>
+ {% if object.name %}
+ <p>{{ object.name }}</p>
+ {% endif %}
+ </div>
+ </div>
+
+{% if object == request.user %}
+<!-- Action buttons -->
+<div class="row">
+
+ <div class="col-sm-12">
+ <a class="btn btn-primary" href="{% url 'users:update' %}" role="button">My Info</a>
+ <a class="btn btn-primary" href="{% url 'account_email' %}" role="button">E-Mail</a>
+ <!-- Your Stuff: Custom user template urls -->
+ </div>
+
+</div>
+<!-- End Action buttons -->
+{% endif %}
+
+
+</div>
+{% endblock content %}
+
diff --git a/ctrack/templates/users/user_form.html b/ctrack/templates/users/user_form.html
new file mode 100644
index 0000000..467357a
--- /dev/null
+++ b/ctrack/templates/users/user_form.html
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+{% load crispy_forms_tags %}
+
+{% block title %}{{ user.username }}{% endblock %}
+
+{% block content %}
+ <h1>{{ user.username }}</h1>
+ <form class="form-horizontal" method="post" action="{% url 'users:update' %}">
+ {% csrf_token %}
+ {{ form|crispy }}
+ <div class="control-group">
+ <div class="controls">
+ <button type="submit" class="btn btn-primary">Update</button>
+ </div>
+ </div>
+ </form>
+{% endblock %}
diff --git a/ctrack/users/__init__.py b/ctrack/users/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/users/__init__.py
diff --git a/ctrack/users/adapters.py b/ctrack/users/adapters.py
new file mode 100644
index 0000000..0d206fa
--- /dev/null
+++ b/ctrack/users/adapters.py
@@ -0,0 +1,16 @@
+from typing import Any
+
+from allauth.account.adapter import DefaultAccountAdapter
+from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
+from django.conf import settings
+from django.http import HttpRequest
+
+
+class AccountAdapter(DefaultAccountAdapter):
+ def is_open_for_signup(self, request: HttpRequest):
+ return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
+
+
+class SocialAccountAdapter(DefaultSocialAccountAdapter):
+ def is_open_for_signup(self, request: HttpRequest, sociallogin: Any):
+ return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
diff --git a/ctrack/users/admin.py b/ctrack/users/admin.py
new file mode 100644
index 0000000..120cc64
--- /dev/null
+++ b/ctrack/users/admin.py
@@ -0,0 +1,17 @@
+from django.contrib import admin
+from django.contrib.auth import admin as auth_admin
+from django.contrib.auth import get_user_model
+
+from ctrack.users.forms import UserChangeForm, UserCreationForm
+
+User = get_user_model()
+
+
+@admin.register(User)
+class UserAdmin(auth_admin.UserAdmin):
+
+ form = UserChangeForm
+ add_form = UserCreationForm
+ fieldsets = (("User", {"fields": ("name",)}),) + auth_admin.UserAdmin.fieldsets
+ list_display = ["username", "name", "is_superuser"]
+ search_fields = ["name"]
diff --git a/ctrack/users/apps.py b/ctrack/users/apps.py
new file mode 100644
index 0000000..9f81f1d
--- /dev/null
+++ b/ctrack/users/apps.py
@@ -0,0 +1,13 @@
+from django.apps import AppConfig
+from django.utils.translation import gettext_lazy as _
+
+
+class UsersConfig(AppConfig):
+ name = "ctrack.users"
+ verbose_name = _("Users")
+
+ def ready(self):
+ try:
+ import ctrack.users.signals # noqa F401
+ except ImportError:
+ pass
diff --git a/ctrack/users/forms.py b/ctrack/users/forms.py
new file mode 100644
index 0000000..250cc90
--- /dev/null
+++ b/ctrack/users/forms.py
@@ -0,0 +1,30 @@
+from django.contrib.auth import get_user_model, forms
+from django.core.exceptions import ValidationError
+from django.utils.translation import ugettext_lazy as _
+
+User = get_user_model()
+
+
+class UserChangeForm(forms.UserChangeForm):
+ class Meta(forms.UserChangeForm.Meta):
+ model = User
+
+
+class UserCreationForm(forms.UserCreationForm):
+
+ error_message = forms.UserCreationForm.error_messages.update(
+ {"duplicate_username": _("This username has already been taken.")}
+ )
+
+ class Meta(forms.UserCreationForm.Meta):
+ model = User
+
+ def clean_username(self):
+ username = self.cleaned_data["username"]
+
+ try:
+ User.objects.get(username=username)
+ except User.DoesNotExist:
+ return username
+
+ raise ValidationError(self.error_messages["duplicate_username"])
diff --git a/ctrack/users/migrations/0001_initial.py b/ctrack/users/migrations/0001_initial.py
new file mode 100644
index 0000000..c9d8905
--- /dev/null
+++ b/ctrack/users/migrations/0001_initial.py
@@ -0,0 +1,132 @@
+import django.contrib.auth.models
+import django.contrib.auth.validators
+from django.db import migrations, models
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [("auth", "0008_alter_user_username_max_length")]
+
+ operations = [
+ migrations.CreateModel(
+ name="User",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("password", models.CharField(max_length=128, verbose_name="password")),
+ (
+ "last_login",
+ models.DateTimeField(
+ blank=True, null=True, verbose_name="last login"
+ ),
+ ),
+ (
+ "is_superuser",
+ models.BooleanField(
+ default=False,
+ help_text="Designates that this user has all permissions without explicitly assigning them.",
+ verbose_name="superuser status",
+ ),
+ ),
+ (
+ "username",
+ models.CharField(
+ error_messages={
+ "unique": "A user with that username already exists."
+ },
+ help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
+ max_length=150,
+ unique=True,
+ validators=[
+ django.contrib.auth.validators.UnicodeUsernameValidator()
+ ],
+ verbose_name="username",
+ ),
+ ),
+ (
+ "first_name",
+ models.CharField(
+ blank=True, max_length=30, verbose_name="first name"
+ ),
+ ),
+ (
+ "last_name",
+ models.CharField(
+ blank=True, max_length=150, verbose_name="last name"
+ ),
+ ),
+ (
+ "email",
+ models.EmailField(
+ blank=True, max_length=254, verbose_name="email address"
+ ),
+ ),
+ (
+ "is_staff",
+ models.BooleanField(
+ default=False,
+ help_text="Designates whether the user can log into this admin site.",
+ verbose_name="staff status",
+ ),
+ ),
+ (
+ "is_active",
+ models.BooleanField(
+ default=True,
+ help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
+ verbose_name="active",
+ ),
+ ),
+ (
+ "date_joined",
+ models.DateTimeField(
+ default=django.utils.timezone.now, verbose_name="date joined"
+ ),
+ ),
+ (
+ "name",
+ models.CharField(
+ blank=True, max_length=255, verbose_name="Name of User"
+ ),
+ ),
+ (
+ "groups",
+ models.ManyToManyField(
+ blank=True,
+ help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
+ related_name="user_set",
+ related_query_name="user",
+ to="auth.Group",
+ verbose_name="groups",
+ ),
+ ),
+ (
+ "user_permissions",
+ models.ManyToManyField(
+ blank=True,
+ help_text="Specific permissions for this user.",
+ related_name="user_set",
+ related_query_name="user",
+ to="auth.Permission",
+ verbose_name="user permissions",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name_plural": "users",
+ "verbose_name": "user",
+ "abstract": False,
+ },
+ managers=[("objects", django.contrib.auth.models.UserManager())],
+ )
+ ]
diff --git a/ctrack/users/migrations/__init__.py b/ctrack/users/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/users/migrations/__init__.py
diff --git a/ctrack/users/models.py b/ctrack/users/models.py
new file mode 100644
index 0000000..8f07b15
--- /dev/null
+++ b/ctrack/users/models.py
@@ -0,0 +1,14 @@
+from django.contrib.auth.models import AbstractUser
+from django.db.models import CharField
+from django.urls import reverse
+from django.utils.translation import ugettext_lazy as _
+
+
+class User(AbstractUser):
+
+ # First Name and Last Name do not cover name patterns
+ # around the globe.
+ name = CharField(_("Name of User"), blank=True, max_length=255)
+
+ def get_absolute_url(self):
+ return reverse("users:detail", kwargs={"username": self.username})
diff --git a/ctrack/users/tests/__init__.py b/ctrack/users/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/users/tests/__init__.py
diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py
new file mode 100644
index 0000000..b537136
--- /dev/null
+++ b/ctrack/users/tests/factories.py
@@ -0,0 +1,27 @@
+from typing import Any, Sequence
+
+from django.contrib.auth import get_user_model
+from factory import DjangoModelFactory, Faker, post_generation
+
+
+class UserFactory(DjangoModelFactory):
+
+ username = Faker("user_name")
+ email = Faker("email")
+ name = Faker("name")
+
+ @post_generation
+ def password(self, create: bool, extracted: Sequence[Any], **kwargs):
+ password = Faker(
+ "password",
+ length=42,
+ special_chars=True,
+ digits=True,
+ upper_case=True,
+ lower_case=True,
+ ).generate(extra_kwargs={})
+ self.set_password(password)
+
+ class Meta:
+ model = get_user_model()
+ django_get_or_create = ["username"]
diff --git a/ctrack/users/tests/test_forms.py b/ctrack/users/tests/test_forms.py
new file mode 100644
index 0000000..11ef251
--- /dev/null
+++ b/ctrack/users/tests/test_forms.py
@@ -0,0 +1,40 @@
+import pytest
+
+from ctrack.users.forms import UserCreationForm
+from ctrack.users.tests.factories import UserFactory
+
+pytestmark = pytest.mark.django_db
+
+
+class TestUserCreationForm:
+ def test_clean_username(self):
+ # A user with proto_user params does not exist yet.
+ proto_user = UserFactory.build()
+
+ form = UserCreationForm(
+ {
+ "username": proto_user.username,
+ "password1": proto_user._password,
+ "password2": proto_user._password,
+ }
+ )
+
+ assert form.is_valid()
+ assert form.clean_username() == proto_user.username
+
+ # Creating a user.
+ form.save()
+
+ # The user with proto_user params already exists,
+ # hence cannot be created.
+ form = UserCreationForm(
+ {
+ "username": proto_user.username,
+ "password1": proto_user._password,
+ "password2": proto_user._password,
+ }
+ )
+
+ assert not form.is_valid()
+ assert len(form.errors) == 1
+ assert "username" in form.errors
diff --git a/ctrack/users/tests/test_models.py b/ctrack/users/tests/test_models.py
new file mode 100644
index 0000000..1b33961
--- /dev/null
+++ b/ctrack/users/tests/test_models.py
@@ -0,0 +1,9 @@
+import pytest
+
+from ctrack.users.models import User
+
+pytestmark = pytest.mark.django_db
+
+
+def test_user_get_absolute_url(user: User):
+ assert user.get_absolute_url() == f"/users/{user.username}/"
diff --git a/ctrack/users/tests/test_urls.py b/ctrack/users/tests/test_urls.py
new file mode 100644
index 0000000..383a649
--- /dev/null
+++ b/ctrack/users/tests/test_urls.py
@@ -0,0 +1,24 @@
+import pytest
+from django.urls import reverse, resolve
+
+from ctrack.users.models import User
+
+pytestmark = pytest.mark.django_db
+
+
+def test_detail(user: User):
+ assert (
+ reverse("users:detail", kwargs={"username": user.username})
+ == f"/users/{user.username}/"
+ )
+ assert resolve(f"/users/{user.username}/").view_name == "users:detail"
+
+
+def test_update():
+ assert reverse("users:update") == "/users/~update/"
+ assert resolve("/users/~update/").view_name == "users:update"
+
+
+def test_redirect():
+ assert reverse("users:redirect") == "/users/~redirect/"
+ assert resolve("/users/~redirect/").view_name == "users:redirect"
diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py
new file mode 100644
index 0000000..3e7fbf7
--- /dev/null
+++ b/ctrack/users/tests/test_views.py
@@ -0,0 +1,46 @@
+import pytest
+from django.test import RequestFactory
+
+from ctrack.users.models import User
+from ctrack.users.views import UserRedirectView, UserUpdateView
+
+pytestmark = pytest.mark.django_db
+
+
+class TestUserUpdateView:
+ """
+ TODO:
+ extracting view initialization code as class-scoped fixture
+ would be great if only pytest-django supported non-function-scoped
+ fixture db access -- this is a work-in-progress for now:
+ https://github.com/pytest-dev/pytest-django/pull/258
+ """
+
+ def test_get_success_url(self, user: User, request_factory: RequestFactory):
+ view = UserUpdateView()
+ request = request_factory.get("/fake-url/")
+ request.user = user
+
+ view.request = request
+
+ assert view.get_success_url() == f"/users/{user.username}/"
+
+ def test_get_object(self, user: User, request_factory: RequestFactory):
+ view = UserUpdateView()
+ request = request_factory.get("/fake-url/")
+ request.user = user
+
+ view.request = request
+
+ assert view.get_object() == user
+
+
+class TestUserRedirectView:
+ def test_get_redirect_url(self, user: User, request_factory: RequestFactory):
+ view = UserRedirectView()
+ request = request_factory.get("/fake-url")
+ request.user = user
+
+ view.request = request
+
+ assert view.get_redirect_url() == f"/users/{user.username}/"
diff --git a/ctrack/users/urls.py b/ctrack/users/urls.py
new file mode 100644
index 0000000..cc1d04c
--- /dev/null
+++ b/ctrack/users/urls.py
@@ -0,0 +1,14 @@
+from django.urls import path
+
+from ctrack.users.views import (
+ user_redirect_view,
+ user_update_view,
+ user_detail_view,
+)
+
+app_name = "users"
+urlpatterns = [
+ path("~redirect/", view=user_redirect_view, name="redirect"),
+ path("~update/", view=user_update_view, name="update"),
+ path("<str:username>/", view=user_detail_view, name="detail"),
+]
diff --git a/ctrack/users/views.py b/ctrack/users/views.py
new file mode 100644
index 0000000..5c0d5b5
--- /dev/null
+++ b/ctrack/users/views.py
@@ -0,0 +1,50 @@
+from django.contrib.auth import get_user_model
+from django.contrib.auth.mixins import LoginRequiredMixin
+from django.urls import reverse
+from django.views.generic import DetailView, RedirectView, UpdateView
+from django.contrib import messages
+from django.utils.translation import ugettext_lazy as _
+
+User = get_user_model()
+
+
+class UserDetailView(LoginRequiredMixin, DetailView):
+
+ model = User
+ slug_field = "username"
+ slug_url_kwarg = "username"
+
+
+user_detail_view = UserDetailView.as_view()
+
+
+class UserUpdateView(LoginRequiredMixin, UpdateView):
+
+ model = User
+ fields = ["name"]
+
+ def get_success_url(self):
+ return reverse("users:detail", kwargs={"username": self.request.user.username})
+
+ def get_object(self):
+ return User.objects.get(username=self.request.user.username)
+
+ def form_valid(self, form):
+ messages.add_message(
+ self.request, messages.INFO, _("Infos successfully updated")
+ )
+ return super().form_valid(form)
+
+
+user_update_view = UserUpdateView.as_view()
+
+
+class UserRedirectView(LoginRequiredMixin, RedirectView):
+
+ permanent = False
+
+ def get_redirect_url(self):
+ return reverse("users:detail", kwargs={"username": self.request.user.username})
+
+
+user_redirect_view = UserRedirectView.as_view()
diff --git a/ctrack/utils/__init__.py b/ctrack/utils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ctrack/utils/__init__.py
diff --git a/ctrack/utils/context_processors.py b/ctrack/utils/context_processors.py
new file mode 100644
index 0000000..de40507
--- /dev/null
+++ b/ctrack/utils/context_processors.py
@@ -0,0 +1,5 @@
+from django.conf import settings
+
+
+def settings_context(_request):
+ return {"settings": settings}
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..20c9e9c
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ctrack.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ctrack.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/ctrack"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ctrack"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/__init__.py b/docs/__init__.py
new file mode 100644
index 0000000..8772c82
--- /dev/null
+++ b/docs/__init__.py
@@ -0,0 +1 @@
+# Included so that Django's startproject comment runs against the docs directory
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..445751f
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,255 @@
+# ctrack documentation build configuration file, created by
+# sphinx-quickstart.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import os
+import sys
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+# sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+# needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ["_templates"]
+
+# The suffix of source filenames.
+source_suffix = ".rst"
+
+# The encoding of source files.
+# source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = "index"
+
+# General information about the project.
+project = "ctrack"
+copyright = """2020, Matt Lemon"""
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = "0.1"
+# The full version, including alpha/beta/rc tags.
+release = "0.1"
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+# language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+# today = ''
+# Else, today_fmt is used as the format for a strftime call.
+# today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ["_build"]
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+# default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+# add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+# add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+# show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = "sphinx"
+
+# A list of ignored prefixes for module index sorting.
+# modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = "default"
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+# html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+# html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+# html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+# html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+# html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+# html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ["_static"]
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+# html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+# html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+# html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+# html_additional_pages = {}
+
+# If false, no module index is generated.
+# html_domain_indices = True
+
+# If false, no index is generated.
+# html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+# html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+# html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+# html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+# html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+# html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+# html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = "ctrackdoc"
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+ # The paper size ('letterpaper' or 'a4paper').
+ # 'papersize': 'letterpaper',
+ # The font size ('10pt', '11pt' or '12pt').
+ # 'pointsize': '10pt',
+ # Additional stuff for the LaTeX preamble.
+ # 'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ (
+ "index",
+ "ctrack.tex",
+ "ctrack Documentation",
+ """Matt Lemon""",
+ "manual",
+ )
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+# latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+# latex_use_parts = False
+
+# If true, show page references after internal links.
+# latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+# latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+# latex_appendices = []
+
+# If false, no module index is generated.
+# latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ (
+ "index",
+ "ctrack",
+ "ctrack Documentation",
+ ["""Matt Lemon"""],
+ 1,
+ )
+]
+
+# If true, show URL addresses after external links.
+# man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ (
+ "index",
+ "ctrack",
+ "ctrack Documentation",
+ """Matt Lemon""",
+ "ctrack",
+ """CCT tracker""",
+ "Miscellaneous",
+ )
+]
+
+# Documents to append as an appendix to all manuals.
+# texinfo_appendices = []
+
+# If false, no module index is generated.
+# texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+# texinfo_show_urls = 'footnote'
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..ff0648c
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,20 @@
+.. ctrack documentation master file, created by
+ sphinx-quickstart.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+ctrack Project Documentation
+====================================================================
+
+Table of Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+
+Indices & Tables
+================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..1be8ed2
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,190 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^<target^>` where ^<target^> is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. singlehtml to make a single large HTML file
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. devhelp to make HTML files and a Devhelp project
+ echo. epub to make an epub
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. text to make text files
+ echo. man to make manual pages
+ echo. texinfo to make Texinfo files
+ echo. gettext to make PO message catalogs
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+ del /q /s %BUILDDIR%\*
+ goto end
+)
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+ goto end
+)
+
+if "%1" == "singlehtml" (
+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\ctrack.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\ctrack.ghc
+ goto end
+)
+
+if "%1" == "devhelp" (
+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished.
+ goto end
+)
+
+if "%1" == "epub" (
+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The epub file is in %BUILDDIR%/epub.
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "text" (
+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The text files are in %BUILDDIR%/text.
+ goto end
+)
+
+if "%1" == "man" (
+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The manual pages are in %BUILDDIR%/man.
+ goto end
+)
+
+if "%1" == "texinfo" (
+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+ goto end
+)
+
+if "%1" == "gettext" (
+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.The overview file is in %BUILDDIR%/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+ goto end
+)
+
+:end
diff --git a/locale/README.rst b/locale/README.rst
new file mode 100644
index 0000000..c2f1dcd
--- /dev/null
+++ b/locale/README.rst
@@ -0,0 +1,6 @@
+Translations
+============
+
+Translations will be placed in this folder when running::
+
+ python manage.py makemessages
diff --git a/manage.py b/manage.py
new file mode 100755
index 0000000..81b5e0c
--- /dev/null
+++ b/manage.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
+
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError:
+ # The above import may fail for some other reason. Ensure that the
+ # issue is really that Django is missing to avoid masking other
+ # exceptions on Python 2.
+ try:
+ import django # noqa
+ except ImportError:
+ 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?"
+ )
+
+ raise
+
+ # This allows easy placement of apps within the interior
+ # ctrack directory.
+ current_path = os.path.dirname(os.path.abspath(__file__))
+ sys.path.append(os.path.join(current_path, "ctrack"))
+
+ execute_from_command_line(sys.argv)
diff --git a/pytest.ini b/pytest.ini
new file mode 100644
index 0000000..c2b3a23
--- /dev/null
+++ b/pytest.ini
@@ -0,0 +1,3 @@
+[pytest]
+addopts = --ds=config.settings.test --reuse-db
+python_files = tests.py test_*.py
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..c1b500c
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,3 @@
+# This file is expected by Heroku.
+
+-r requirements/production.txt
diff --git a/requirements/base.txt b/requirements/base.txt
new file mode 100644
index 0000000..7436214
--- /dev/null
+++ b/requirements/base.txt
@@ -0,0 +1,18 @@
+pytz==2019.3 # https://github.com/stub42/pytz
+python-slugify==4.0.0 # https://github.com/un33k/python-slugify
+Pillow==7.0.0 # https://github.com/python-pillow/Pillow
+argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi
+redis==3.3.11 # https://github.com/antirez/redis
+
+# Django
+# ------------------------------------------------------------------------------
+django==2.2.9 # pyup: < 3.0 # https://www.djangoproject.com/
+django-environ==0.4.5 # https://github.com/joke2k/django-environ
+django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils
+django-allauth==0.41.0 # https://github.com/pennersr/django-allauth
+django-crispy-forms==1.8.1 # https://github.com/django-crispy-forms/django-crispy-forms
+django-redis==4.11.0 # https://github.com/niwinz/django-redis
+
+# Django REST Framework
+djangorestframework==3.11.0 # https://github.com/encode/django-rest-framework
+coreapi==2.3.3 # https://github.com/core-api/python-client
diff --git a/requirements/local.txt b/requirements/local.txt
new file mode 100644
index 0000000..d196452
--- /dev/null
+++ b/requirements/local.txt
@@ -0,0 +1,30 @@
+-r ./base.txt
+
+Werkzeug==0.16.0 # https://github.com/pallets/werkzeug
+ipdb==0.12.3 # https://github.com/gotcha/ipdb
+Sphinx==2.3.1 # https://github.com/sphinx-doc/sphinx
+psycopg2-binary==2.8.4 # https://github.com/psycopg/psycopg2
+
+# Testing
+# ------------------------------------------------------------------------------
+mypy==0.761 # https://github.com/python/mypy
+django-stubs==1.4.0 # https://github.com/typeddjango/django-stubs
+pytest==5.3.3 # https://github.com/pytest-dev/pytest
+pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar
+
+# Code quality
+# ------------------------------------------------------------------------------
+flake8==3.7.9 # https://github.com/PyCQA/flake8
+coverage==5.0.3 # https://github.com/nedbat/coveragepy
+black==19.10b0 # https://github.com/ambv/black
+pylint-django==2.0.13 # https://github.com/PyCQA/pylint-django
+pre-commit==1.21.0 # https://github.com/pre-commit/pre-commit
+
+# Django
+# ------------------------------------------------------------------------------
+factory-boy==2.12.0 # https://github.com/FactoryBoy/factory_boy
+
+django-debug-toolbar==2.1 # https://github.com/jazzband/django-debug-toolbar
+django-extensions==2.2.6 # https://github.com/django-extensions/django-extensions
+django-coverage-plugin==1.7.0 # https://github.com/nedbat/django_coverage_plugin
+pytest-django==3.8.0 # https://github.com/pytest-dev/pytest-django
diff --git a/requirements/production.txt b/requirements/production.txt
new file mode 100644
index 0000000..810a210
--- /dev/null
+++ b/requirements/production.txt
@@ -0,0 +1,12 @@
+# PRECAUTION: avoid production dependencies that aren't in development
+
+-r ./base.txt
+
+gunicorn==20.0.4 # https://github.com/benoitc/gunicorn
+psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2
+Collectfast==1.3.1 # https://github.com/antonagestam/collectfast
+
+# Django
+# ------------------------------------------------------------------------------
+django-storages[google]==1.8 # https://github.com/jschneier/django-storages
+django-anymail[mailgun]==7.0.0 # https://github.com/anymail/django-anymail
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..5f7d9b6
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,23 @@
+[flake8]
+max-line-length = 120
+exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules
+
+[pycodestyle]
+max-line-length = 120
+exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules
+
+[mypy]
+python_version = 3.7
+check_untyped_defs = True
+ignore_missing_imports = True
+warn_unused_ignores = True
+warn_redundant_casts = True
+warn_unused_configs = True
+plugins = mypy_django_plugin.main
+
+[mypy.plugins.django-stubs]
+django_settings_module = config.settings.test
+
+[mypy-*.migrations.*]
+# Django migrations should not produce any errors:
+ignore_errors = True
diff --git a/utility/install_os_dependencies.sh b/utility/install_os_dependencies.sh
new file mode 100755
index 0000000..ec9372f
--- /dev/null
+++ b/utility/install_os_dependencies.sh
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+WORK_DIR="$(dirname "$0")"
+DISTRO_NAME=$(lsb_release -sc)
+OS_REQUIREMENTS_FILENAME="requirements-$DISTRO_NAME.apt"
+
+cd $WORK_DIR
+
+# Check if a requirements file exist for the current distribution.
+if [ ! -r "$OS_REQUIREMENTS_FILENAME" ]; then
+ cat <<-EOF >&2
+ There is no requirements file for your distribution.
+ You can see one of the files listed below to help search the equivalent package in your system:
+ $(find ./ -name "requirements-*.apt" -printf " - %f\n")
+ EOF
+ exit 1;
+fi
+
+# Handle call with wrong command
+function wrong_command()
+{
+ echo "${0##*/} - unknown command: '${1}'" >&2
+ usage_message
+}
+
+# Print help / script usage
+function usage_message()
+{
+ cat <<-EOF
+ Usage: $WORK_DIR/${0##*/} <command>
+ Available commands are:
+ list Print a list of all packages defined on ${OS_REQUIREMENTS_FILENAME} file
+ help Print this help
+
+ Commands that require superuser permission:
+ install Install packages defined on ${OS_REQUIREMENTS_FILENAME} file. Note: This
+ does not upgrade the packages already installed for new versions, even if
+ new version is available in the repository.
+ upgrade Same that install, but upgrade the already installed packages, if new
+ version is available.
+ EOF
+}
+
+# Read the requirements.apt file, and remove comments and blank lines
+function list_packages(){
+ grep -v "#" "${OS_REQUIREMENTS_FILENAME}" | grep -v "^$";
+}
+
+function install_packages()
+{
+ list_packages | xargs apt-get --no-upgrade install -y;
+}
+
+function upgrade_packages()
+{
+ list_packages | xargs apt-get install -y;
+}
+
+function install_or_upgrade()
+{
+ P=${1}
+ PARAN=${P:-"install"}
+
+ if [[ $EUID -ne 0 ]]; then
+ cat <<-EOF >&2
+ You must run this script with root privilege
+ Please do:
+ sudo $WORK_DIR/${0##*/} $PARAN
+ EOF
+ exit 1
+ else
+
+ apt-get update
+
+ # Install the basic compilation dependencies and other required libraries of this project
+ if [ "$PARAN" == "install" ]; then
+ install_packages;
+ else
+ upgrade_packages;
+ fi
+
+ # cleaning downloaded packages from apt-get cache
+ apt-get clean
+
+ exit 0
+ fi
+}
+
+# Handle command argument
+case "$1" in
+ install) install_or_upgrade;;
+ upgrade) install_or_upgrade "upgrade";;
+ list) list_packages;;
+ help|"") usage_message;;
+ *) wrong_command "$1";;
+esac
diff --git a/utility/install_python_dependencies.sh b/utility/install_python_dependencies.sh
new file mode 100755
index 0000000..bdc181a
--- /dev/null
+++ b/utility/install_python_dependencies.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+WORK_DIR="$(dirname "$0")"
+PROJECT_DIR="$(dirname "$WORK_DIR")"
+
+pip --version >/dev/null 2>&1 || {
+ echo >&2 -e "\npip is required but it's not installed."
+ echo >&2 -e "You can install it by running the following command:\n"
+ echo >&2 "wget https://bootstrap.pypa.io/get-pip.py --output-document=get-pip.py; chmod +x get-pip.py; sudo -H python3 get-pip.py"
+ echo >&2 -e "\n"
+ echo >&2 -e "\nFor more information, see pip documentation: https://pip.pypa.io/en/latest/"
+ exit 1;
+}
+
+virtualenv --version >/dev/null 2>&1 || {
+ echo >&2 -e "\nvirtualenv is required but it's not installed."
+ echo >&2 -e "You can install it by running the following command:\n"
+ echo >&2 "sudo -H pip3 install virtualenv"
+ echo >&2 -e "\n"
+ echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/"
+ exit 1;
+}
+
+if [ -z "$VIRTUAL_ENV" ]; then
+ echo >&2 -e "\nYou need activate a virtualenv first"
+ echo >&2 -e 'If you do not have a virtualenv created, run the following command to create and automatically activate a new virtualenv named "venv" on current folder:\n'
+ echo >&2 -e "virtualenv venv --python=\`which python3\`"
+ echo >&2 -e "\nTo leave/disable the currently active virtualenv, run the following command:\n"
+ echo >&2 "deactivate"
+ echo >&2 -e "\nTo activate the virtualenv again, run the following command:\n"
+ echo >&2 "source venv/bin/activate"
+ echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/"
+ echo >&2 -e "\n"
+ exit 1;
+else
+
+ pip install -r $PROJECT_DIR/requirements/local.txt
+
+fi
diff --git a/utility/requirements-bionic.apt b/utility/requirements-bionic.apt
new file mode 100644
index 0000000..1ca82b2
--- /dev/null
+++ b/utility/requirements-bionic.apt
@@ -0,0 +1,23 @@
+##basic build dependencies of various Django apps for Ubuntu Bionic 18.04
+#build-essential metapackage install: make, gcc, g++,
+build-essential
+#required to translate
+gettext
+python3-dev
+
+##shared dependencies of:
+##Pillow, pylibmc
+zlib1g-dev
+
+##Postgresql and psycopg2 dependencies
+libpq-dev
+
+##Pillow dependencies
+libtiff5-dev
+libjpeg8-dev
+libfreetype6-dev
+liblcms2-dev
+libwebp-dev
+
+##django-extensions
+libgraphviz-dev
diff --git a/utility/requirements-buster.apt b/utility/requirements-buster.apt
new file mode 100644
index 0000000..75957f4
--- /dev/null
+++ b/utility/requirements-buster.apt
@@ -0,0 +1,23 @@
+##basic build dependencies of various Django apps for Debian Jessie 10.x
+#build-essential metapackage install: make, gcc, g++,
+build-essential
+#required to translate
+gettext
+python3-dev
+
+##shared dependencies of:
+##Pillow, pylibmc
+zlib1g-dev
+
+##Postgresql and psycopg2 dependencies
+libpq-dev
+
+##Pillow dependencies
+libtiff5-dev
+libjpeg62-turbo-dev
+libfreetype6-dev
+liblcms2-dev
+libwebp-dev
+
+##django-extensions
+libgraphviz-dev
diff --git a/utility/requirements-jessie.apt b/utility/requirements-jessie.apt
new file mode 100644
index 0000000..5c49365
--- /dev/null
+++ b/utility/requirements-jessie.apt
@@ -0,0 +1,23 @@
+##basic build dependencies of various Django apps for Debian Jessie 8.x
+#build-essential metapackage install: make, gcc, g++,
+build-essential
+#required to translate
+gettext
+python3-dev
+
+##shared dependencies of:
+##Pillow, pylibmc
+zlib1g-dev
+
+##Postgresql and psycopg2 dependencies
+libpq-dev
+
+##Pillow dependencies
+libtiff5-dev
+libjpeg62-turbo-dev
+libfreetype6-dev
+liblcms2-dev
+libwebp-dev
+
+##django-extensions
+graphviz-dev
diff --git a/utility/requirements-stretch.apt b/utility/requirements-stretch.apt
new file mode 100644
index 0000000..a2b3a7e
--- /dev/null
+++ b/utility/requirements-stretch.apt
@@ -0,0 +1,23 @@
+##basic build dependencies of various Django apps for Debian Jessie 9.x
+#build-essential metapackage install: make, gcc, g++,
+build-essential
+#required to translate
+gettext
+python3-dev
+
+##shared dependencies of:
+##Pillow, pylibmc
+zlib1g-dev
+
+##Postgresql and psycopg2 dependencies
+libpq-dev
+
+##Pillow dependencies
+libtiff5-dev
+libjpeg62-turbo-dev
+libfreetype6-dev
+liblcms2-dev
+libwebp-dev
+
+##django-extensions
+graphviz-dev
diff --git a/utility/requirements-trusty.apt b/utility/requirements-trusty.apt
new file mode 100644
index 0000000..455f1a8
--- /dev/null
+++ b/utility/requirements-trusty.apt
@@ -0,0 +1,23 @@
+##basic build dependencies of various Django apps for Ubuntu Trusty 14.04
+#build-essential metapackage install: make, gcc, g++,
+build-essential
+#required to translate
+gettext
+python3-dev
+
+##shared dependencies of:
+##Pillow, pylibmc
+zlib1g-dev
+
+##Postgresql and psycopg2 dependencies
+libpq-dev
+
+##Pillow dependencies
+libtiff4-dev
+libjpeg8-dev
+libfreetype6-dev
+liblcms1-dev
+libwebp-dev
+
+##django-extensions
+graphviz-dev
diff --git a/utility/requirements-xenial.apt b/utility/requirements-xenial.apt
new file mode 100644
index 0000000..ba84ef1
--- /dev/null
+++ b/utility/requirements-xenial.apt
@@ -0,0 +1,23 @@
+##basic build dependencies of various Django apps for Ubuntu Xenial 16.04
+#build-essential metapackage install: make, gcc, g++,
+build-essential
+#required to translate
+gettext
+python3-dev
+
+##shared dependencies of:
+##Pillow, pylibmc
+zlib1g-dev
+
+##Postgresql and psycopg2 dependencies
+libpq-dev
+
+##Pillow dependencies
+libtiff5-dev
+libjpeg8-dev
+libfreetype6-dev
+liblcms2-dev
+libwebp-dev
+
+##django-extensions
+graphviz-dev