Commit 23db719f authored by Maxime Emschwiller's avatar Maxime Emschwiller
Browse files

feature(backend): Add model and migration

parent 098a9e51
# Generated by Django 2.1.7 on 2020-06-01 12:18
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("backend_app", "0005_lastvisiteduniversity"),
("stats_app", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="DailyExchangeContributionsInfo",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("date", models.DateTimeField()),
("major", models.CharField(blank=True, max_length=20)),
("minor", models.CharField(blank=True, max_length=47)),
("exchange_semester", models.CharField(max_length=5)),
(
"nb_contributions",
models.IntegerField(
validators=[django.core.validators.MinValueValidator(0)]
),
),
(
"university",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="backend_app.University",
),
),
],
),
migrations.AlterUniqueTogether(
name="dailyexchangecontributionsinfo",
unique_together={
("date", "university", "major", "minor", "exchange_semester")
},
),
]
from django.db import models
from django.core.validators import MinValueValidator
from backend_app.models.university import University
class DailyConnections(models.Model):
date = models.DateTimeField(unique=True, null=False)
nb_connections = models.IntegerField(validators=[MinValueValidator(0)], null=False)
class DailyExchangeContributionsInfo(models.Model):
date = models.DateTimeField(null=False)
university = models.ForeignKey(University, null=False, on_delete=models.CASCADE)
major = models.CharField(max_length=20, null=False, blank=True)
minor = models.CharField(max_length=47, null=False, blank=True)
exchange_semester = models.CharField(max_length=5, null=False)
nb_contributions = models.IntegerField(
validators=[MinValueValidator(0)], null=False
)
class Meta:
unique_together = ("date", "university", "major", "minor", "exchange_semester")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment