diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d59fb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +db.sqlite3 diff --git a/README b/README index 5cd1c87..2fe8c34 100644 --- a/README +++ b/README @@ -1,19 +1,19 @@ ,--,--' `- | ,-. ,-. ,-. ,-. ,-. ,-. ,-. , | ,-| `-. ,-| | | | | ,-| `-' `-^ `-' `-^ `-' `-' ' `-^ This server allows you to run you own Tasacora web service. - It relies on Python 3.4 and Django 1.8. + It relies on Python 3.5 and Django 2.2. Support ======= * IRC Freeenode #tasacora http://irc.lc/freenode/tasacora (English, but most of us also speak French) * Community support on our forum http://purl.net/NET/Nasqueron/Tasacora/Forum (French, English) diff --git a/manage.py b/manage.py index a293c9f..cbd2640 100755 --- a/manage.py +++ b/manage.py @@ -1,12 +1,21 @@ #!/usr/bin/env python3 - +"""Django's command-line utility for administrative tasks.""" import os import sys -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tasacora_server.settings") +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tasacora_server.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + 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?" + ) from exc + execute_from_command_line(sys.argv) - from django.core.management import execute_from_command_line - execute_from_command_line(sys.argv) +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt index 21538a3..11df407 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -Django==1.8 +Django==2.2.1 django-extensions==1.5.2 six==1.9.0 diff --git a/tasacora_server/settings.py b/tasacora_server/settings.py index 0209e28..f0aea6a 100644 --- a/tasacora_server/settings.py +++ b/tasacora_server/settings.py @@ -1,83 +1,120 @@ """ Django settings for tasacora_server project. +Generated by 'django-admin startproject' using Django 2.2.1. + For more information on this file, see -https://docs.djangoproject.com/en/1.7/topics/settings/ +https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.7/ref/settings/ +https://docs.djangoproject.com/en/2.2/ref/settings/ """ -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '7gcawy)wodyrey55fc56i^fsc50*5zzaz=yzn4ux&186#76s^z' +SECRET_KEY = 'c(%(pkqf8^%db&cqc@9#&@n!w!!#8^rz+afv&ha6e7=nd_+d41' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -TEMPLATE_DEBUG = True - ALLOWED_HOSTS = [] # Application definition -INSTALLED_APPS = ( +INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', -) +] -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', -) +] ROOT_URLCONF = 'tasacora_server.urls' +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + WSGI_APPLICATION = 'tasacora_server.wsgi.application' # Database -# https://docs.djangoproject.com/en/1.7/ref/settings/#databases +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } + +# Password validation +# https://docs.djangoproject.com/en/2.2/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', + }, +] + + # Internationalization -# https://docs.djangoproject.com/en/1.7/topics/i18n/ +# https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.7/howto/static-files/ +# https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/' diff --git a/tasacora_server/urls.py b/tasacora_server/urls.py index d9bb933..7e98f79 100644 --- a/tasacora_server/urls.py +++ b/tasacora_server/urls.py @@ -1,10 +1,21 @@ -from django.conf.urls import patterns, include, url -from django.contrib import admin +"""tasacora_server URL Configuration -urlpatterns = patterns('', - # Examples: - # url(r'^$', 'tasacora_server.views.home', name='home'), - # url(r'^blog/', include('blog.urls')), +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path - url(r'^admin/', include(admin.site.urls)), - ) +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/tasacora_server/wsgi.py b/tasacora_server/wsgi.py index 686c66d..cd07976 100644 --- a/tasacora_server/wsgi.py +++ b/tasacora_server/wsgi.py @@ -1,14 +1,16 @@ """ WSGI config for tasacora_server project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ """ -from django.core.wsgi import get_wsgi_application import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tasacora_server.settings") + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tasacora_server.settings') application = get_wsgi_application()