Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
ce20715c
Unverified
Commit
ce20715c
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add SchoolRelated mixin model and link Person and Group to school.
Advances
#19
.
parent
6b6fe963
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
biscuit/core/migrations/0008_school_person_group.py
+44
-0
44 additions, 0 deletions
biscuit/core/migrations/0008_school_person_group.py
biscuit/core/mixins.py
+8
-0
8 additions, 0 deletions
biscuit/core/mixins.py
biscuit/core/models.py
+12
-4
12 additions, 4 deletions
biscuit/core/models.py
with
64 additions
and
4 deletions
biscuit/core/migrations/0008_school_person_group.py
0 → 100644
+
44
−
0
View file @
ce20715c
# Generated by Django 2.2.3 on 2019-07-28 20:52
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
core
'
,
'
0007_school
'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'
group
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
1
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
preserve_default
=
False
,
),
migrations
.
AddField
(
model_name
=
'
person
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
1
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
preserve_default
=
False
,
),
migrations
.
AlterField
(
model_name
=
'
person
'
,
name
=
'
import_ref
'
,
field
=
models
.
CharField
(
blank
=
True
,
editable
=
False
,
max_length
=
64
,
verbose_name
=
'
Reference ID of import source
'
),
),
migrations
.
AlterField
(
model_name
=
'
person
'
,
name
=
'
short_name
'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
5
,
verbose_name
=
'
Short name
'
),
),
migrations
.
AlterUniqueTogether
(
name
=
'
group
'
,
unique_together
=
{(
'
school
'
,
'
short_name
'
),
(
'
school
'
,
'
name
'
)},
),
migrations
.
AlterUniqueTogether
(
name
=
'
person
'
,
unique_together
=
{(
'
school
'
,
'
short_name
'
),
(
'
school
'
,
'
import_ref
'
)},
),
]
This diff is collapsed.
Click to expand it.
biscuit/core/mixins.py
0 → 100644
+
8
−
0
View file @
ce20715c
from
django.db
import
models
class
SchoolRelated
(
models
.
Model
):
class
Meta
:
abstract
=
True
school
=
models
.
ForeignKey
(
'
core.School
'
,
on_delete
=
models
.
CASCADE
)
This diff is collapsed.
Click to expand it.
biscuit/core/models.py
+
12
−
4
View file @
ce20715c
...
...
@@ -3,6 +3,8 @@ from django.utils.translation import gettext_lazy as _
from
phonenumber_field.modelfields
import
PhoneNumberField
from
.mixins
import
SchoolRelated
class
School
(
models
.
Model
):
name
=
models
.
CharField
(
verbose_name
=
_
(
'
Name
'
),
max_length
=
30
)
...
...
@@ -10,7 +12,10 @@ class School(models.Model):
'
Official name of the school, e.g. as given by supervisory authority
'
))
class
Person
(
models
.
Model
):
class
Person
(
SchoolRelated
):
class
Meta
:
unique_together
=
[[
'
school
'
,
'
short_name
'
],
[
'
school
'
,
'
import_ref
'
]]
SEX_CHOICES
=
[
(
'
f
'
,
_
(
'
female
'
)),
(
'
m
'
,
_
(
'
male
'
))
...
...
@@ -25,7 +30,7 @@ class Person(models.Model):
'
Additional name(s)
'
),
max_length
=
30
,
blank
=
True
)
short_name
=
models
.
CharField
(
verbose_name
=
_
(
'
Short name
'
),
max_length
=
5
,
blank
=
True
,
unique
=
True
)
'
Short name
'
),
max_length
=
5
,
blank
=
True
)
street
=
models
.
CharField
(
verbose_name
=
_
(
'
Street
'
),
max_length
=
30
,
blank
=
True
)
...
...
@@ -50,7 +55,7 @@ class Person(models.Model):
photo
=
models
.
ImageField
(
verbose_name
=
_
(
'
Photo
'
),
blank
=
True
,
null
=
True
)
import_ref
=
models
.
CharField
(
verbose_name
=
_
(
'
Reference ID of import source
'
),
max_length
=
64
,
blank
=
True
,
unique
=
True
,
editable
=
False
)
'
Reference ID of import source
'
),
max_length
=
64
,
blank
=
True
,
editable
=
False
)
guardians
=
models
.
ManyToManyField
(
'
self
'
,
verbose_name
=
_
(
'
Guardians / Parents
'
),
symmetrical
=
False
,
related_name
=
'
children
'
)
...
...
@@ -59,7 +64,10 @@ class Person(models.Model):
return
'
%s, %s
'
%
(
self
.
last_name
,
self
.
first_name
)
class
Group
(
models
.
Model
):
class
Group
(
SchoolRelated
):
class
Meta
:
unique_together
=
[[
'
school
'
,
'
name
'
],
[
'
school
'
,
'
short_name
'
]]
name
=
models
.
CharField
(
verbose_name
=
_
(
'
Long name of group
'
),
max_length
=
30
,
unique
=
True
)
short_name
=
models
.
CharField
(
verbose_name
=
_
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment