Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
23db719f
Commit
23db719f
authored
Jun 07, 2020
by
Maxime Emschwiller
Browse files
feature(backend): Add model and migration
parent
098a9e51
Changes
2
Show whitespace changes
Inline
Side-by-side
backend/stats_app/migrations/0002_auto_20200601_1418.py
0 → 100644
View file @
23db719f
# 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"
)
},
),
]
backend/stats_app/models.py
View file @
23db719f
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"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment