diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index 3c5e8c33..00000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory" : "vendor" -} diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..56ef4df2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +/virtualenv +/venv +/results +/etc +**.pyc +__pycache__ +.env +.git +db.sqlite3 +Makefile +Dockerfile +.coverage diff --git a/.editorconfig b/.editorconfig index e503987d..22fd0c20 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,5 @@ indent_style = space [*.{js,py}] indent_size = 4 -# Matches the exact files either package.json or .travis.yml [{*.json,*.yml}] indent_size = 2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..84190465 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +FROM python:3.7 + +EXPOSE 8888 + +ENV DJANGO_SETTINGS_MODULE="config.settings.docker" + +ARG DJANGO_SECRET_KEY="notneededforbuilds" +ARG DATABASE_URL="postgres://not@neededforbuilds" +ARG MODEEMIUSERDB_URL="postgres://not@neededforbuilds" +ARG RECAPTCHA_PUBLIC_KEY="notneededforbuilds" +ARG RECAPTCHA_PRIVATE_KEY="notneededforbuilds" + +COPY scripts/entrypoint /usr/local/bin/entrypoint +RUN chmod a+x /usr/local/bin/entrypoint + +WORKDIR /app + +ADD requirements.txt /app/requirements.txt +RUN python -m pip install --no-cache-dir -r requirements.txt + +ADD . /app/ + +RUN python manage.py collectstatic --noinput + +RUN groupadd -g 1001 modeemintternet +RUN useradd -u 1001 -g 1001 -d /app modeemintternet +USER modeemintternet + +ENTRYPOINT ["/usr/local/bin/entrypoint"] +CMD [ \ + "gunicorn", \ + "--name", \ + "modeemintternet", \ + "--access-logfile", \ + "-", \ + "--access-logform", \ + "%({X-Forwarded-For}i)s %(l)s %(u)s %(t)s '%(r)s' %(s)s %(b)s '%(f)s' '%(a)s'", \ + "--log-level", \ + "info", \ + "--workers", \ + "2", \ + "--bind", \ + "0.0.0.0:8888", \ + "config.wsgi:application" \ +] + +ARG RELEASE +ENV RELEASE=${RELEASE} diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e43db07a --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +RELEASE := $$(git show -s --format=%H) +IMAGE := modeemi/intternetvelho + +test: + @echo "Running tests and linters" + python manage.py test + +build: + docker build --build-arg RELEASE=${RELEASE} -t ${IMAGE} . + +run: + docker run ${IMAGE} + +push: + docker push ${IMAGE} + +pull: + docker pull ${IMAGE} + +default: + make test + +all: + make test + make build + make push + +.PHONY: all default test build push pull run diff --git a/bower.json b/bower.json deleted file mode 100644 index 09361928..00000000 --- a/bower.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "modeemintternet", - "version": "2017.01.28", - "authors": [ - "Aleksi Häkli " - ], - "description": "Uusi Modeemin Intternet", - "main": "bower.json", - "keywords": [ - "modeemi", - "ry", - "modeemi.fi", - "tty", - "tampere", - "tampereen", - "teknillinen", - "yliopisto", - "university", - "of", - "technology", - "rekisteröity", - "yhdistys" - ], - "license": "MIT", - "homepage": "https://www.modeemi.fi/", - "private": true, - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ], - "dependencies": { - "bootstrap": "3.3.7", - "jquery": "2.2.4", - "font-awesome": "4.7.0" - } -} diff --git a/config/settings/base.py b/config/settings/base.py index 91d32c36..a03b3afe 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ Django settings for modeemintternet project. @@ -7,12 +5,11 @@ https://docs.djangoproject.com/en/1.8/topics/settings/ """ -from __future__ import unicode_literals - import warnings import environ + PROJECT_ROOT = environ.Path(__file__) - 3 # type: environ.Path PROJECT_DIR = PROJECT_ROOT.path('modeemintternet') @@ -23,9 +20,6 @@ env.read_env('.env') env.read_env('/etc/modeemintternet/env') -# Quick-start settings, check for deployment -# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ - DEBUG = env('DJANGO_DEBUG', cast=bool, default=False) ROOT_URLCONF = 'config.urls' WSGI_APPLICATION = 'config.wsgi.application' @@ -89,7 +83,6 @@ USE_TZ = True STATICFILES_DIRS = ( - PROJECT_ROOT('vendor'), PROJECT_DIR('static'), ) @@ -109,7 +102,6 @@ 'crispy_forms', 'rest_framework', - 'raven.contrib.django.raven_compat', 'snowpenguin.django.recaptcha2', 'modeemintternet', @@ -117,6 +109,9 @@ MIDDLEWARE = ( 'django.middleware.security.SecurityMiddleware', + + 'whitenoise.middleware.WhiteNoiseMiddleware', + 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.http.ConditionalGetMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -152,4 +147,28 @@ }, ] +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + }, + }, + 'loggers': { + '': { + 'handlers': ['console'], + 'level': env('DJANGO_LOG_LEVEL', default='INFO'), + }, + 'django': { + 'handlers': ['console'], + 'level': env('DJANGO_LOG_LEVEL', default='INFO'), + }, + 'django.request': { + 'handlers': ['console'], + 'level': env('DJANGO_REQUEST_LOG_LEVEL', default='INFO'), + }, + }, +} + CRISPY_TEMPLATE_PACK = 'bootstrap3' diff --git a/config/settings/docker.py b/config/settings/docker.py new file mode 100644 index 00000000..5d693f15 --- /dev/null +++ b/config/settings/docker.py @@ -0,0 +1,4 @@ +from .production import * # noqa + + +STATIC_ROOT = '/app/static' diff --git a/config/settings/local.py b/config/settings/local.py index 947118da..b20a6770 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import os from .base import * # noqa @@ -7,7 +5,6 @@ DEBUG = True SECRET_KEY = env('DJANGO_SECRETKEY', default='thisisthedummydjangosecretkey') - EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend') RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY', default=None) diff --git a/config/settings/production.py b/config/settings/production.py index cfc2241c..3e2a3edc 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - -import raven from logging import getLogger from django.core.exceptions import ImproperlyConfigured @@ -19,27 +16,19 @@ RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY') RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PRIVATE_KEY') -if len(SECRET_KEY) < 42: +if len(SECRET_KEY) < 18: raise ImproperlyConfigured('Django SECRET_KEY is too short, length is {}'.format(len(SECRET_KEY))) -# Database -# https://docs.djangoproject.com/en/1.8/ref/settings/#databases DATABASES = { 'default': env.db(), 'modeemiuserdb': env.db('MODEEMIUSERDB_URL'), } -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage' +STATICFILES_STORAGE = env( + 'DJANGO_STATICFILES_STORAGE', + default='whitenoise.storage.CompressedStaticFilesStorage', +) + STATIC_ROOT = '/var/www/modeemintternet/static' MEDIA_ROOT = '/var/www/modeemintternet/media' -try: - release = raven.fetch_git_sha(str(PROJECT_ROOT)) -except Exception as e: - log.error(e) - release = None - -RAVEN_CONFIG = { - 'dsn': env('RAVEN_DSN', default=None), - 'release': release, -} diff --git a/config/settings/test.py b/config/settings/test.py index cd7b7686..70c922b2 100644 --- a/config/settings/test.py +++ b/config/settings/test.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -import os - from .local import * # noqa SECRET_KEY = env('DJANGO_SECRETKEY', default='thisisthedummydjangosecretkey') diff --git a/config/urls.py b/config/urls.py index eb307294..bb43a4b5 100644 --- a/config/urls.py +++ b/config/urls.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - from django.urls import include, path from django.conf.urls.static import static diff --git a/config/wsgi.py b/config/wsgi.py index 8e00ca73..7bd44b46 100644 --- a/config/wsgi.py +++ b/config/wsgi.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - import os from django.core.wsgi import get_wsgi_application diff --git a/etc/apache2/sites-available/www.modeemi.fi b/etc/apache2/sites-available/www.modeemi.fi deleted file mode 100644 index eb15b5b2..00000000 --- a/etc/apache2/sites-available/www.modeemi.fi +++ /dev/null @@ -1,54 +0,0 @@ -# Modeemi Intternet Projekt server Apache config -# -# NOTE: SSL setup requires a concatenated cert where your own and -# chain certificate files are concatenated into one .crt file - -NameVirtualHost 130.230.72.136:80 -NameVirtualHost [2001:708:310:3430:8057:e2ff:fe1d:fcdf]:80 - - - ServerName www.modeemi.fi - ServerAlias modeemi.fi - ServerAlias www.modeemi.cs.tut.fi - ServerAlias modeemi.cs.tut.fi - ServerAdmin webmaster@modeemi.fi - - RewriteEngine On - RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} - - - -Listen 130.230.72.136:443 -Listen [2001:708:310:3430:8057:e2ff:fe1d:fcdf]:443 -NameVirtualHost 130.230.72.136:443 -NameVirtualHost [2001:708:310:3430:8057:e2ff:fe1d:fcdf]:443 - - - ServerName www.modeemi.fi - ServerAlias www.modeemi.cs.tut.fi - ServerAlias modeemi.fi - ServerAlias modeemi.cs.tut.fi - ServerAdmin webmaster@modeemi.fi - - ErrorLog ${APACHE_LOG_DIR}/www.modeemi.fi.error.log - TransferLog ${APACHE_LOG_DIR}/www.modeemi.fi.access.log - - SSLEngine on - SSLCertificateFile /etc/ssl/certs/www.modeemi.fi.crt - SSLCertificateKeyFile /etc/ssl/certs/www.modeemi.fi.key - SSLVerifyClient None - - BrowserMatch ".*MSIE.*" \ - nokeepalive ssl-unclean-shutdown \ - downgrade-1.0 force-response-1.0 - - - uWSGIforceScriptName "/" - uWSGISocket 127.0.0.1:8666 - SetHandler uwsgi-handler - - - Alias /static /var/www/modeemintternet/static/ - Alias /media /var/www/modeemintternet/media/ - - diff --git a/etc/nginx/sites-available/www.modeemi.fi b/etc/nginx/sites-available/www.modeemi.fi deleted file mode 100644 index 0eb9f693..00000000 --- a/etc/nginx/sites-available/www.modeemi.fi +++ /dev/null @@ -1,74 +0,0 @@ -# Modeemi Intternet Projekt server nginx config -# -# NOTE: SSL setup requires a concatenated cert where your own and -# chain certificate files are concatenated into one .crt file - -# The upstream component nginx needs to connect to; we're using an unix socket -upstream django { - server 127.0.0.1:8666; -} - -# Modeemi web server HTTP config, just redirects to an HTTPS url -server { - listen 80; - server_name "modeemi.fi" "www.modeemi.fi" "www.modeemi.cs.tut.fi" "modeemi.cs.tut.fi"; - charset utf-8; - rewrite ^(.*) https://$host$1 permanent; -} - -# Modeemi web server HTTPS config, actually serves the site -server { - listen 443 ssl; - server_name "modeemi.fi" "www.modeemi.fi" "www.modeemi.cs.tut.fi" "modeemi.cs.tut.fi"; - charset utf-8; - - # Max upload size, adjust to taste - client_max_body_size 75M; - - # Enable gzip compression - gzip_comp_level 2; - gzip_min_length 1000; - gzip_proxied expired no-cache no-store private auth; - gzip_types text/plain text/css application/javascript application/x-javascript application/json text/xml application/xml; - - # Enable timeouts with sane defaults - client_body_timeout 12; - client_header_timeout 12; - send_timeout 10; - - # NOTE: Check that the chain cert is concatenated correctly into the .crt - ssl_certificate /etc/ssl/certs/www.modeemi.fi.crt; - ssl_certificate_key /etc/ssl/private/www.modeemi.fi.key; - - # Additional security hardening - # Add HSTS headers and set up a sane cipher suite - add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; - ssl_prefer_server_ciphers On; - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; - ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS; - - # Deny any hidden files in server root - location ~ /\. { - deny all; - } - - # Cache static files for a sane duration - location ~* .(jpg|jpeg|png|gif|ico|css|js|json|map|woff|woff2|tff|svg|eot)$ { - expires 14d; - } - - # Handle static and media paths with aliases - # Otherwise the django handler will catch them - location /static { - alias /var/www//modeemintternet/static; - } - location /media { - alias /var/www//modeemintternet/media; - } - - # Other /resources requests go to the uWSGI server - location / { - uwsgi_pass django; - include /etc/uwsgi/www.modeemi.fi.params; - } -} diff --git a/etc/supervisord/conf.d/www.modeemi.fi.conf b/etc/supervisord/conf.d/www.modeemi.fi.conf deleted file mode 100644 index 15e0b97a..00000000 --- a/etc/supervisord/conf.d/www.modeemi.fi.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:modeemintternet] -user=modeemintternet ; configure the server user here -directory=/opt/intternet/modeemintternet/ ; relative to virtualenv -command=/usr/local/bin/uwsgi - --pp /opt/intternet/modeemintternet/virtualenv - --ini /etc/uwsgi/www.modeemi.fi.ini -autostart=true ; start at login -autorestart=true ; restart if necessary diff --git a/etc/uwsgi/www.modeemi.fi.ini b/etc/uwsgi/www.modeemi.fi.ini deleted file mode 100644 index 8c55fad0..00000000 --- a/etc/uwsgi/www.modeemi.fi.ini +++ /dev/null @@ -1,25 +0,0 @@ -# Demo server .ini file for uwsgi setup - -[uwsgi] - -# custom .ini variables -project = modeemintternet -homefolder = /opt/intternet - -# Django-related settings -# Directory we will serve from -chdir = %(homefolder)/%(project) -# Django's wsgi file as Python object (note syntax, folder.file:object) -module = %(project).wsgi:application -# virtualenv path for package configuration -home = %(homefolder)/%(project)/virtualenv - -# Process-related settings -master = true -# Process amount might have to be adjusted depending on server load -processes = 4 -buffer-size = 65535 -socket = 127.0.0.1:8666 -logto = /var/log/modeemintternet/%(project).log -# Clear environment on exit -vacuum = true diff --git a/etc/uwsgi/www.modeemi.fi.params b/etc/uwsgi/www.modeemi.fi.params deleted file mode 100644 index 0bdf13bb..00000000 --- a/etc/uwsgi/www.modeemi.fi.params +++ /dev/null @@ -1,15 +0,0 @@ -uwsgi_param QUERY_STRING $query_string; -uwsgi_param REQUEST_METHOD $request_method; -uwsgi_param CONTENT_TYPE $content_type; -uwsgi_param CONTENT_LENGTH $content_length; - -uwsgi_param REQUEST_URI $request_uri; -uwsgi_param PATH_INFO $document_uri; -uwsgi_param DOCUMENT_ROOT $document_root; -uwsgi_param SERVER_PROTOCOL $server_protocol; -uwsgi_param HTTPS $https if_not_empty; - -uwsgi_param REMOTE_ADDR $remote_addr; -uwsgi_param REMOTE_PORT $remote_port; -uwsgi_param SERVER_PORT $server_port; -uwsgi_param SERVER_NAME $server_name; \ No newline at end of file diff --git a/manage.py b/manage.py index a83a5f47..a1a1534e 100755 --- a/manage.py +++ b/manage.py @@ -1,8 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - import os import sys diff --git a/modeemintternet/admin.py b/modeemintternet/admin.py index 451bd9cb..7d767a07 100644 --- a/modeemintternet/admin.py +++ b/modeemintternet/admin.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - from logging import getLogger from django.contrib import admin diff --git a/modeemintternet/apiviews.py b/modeemintternet/apiviews.py index 0d16a71f..68d68acb 100644 --- a/modeemintternet/apiviews.py +++ b/modeemintternet/apiviews.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - from rest_framework import viewsets from modeemintternet.models import News from modeemintternet.serializers import NewsSerializer diff --git a/modeemintternet/feeds.py b/modeemintternet/feeds.py index b0391c90..1058b68c 100644 --- a/modeemintternet/feeds.py +++ b/modeemintternet/feeds.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - from django.contrib.syndication.views import Feed from django_ical.views import ICalFeed diff --git a/modeemintternet/forms.py b/modeemintternet/forms.py index 42744e2e..f882dbe9 100644 --- a/modeemintternet/forms.py +++ b/modeemintternet/forms.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - from django.core.exceptions import ValidationError from django.forms import ModelForm, CharField, PasswordInput diff --git a/modeemintternet/mailer.py b/modeemintternet/mailer.py index c999d15f..7a4e2d2f 100644 --- a/modeemintternet/mailer.py +++ b/modeemintternet/mailer.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - """ Custom mailer for the awesome modeemintternet super portal. """ diff --git a/modeemintternet/migrations/0001_initial.py b/modeemintternet/migrations/0001_initial.py index 2b9b716b..61e0dfc5 100644 --- a/modeemintternet/migrations/0001_initial.py +++ b/modeemintternet/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0002_soda.py b/modeemintternet/migrations/0002_soda.py index bf26789e..032274fe 100644 --- a/modeemintternet/migrations/0002_soda.py +++ b/modeemintternet/migrations/0002_soda.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0003_auto_20141014_1639.py b/modeemintternet/migrations/0003_auto_20141014_1639.py index fcd03f72..708f3660 100644 --- a/modeemintternet/migrations/0003_auto_20141014_1639.py +++ b/modeemintternet/migrations/0003_auto_20141014_1639.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0004_auto_20150315_0131.py b/modeemintternet/migrations/0004_auto_20150315_0131.py index 6ac219d5..7409bfe1 100644 --- a/modeemintternet/migrations/0004_auto_20150315_0131.py +++ b/modeemintternet/migrations/0004_auto_20150315_0131.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0005_auto_20150329_1547.py b/modeemintternet/migrations/0005_auto_20150329_1547.py index c55b2c5d..f463c0a3 100644 --- a/modeemintternet/migrations/0005_auto_20150329_1547.py +++ b/modeemintternet/migrations/0005_auto_20150329_1547.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0006_auto_20150329_2023.py b/modeemintternet/migrations/0006_auto_20150329_2023.py index 81ddc69b..2da23ae4 100644 --- a/modeemintternet/migrations/0006_auto_20150329_2023.py +++ b/modeemintternet/migrations/0006_auto_20150329_2023.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0007_application_des_crypt.py b/modeemintternet/migrations/0007_application_des_crypt.py index 51fec094..797b84c9 100644 --- a/modeemintternet/migrations/0007_application_des_crypt.py +++ b/modeemintternet/migrations/0007_application_des_crypt.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0008_auto_20150403_0333.py b/modeemintternet/migrations/0008_auto_20150403_0333.py index 77dae05b..758b402a 100644 --- a/modeemintternet/migrations/0008_auto_20150403_0333.py +++ b/modeemintternet/migrations/0008_auto_20150403_0333.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/modeemintternet/migrations/0009_auto_20160229_1131.py b/modeemintternet/migrations/0009_auto_20160229_1131.py index 43396822..224c7ba2 100644 --- a/modeemintternet/migrations/0009_auto_20160229_1131.py +++ b/modeemintternet/migrations/0009_auto_20160229_1131.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models diff --git a/modeemintternet/migrations/0010_auto_20160229_1132.py b/modeemintternet/migrations/0010_auto_20160229_1132.py index 9c75e6d0..a0f52e57 100644 --- a/modeemintternet/migrations/0010_auto_20160229_1132.py +++ b/modeemintternet/migrations/0010_auto_20160229_1132.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models diff --git a/modeemintternet/migrations/0011_auto_20170128_1807.py b/modeemintternet/migrations/0011_auto_20170128_1807.py index 7c5faefa..04a1b171 100644 --- a/modeemintternet/migrations/0011_auto_20170128_1807.py +++ b/modeemintternet/migrations/0011_auto_20170128_1807.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models diff --git a/modeemintternet/models.py b/modeemintternet/models.py index 1543d641..c32ee069 100644 --- a/modeemintternet/models.py +++ b/modeemintternet/models.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - import re from logging import getLogger from passlib.context import CryptContext diff --git a/modeemintternet/serializers.py b/modeemintternet/serializers.py index 05150327..2ad7667f 100644 --- a/modeemintternet/serializers.py +++ b/modeemintternet/serializers.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - from rest_framework import serializers from modeemintternet.models import News diff --git a/modeemintternet/templates/base.html b/modeemintternet/templates/base.html index fac24aca..29c00419 100644 --- a/modeemintternet/templates/base.html +++ b/modeemintternet/templates/base.html @@ -1,6 +1,5 @@ {% load cache %} {% load staticfiles %} -{% load raven %} {% load version %} {% load recaptcha2 %} @@ -25,13 +24,13 @@ {% endblock meta %} {% block link %} - {% cache 3600 link %} - - - - - - {% endcache %} + + + + + + + {% endblock link %} {% recaptcha_init %} @@ -42,32 +41,21 @@ {% block content %}{% endblock %} -{% cache 3600 footer %} - -{% endcache %} + {% block script %} - {% cache 3600 script %} - {% comment 'Ei lie tarvetta ajella virhetrackaysta ilman JavaScriptiä frontissa' %} - {% if not debug %} - - - {% endif %} - {% endcomment %} - - - - {% endcache %} + + {% endblock script %} diff --git a/modeemintternet/templatetags/version.py b/modeemintternet/templatetags/version.py index 5b6d416d..14c92139 100644 --- a/modeemintternet/templatetags/version.py +++ b/modeemintternet/templatetags/version.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import logging import os diff --git a/modeemintternet/tests.py b/modeemintternet/tests.py index 9bd9b6ed..ada338c9 100644 --- a/modeemintternet/tests.py +++ b/modeemintternet/tests.py @@ -1,11 +1,7 @@ -# -*- coding: utf-8 -*- - """ Unit tests for modeemintternet app. """ -from __future__ import unicode_literals - import datetime from django.conf import settings diff --git a/modeemintternet/views.py b/modeemintternet/views.py index d423ff51..e497adb2 100644 --- a/modeemintternet/views.py +++ b/modeemintternet/views.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - import logging from django.http import HttpResponse diff --git a/requirements.in b/requirements.in index 522101b6..734e95a6 100644 --- a/requirements.in +++ b/requirements.in @@ -5,15 +5,16 @@ django-debug-toolbar django-environ django-guardian django-ical +django-recaptcha2 django-rest-swagger -django-suit djangorestframework future gitpython gunicorn icalendar +ipython passlib pip-tools -psycopg2 +psycopg2-binary pytz -raven +whitenoise diff --git a/requirements.txt b/requirements.txt index d974a33c..66006f3f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,45 +2,60 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile --output-file requirements.txt requirements.in +# pip-compile # +appnope==0.1.0 # via ipython +backcall==0.1.0 # via ipython certifi==2019.6.16 # via requests chardet==3.0.4 # via requests click==7.0 # via pip-tools coreapi==2.3.3 # via django-rest-swagger, openapi-codec coreschema==0.0.4 # via coreapi coverage==4.5.4 +decorator==4.4.0 # via ipython, traitlets django-crispy-forms==1.7.2 django-debug-toolbar==2.0 django-environ==0.4.5 django-guardian==2.0.0 django-ical==1.5 +django-recaptcha2==1.4.1 django-rest-swagger==2.2.0 -django-suit==0.2.26 django==2.2.3 -django-recaptcha2==1.4.1 djangorestframework==3.10.2 -first==2.0.2 # via pip-tools future==0.17.1 gitdb2==2.0.5 # via gitpython gitpython==2.1.13 gunicorn==19.9.0 icalendar==4.0.3 idna==2.8 # via requests +ipython-genutils==0.2.0 # via traitlets +ipython==7.7.0 itypes==1.1.0 # via coreapi -jinja2==2.10.1 # via coreschema -markupsafe==1.1.1 # via jinja2 +jedi==0.14.1 # via ipython +jinja2==2.10.1 # via coreschema +markupsafe==1.1.1 # via jinja2 openapi-codec==1.3.2 # via django-rest-swagger +parso==0.5.1 # via jedi passlib==1.7.1 -pip-tools==4.0.0 -psycopg2==2.8.3 +pexpect==4.7.0 # via ipython +pickleshare==0.7.5 # via ipython +pip-tools==3.8.0 +prompt-toolkit==2.0.9 # via ipython +psycopg2-binary==2.8.3 +ptyprocess==0.6.0 # via pexpect +pygments==2.4.2 # via ipython python-dateutil==2.8.0 # via icalendar pytz==2019.1 -raven==6.10.0 -requests==2.22.0 # via coreapi +requests==2.22.0 # via coreapi, django-recaptcha2 simplejson==3.16.0 # via django-rest-swagger -six==1.12.0 # via django-environ, django-guardian, pip-tools, python-dateutil +six==1.12.0 # via pip-tools, prompt-toolkit, python-dateutil, traitlets smmap2==2.0.5 # via gitdb2 -sqlparse==0.3.0 # via django-debug-toolbar +sqlparse==0.3.0 # via django, django-debug-toolbar +traitlets==4.3.2 # via ipython uritemplate==3.0.0 # via coreapi -urllib3==1.25.3 # via requests +urllib3==1.25.3 # via requests +wcwidth==0.1.7 # via prompt-toolkit +whitenoise==4.1.3 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools==41.0.1 # via ipython diff --git a/scripts/entrypoint b/scripts/entrypoint new file mode 100644 index 00000000..99ef7492 --- /dev/null +++ b/scripts/entrypoint @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ ! -z "${DATABASE_MIGRATE:-}" ]]; then + if [[ ! -z "${DATABASE_WAIT_ON_STARTUP_SECONDS:-}" ]]; then + echo "Waiting for ${DATABASE_WAIT_ON_STARTUP_SECONDS} seconds before running any database operations" + sleep ${DATABASE_WAIT_ON_STARTUP_SECONDS} + fi + + echo "Running database migrations" + python manage.py migrate --noinput + echo "Creating database cache tables" + python manage.py createcachetable +fi + +exec "$@"