Commit 6d7d3f44 authored by Florent Chehab's avatar Florent Chehab

Migrated from standard Django model to a custom one for optmization concerns

parent e8f37050
from django.contrib.auth.models import User from base_app.models import User
import os import os
......
import os import os
from django.contrib.auth.models import User from base_app.models import User
import pandas as pd import pandas as pd
from backend_app.models.country import Country from backend_app.models.country import Country
......
...@@ -2,7 +2,7 @@ import csv ...@@ -2,7 +2,7 @@ import csv
import os import os
from decimal import Decimal from decimal import Decimal
from django.contrib.auth.models import User from base_app.models import User
from backend_app.models.currency import Currency from backend_app.models.currency import Currency
......
from django.contrib.auth.models import User from base_app.models import User
from django.utils import timezone from django.utils import timezone
import reversion import reversion
......
import json import json
import os import os
from django.contrib.auth.models import User from base_app.models import User
from backend_app.models.tag import Tag from backend_app.models.tag import Tag
......
import os import os
from django.contrib.auth.models import User from base_app.models import User
import pandas as pd import pandas as pd
from backend_app.models.campus import Campus from backend_app.models.campus import Campus
......
from datetime import datetime from datetime import datetime
from django.contrib.auth.models import User from base_app.models import User
from backend_app.models.country import Country, CountryScholarship from backend_app.models.country import Country, CountryScholarship
from backend_app.models.currency import Currency from backend_app.models.currency import Currency
......
# Generated by Django 2.0.3 on 2018-09-16 13:31 # Generated by Django 2.1.7 on 2019-03-10 13:41
import backend_app.fields import backend_app.fields
import backend_app.models.abstract.my_model.myModel import backend_app.models.abstract.my_model.myModel
...@@ -14,9 +14,9 @@ class Migration(migrations.Migration): ...@@ -14,9 +14,9 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
("auth", "0009_alter_user_last_name_max_length"),
("contenttypes", "0002_remove_content_type_name"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("contenttypes", "0002_remove_content_type_name"),
("base_app", "0001_initial"),
] ]
operations = [ operations = [
...@@ -32,8 +32,8 @@ class Migration(migrations.Migration): ...@@ -32,8 +32,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -44,8 +44,8 @@ class Migration(migrations.Migration): ...@@ -44,8 +44,8 @@ class Migration(migrations.Migration):
], ],
), ),
), ),
("title", models.CharField(default="", max_length=150)), ("title", models.CharField(blank=True, default="", max_length=150)),
("comment", models.CharField(default="", max_length=5000)), ("comment", models.CharField(blank=True, default="", max_length=5000)),
("useful_links", backend_app.fields.JSONField(default=list)), ("useful_links", backend_app.fields.JSONField(default=list)),
( (
"importance_level", "importance_level",
...@@ -60,7 +60,7 @@ class Migration(migrations.Migration): ...@@ -60,7 +60,7 @@ class Migration(migrations.Migration):
), ),
), ),
("is_main_campus", models.BooleanField()), ("is_main_campus", models.BooleanField()),
("name", models.CharField(default="", max_length=200)), ("name", models.CharField(blank=True, default="", max_length=200)),
( (
"lat", "lat",
models.DecimalField( models.DecimalField(
...@@ -97,8 +97,8 @@ class Migration(migrations.Migration): ...@@ -97,8 +97,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -109,8 +109,8 @@ class Migration(migrations.Migration): ...@@ -109,8 +109,8 @@ class Migration(migrations.Migration):
], ],
), ),
), ),
("title", models.CharField(default="", max_length=150)), ("title", models.CharField(blank=True, default="", max_length=150)),
("comment", models.CharField(default="", max_length=5000)), ("comment", models.CharField(blank=True, default="", max_length=5000)),
("useful_links", backend_app.fields.JSONField(default=list)), ("useful_links", backend_app.fields.JSONField(default=list)),
( (
"importance_level", "importance_level",
...@@ -147,8 +147,8 @@ class Migration(migrations.Migration): ...@@ -147,8 +147,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -160,8 +160,11 @@ class Migration(migrations.Migration): ...@@ -160,8 +160,11 @@ class Migration(migrations.Migration):
), ),
), ),
("name", models.CharField(max_length=200)), ("name", models.CharField(max_length=200)),
("local_name", models.CharField(default="", max_length=200)), (
("area", models.CharField(default="", max_length=200)), "local_name",
models.CharField(blank=True, default="", max_length=200),
),
("area", models.CharField(blank=True, default="", max_length=200)),
], ],
options={"abstract": False}, options={"abstract": False},
), ),
...@@ -177,8 +180,8 @@ class Migration(migrations.Migration): ...@@ -177,8 +180,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -189,8 +192,8 @@ class Migration(migrations.Migration): ...@@ -189,8 +192,8 @@ class Migration(migrations.Migration):
], ],
), ),
), ),
("title", models.CharField(default="", max_length=150)), ("title", models.CharField(blank=True, default="", max_length=150)),
("comment", models.CharField(default="", max_length=5000)), ("comment", models.CharField(blank=True, default="", max_length=5000)),
("useful_links", backend_app.fields.JSONField(default=list)), ("useful_links", backend_app.fields.JSONField(default=list)),
( (
"importance_level", "importance_level",
...@@ -218,8 +221,8 @@ class Migration(migrations.Migration): ...@@ -218,8 +221,8 @@ class Migration(migrations.Migration):
migrations.CreateModel( migrations.CreateModel(
name="Country", name="Country",
fields=[ fields=[
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -237,19 +240,25 @@ class Migration(migrations.Migration): ...@@ -237,19 +240,25 @@ class Migration(migrations.Migration):
), ),
( (
"iso_alpha3_code", "iso_alpha3_code",
models.CharField(default="", max_length=3, unique=True), models.CharField(blank=True, default="", max_length=3, unique=True),
), ),
("region_name", models.CharField(max_length=200)), ("region_name", models.CharField(max_length=200)),
("region_un_code", models.CharField(max_length=3)), ("region_un_code", models.CharField(max_length=3)),
("sub_region_name", models.CharField(default="", max_length=200)), (
("sub_region_un_code", models.CharField(default="", max_length=3)), "sub_region_name",
models.CharField(blank=True, default="", max_length=200),
),
(
"sub_region_un_code",
models.CharField(blank=True, default="", max_length=3),
),
( (
"intermediate_region_name", "intermediate_region_name",
models.CharField(default="", max_length=200), models.CharField(blank=True, default="", max_length=200),
), ),
( (
"intermediate_region_un_code", "intermediate_region_un_code",
models.CharField(default="", max_length=3), models.CharField(blank=True, default="", max_length=3),
), ),
], ],
options={"abstract": False}, options={"abstract": False},
...@@ -266,8 +275,8 @@ class Migration(migrations.Migration): ...@@ -266,8 +275,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -278,8 +287,8 @@ class Migration(migrations.Migration): ...@@ -278,8 +287,8 @@ class Migration(migrations.Migration):
], ],
), ),
), ),
("title", models.CharField(default="", max_length=150)), ("title", models.CharField(blank=True, default="", max_length=150)),
("comment", models.CharField(default="", max_length=5000)), ("comment", models.CharField(blank=True, default="", max_length=5000)),
("useful_links", backend_app.fields.JSONField(default=list)), ("useful_links", backend_app.fields.JSONField(default=list)),
( (
"importance_level", "importance_level",
...@@ -314,8 +323,8 @@ class Migration(migrations.Migration): ...@@ -314,8 +323,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -326,8 +335,8 @@ class Migration(migrations.Migration): ...@@ -326,8 +335,8 @@ class Migration(migrations.Migration):
], ],
), ),
), ),
("title", models.CharField(default="", max_length=150)), ("title", models.CharField(blank=True, default="", max_length=150)),
("comment", models.CharField(default="", max_length=5000)), ("comment", models.CharField(blank=True, default="", max_length=5000)),
("useful_links", backend_app.fields.JSONField(default=list)), ("useful_links", backend_app.fields.JSONField(default=list)),
( (
"importance_level", "importance_level",
...@@ -342,10 +351,14 @@ class Migration(migrations.Migration): ...@@ -342,10 +351,14 @@ class Migration(migrations.Migration):
), ),
), ),
("type", models.CharField(max_length=200)), ("type", models.CharField(max_length=200)),
("other_advantages", models.CharField(default="", max_length=5000)), (
"other_advantages",
models.CharField(blank=True, default="", max_length=5000),
),
( (
"frequency", "frequency",
models.CharField( models.CharField(
blank=True,
choices=[ choices=[
("w", "week"), ("w", "week"),
("m", "month"), ("m", "month"),
...@@ -355,6 +368,7 @@ class Migration(migrations.Migration): ...@@ -355,6 +368,7 @@ class Migration(migrations.Migration):
], ],
default="m", default="m",
max_length=1, max_length=1,
null=True,
), ),
), ),
( (
...@@ -396,8 +410,8 @@ class Migration(migrations.Migration): ...@@ -396,8 +410,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -408,8 +422,8 @@ class Migration(migrations.Migration): ...@@ -408,8 +422,8 @@ class Migration(migrations.Migration):
], ],
), ),
), ),
("title", models.CharField(default="", max_length=150)), ("title", models.CharField(blank=True, default="", max_length=150)),
("comment", models.CharField(default="", max_length=5000)), ("comment", models.CharField(blank=True, default="", max_length=5000)),
("useful_links", backend_app.fields.JSONField(default=list)), ("useful_links", backend_app.fields.JSONField(default=list)),
( (
"importance_level", "importance_level",
...@@ -437,8 +451,8 @@ class Migration(migrations.Migration): ...@@ -437,8 +451,8 @@ class Migration(migrations.Migration):
migrations.CreateModel( migrations.CreateModel(
name="Currency", name="Currency",
fields=[ fields=[
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -454,7 +468,7 @@ class Migration(migrations.Migration): ...@@ -454,7 +468,7 @@ class Migration(migrations.Migration):
models.CharField(max_length=3, primary_key=True, serialize=False), models.CharField(max_length=3, primary_key=True, serialize=False),
), ),
("name", models.CharField(max_length=100)), ("name", models.CharField(max_length=100)),
("symbol", models.CharField(default="", max_length=30)), ("symbol", models.CharField(blank=True, default="", max_length=30)),
( (
"one_EUR_in_this_currency", "one_EUR_in_this_currency",
models.DecimalField( models.DecimalField(
...@@ -469,8 +483,8 @@ class Migration(migrations.Migration): ...@@ -469,8 +483,8 @@ class Migration(migrations.Migration):
migrations.CreateModel( migrations.CreateModel(
name="Department", name="Department",
fields=[ fields=[
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -502,8 +516,8 @@ class Migration(migrations.Migration): ...@@ -502,8 +516,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -530,8 +544,8 @@ class Migration(migrations.Migration): ...@@ -530,8 +544,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -558,8 +572,8 @@ class Migration(migrations.Migration): ...@@ -558,8 +572,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -570,6 +584,15 @@ class Migration(migrations.Migration): ...@@ -570,6 +584,15 @@ class Migration(migrations.Migration):
], ],
), ),
), ),
("year", models.PositiveIntegerField(default=2018)),
(
"semester",
models.CharField(
choices=[("a", "autumn"), ("p", "spring")],
default="a",
max_length=2,
),
),
("nb_seats_offered", models.PositiveIntegerField()), ("nb_seats_offered", models.PositiveIntegerField()),
("nb_seats_offered_exchange", models.PositiveIntegerField(null=True)), ("nb_seats_offered_exchange", models.PositiveIntegerField(null=True)),
( (
...@@ -577,6 +600,7 @@ class Migration(migrations.Migration): ...@@ -577,6 +600,7 @@ class Migration(migrations.Migration):
models.PositiveIntegerField(null=True), models.PositiveIntegerField(null=True),
), ),
], ],
options={"abstract": False},
), ),
migrations.CreateModel( migrations.CreateModel(
name="PendingModeration", name="PendingModeration",
...@@ -614,8 +638,8 @@ class Migration(migrations.Migration): ...@@ -614,8 +638,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -627,6 +651,15 @@ class Migration(migrations.Migration): ...@@ -627,6 +651,15 @@ class Migration(migrations.Migration):
), ),
), ),
("Utc_departure_id", models.IntegerField()), ("Utc_departure_id", models.IntegerField()),
("year", models.PositiveIntegerField(default=2018)),
(
"semester",
models.CharField(
choices=[("a", "autumn"), ("p", "spring")],
default="a",
max_length=2,
),
),
("is_anonymous", models.BooleanField()), ("is_anonymous", models.BooleanField()),
("courses", backend_app.fields.JSONField(null=True)), ("courses", backend_app.fields.JSONField(null=True)),
], ],
...@@ -644,8 +677,8 @@ class Migration(migrations.Migration): ...@@ -644,8 +677,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -662,8 +695,14 @@ class Migration(migrations.Migration): ...@@ -662,8 +695,14 @@ class Migration(migrations.Migration):
"courses_and_courses_feedback", "courses_and_courses_feedback",
backend_app.fields.JSONField(default=dict), backend_app.fields.JSONField(default=dict),
), ),
("adequation_comment", models.CharField(default="", max_length=5000)), (
("integration_comment", models.CharField(default="", max_length=5000)), "adequation_comment",
models.CharField(blank=True, default="", max_length=5000),
),
(
"integration_comment",
models.CharField(blank=True, default="", max_length=5000),
),
( (
"adequation_grate", "adequation_grate",
models.PositiveIntegerField( models.PositiveIntegerField(
...@@ -698,8 +737,8 @@ class Migration(migrations.Migration): ...@@ -698,8 +737,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -713,7 +752,7 @@ class Migration(migrations.Migration): ...@@ -713,7 +752,7 @@ class Migration(migrations.Migration):
("is_anonymous", models.BooleanField(default=True)), ("is_anonymous", models.BooleanField(default=True)),
("is_public", models.BooleanField(default=False)), ("is_public", models.BooleanField(default=False)),
("order_in_list", models.PositiveIntegerField()), ("order_in_list", models.PositiveIntegerField()),
("comment", models.CharField(default="", max_length=5000)), ("comment", models.CharField(blank=True, default="", max_length=5000)),
( (
"grade", "grade",
models.PositiveIntegerField( models.PositiveIntegerField(
...@@ -735,8 +774,8 @@ class Migration(migrations.Migration): ...@@ -735,8 +774,8 @@ class Migration(migrations.Migration):
verbose_name="ID", verbose_name="ID",
), ),
), ),
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)), ("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
( (
"obj_moderation_level", "obj_moderation_level",
models.SmallIntegerField( models.SmallIntegerField(
...@@ -753,28 +792,6 @@ class Migration(migrations.Migration): ...@@ -753,28 +792,6 @@ class Migration(migrations.Migration):
("title", models.CharField(max_length=200)), ("title", models.CharField(max_length=200)),
], ],
), ),
migrations.CreateModel(
name="Semester",
fields=[
("moderated_on", models.DateTimeField(null=True)),
("updated_on", models.DateTimeField(null=True)),
(
"obj_moderation_level",
models.SmallIntegerField(
default=0,
validators=[
django.core.validators.MinValueValidator(0),
backend_app.models.abstract.my_model.myModel.validate_obj_model_lv,
],
),
),
(
"code",
models.CharField(max_length=6, primary_key=True, serialize=False),
),
],
options={"abstract": False},
),
migrations.CreateModel( migrations.CreateModel(
name="Specialty", name="Specialty",
fields=[ fields=[
...@@ -787,8 +804,8 @@ class Migration(migrations.Migration): ...@@ -787,8 +804,8 @@ class Migration(migrations.Migration):
verbose_name="ID",