diff --git a/DjangoFiles/Administration/__init__.py b/DjangoFiles/Administration/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/DjangoFiles/Administration/admin.py b/DjangoFiles/Administration/admin.py deleted file mode 100644 index 60b2a4f..0000000 --- a/DjangoFiles/Administration/admin.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.contrib import admin -from django_tenants.admin import TenantAdminMixin - -from Customers.models import Client - -@admin.register(Client) -class ClientAdmin(TenantAdminMixin, admin.ModelAdmin): - list_display = ('name', 'paid_until') \ No newline at end of file diff --git a/DjangoFiles/Administration/apps.py b/DjangoFiles/Administration/apps.py deleted file mode 100644 index bad86a2..0000000 --- a/DjangoFiles/Administration/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class AdministrationConfig(AppConfig): - name = 'Administration' diff --git a/DjangoFiles/Administration/migrations/__init__.py b/DjangoFiles/Administration/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/DjangoFiles/Administration/models.py b/DjangoFiles/Administration/models.py deleted file mode 100644 index 71a8362..0000000 --- a/DjangoFiles/Administration/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/DjangoFiles/Administration/tests.py b/DjangoFiles/Administration/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/DjangoFiles/Administration/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/DjangoFiles/Administration/views.py b/DjangoFiles/Administration/views.py deleted file mode 100644 index 91ea44a..0000000 --- a/DjangoFiles/Administration/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/DjangoFiles/Customers/migrations/0001_initial.py b/DjangoFiles/Customers/migrations/0001_initial.py deleted file mode 100644 index 7e05e9d..0000000 --- a/DjangoFiles/Customers/migrations/0001_initial.py +++ /dev/null @@ -1,42 +0,0 @@ -# Generated by Django 3.1 on 2021-06-10 10:54 - -from django.db import migrations, models -import django.db.models.deletion -import django_tenants.postgresql_backend.base - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Client', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('schema_name', models.CharField(db_index=True, max_length=63, unique=True, validators=[django_tenants.postgresql_backend.base._check_schema_name])), - ('name', models.CharField(max_length=100)), - ('paid_until', models.DateField()), - ('on_trial', models.BooleanField()), - ('created_on', models.DateField(auto_now_add=True)), - ], - options={ - 'abstract': False, - }, - ), - migrations.CreateModel( - name='Domain', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('domain', models.CharField(db_index=True, max_length=253, unique=True)), - ('is_primary', models.BooleanField(db_index=True, default=True)), - ('tenant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='domains', to='Customers.client')), - ], - options={ - 'abstract': False, - }, - ), - ] diff --git a/DjangoFiles/Customers/migrations/0002_create_tenant_public.py b/DjangoFiles/Customers/migrations/0002_create_tenant_public.py deleted file mode 100644 index b05b4e5..0000000 --- a/DjangoFiles/Customers/migrations/0002_create_tenant_public.py +++ /dev/null @@ -1,46 +0,0 @@ -# Generated by Django 3.1 on 2021-06-10 10:56 -import os -from django.db import migrations - - -def create_premier_tenant(apps, schema_editor): - # We can't import the Person model directly as it may be a newer - # version than this migration expects. We use the historical version. - Client = apps.get_model('Customers', 'Client') - Domain = apps.get_model('Customers', 'Domain') - DNS = os.getenv('DOMAIN') - - tenant_public = Client.objects.get_or_create(schema_name='public', - name='Tibillet Public', - paid_until='2200-12-05', - on_trial=False)[0] - - # Add one or more domains for the tenant - domaine_seul = Domain.objects.get_or_create(domain=DNS, - tenant=tenant_public, - is_primary=True, - ) - - domaine_www = Domain.objects.get_or_create(domain=f'www.{DNS}', - tenant=tenant_public, - is_primary=False, - ) - - return tenant_public, domaine_seul[0], domaine_www[0] - - -def reverse(apps, schema_editor): - tenant_public, domaine_seul, domaine_www = create_premier_tenant(apps, schema_editor) - tenant_public.delete() - domaine_seul.delete() - domaine_www.delete() - - -class Migration(migrations.Migration): - dependencies = [ - ('Customers', '0001_initial'), - ] - - operations = [ - migrations.RunPython(create_premier_tenant, reverse), - ] diff --git a/DjangoFiles/Customers/models.py b/DjangoFiles/Customers/models.py index 86b9b2c..71a8362 100644 --- a/DjangoFiles/Customers/models.py +++ b/DjangoFiles/Customers/models.py @@ -1,14 +1,3 @@ from django.db import models -from django_tenants.models import TenantMixin, DomainMixin -class Client(TenantMixin): - name = models.CharField(max_length=100) - paid_until = models.DateField() - on_trial = models.BooleanField() - created_on = models.DateField(auto_now_add=True) - - # default true, schema will be automatically created and synced when it is saved - auto_create_schema = True - -class Domain(DomainMixin): - pass +# Create your models here. diff --git a/DjangoFiles/TiBillet/asgi.py b/DjangoFiles/TiBillet/asgi.py deleted file mode 100644 index 0c34623..0000000 --- a/DjangoFiles/TiBillet/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for TiBillet project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TiBillet.settings') - -application = get_asgi_application() diff --git a/DjangoFiles/TiBillet/settings.py b/DjangoFiles/TiBillet/settings.py index 0b2595c..5f6a0b8 100644 --- a/DjangoFiles/TiBillet/settings.py +++ b/DjangoFiles/TiBillet/settings.py @@ -1,67 +1,45 @@ """ Django settings for TiBillet project. -Generated by 'django-admin startproject' using Django 3.1. +Generated by 'django-admin startproject' using Django 2.2. For more information on this file, see -https://docs.djangoproject.com/en/3.1/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/3.1/ref/settings/ +https://docs.djangoproject.com/en/2.2/ref/settings/ """ -import os -from pathlib import Path -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve(strict=True).parent.parent +import os + +# 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/3.1/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 = os.environ.get('DJANGO_SECRET') +SECRET_KEY = '(4ux&3#$@yn=dxpi%sl^*&ib+mtg2c0-2gxwjl-m&^ci@+a!o!' # SECURITY WARNING: don't run with debug turned on in production! -# noinspection DjangoDebugModeSettings -if os.environ.get('DEBUG_DJANGO') == "True": - DEBUG = True -else: - DEBUG = False +DEBUG = True + +ALLOWED_HOSTS = [] -ALLOWED_HOSTS = ['*'] # Application definition -SHARED_APPS = ( - 'django_tenants', # mandatory - 'Customers', # you must list the app where your tenant model resides in - - 'django.contrib.contenttypes', - - # everything below here is optional - 'django.contrib.auth', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.messages', +INSTALLED_APPS = [ 'django.contrib.admin', - 'django_extensions', - 'Administration', -) - -TENANT_APPS = ( - # The following Django contrib apps must be in TENANT_APPS + 'django.contrib.auth', 'django.contrib.contenttypes', - - # your tenant-specific apps -) - -INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS] -TENANT_MODEL = "Customers.Client" # app.Model -TENANT_DOMAIN_MODEL = "Customers.Domain" # app.Model - + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] MIDDLEWARE = [ - 'django_tenants.middleware.main.TenantMainMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -91,26 +69,20 @@ TEMPLATES = [ WSGI_APPLICATION = 'TiBillet.wsgi.application' + # Database -# https://docs.djangoproject.com/en/3.1/ref/settings/#databases +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { - 'ENGINE': 'django_tenants.postgresql_backend', # Add 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': os.environ.get('POSTGRES_DB'), - 'USER': os.environ.get('POSTGRES_USER'), - 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), - 'HOST': os.environ.get('POSTGRES_HOST'), - 'PORT': os.environ.get('POSTGRES_PORT', '5432'), + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } -DATABASE_ROUTERS = ( - 'django_tenants.routers.TenantSyncRouter', -) # Password validation -# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -127,8 +99,9 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] + # Internationalization -# https://docs.djangoproject.com/en/3.1/topics/i18n/ +# https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -140,7 +113,8 @@ USE_L10N = True USE_TZ = True + # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.1/howto/static-files/ +# https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/' diff --git a/DjangoFiles/TiBillet/urls.py b/DjangoFiles/TiBillet/urls.py index 303b144..fcbdad3 100644 --- a/DjangoFiles/TiBillet/urls.py +++ b/DjangoFiles/TiBillet/urls.py @@ -1,7 +1,7 @@ """TiBillet URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.1/topics/http/urls/ + https://docs.djangoproject.com/en/2.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views diff --git a/DjangoFiles/TiBillet/wsgi.py b/DjangoFiles/TiBillet/wsgi.py index 2a102c5..0a62464 100644 --- a/DjangoFiles/TiBillet/wsgi.py +++ b/DjangoFiles/TiBillet/wsgi.py @@ -4,7 +4,7 @@ WSGI config for TiBillet 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/3.1/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ """ import os diff --git a/DjangoFiles/launch.sh b/DjangoFiles/launch.sh index a8fcc88..3b691eb 100755 --- a/DjangoFiles/launch.sh +++ b/DjangoFiles/launch.sh @@ -1 +1 @@ -sleep 36d \ No newline at end of file +sleep 30d \ No newline at end of file diff --git a/DjangoFiles/manage.py b/DjangoFiles/manage.py index 96e0cbb..402c2cc 100755 --- a/DjangoFiles/manage.py +++ b/DjangoFiles/manage.py @@ -5,7 +5,6 @@ import sys def main(): - """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TiBillet.settings') try: from django.core.management import execute_from_command_line diff --git a/Docker/Dockerfile/dockerfile b/Docker/Dockerfile/dockerfile index c50f2d9..1e019b7 100644 --- a/Docker/Dockerfile/dockerfile +++ b/Docker/Dockerfile/dockerfile @@ -6,7 +6,7 @@ RUN apt-get upgrade -y RUN pip install pip --upgrade ## PYTHON -RUN pip install django==3.1 +RUN pip install django==2.2 RUN pip install djangorestframework==3.11 RUN pip install requests RUN pip install django-jet