Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
5d3f4fb8
Commit
5d3f4fb8
authored
Oct 19, 2017
by
Tom van Bussel
Browse files
Add a missing migration in the education app
parent
9657cf64
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/education/migrations/0007_rename_answers_type.py
0 → 100644
View file @
5d3f4fb8
from
django.db
import
migrations
,
models
def
forwards_func
(
apps
,
schema_editor
):
Exam
=
apps
.
get_model
(
'education'
,
'Exam'
)
for
exam
in
Exam
.
objects
.
all
():
if
exam
.
type
==
'answers'
:
exam
.
type
=
'exam_answers'
exam
.
save
(
update_fields
=
(
'type'
,))
def
reverse_func
(
apps
,
schema_editor
):
Exam
=
apps
.
get_model
(
'education'
,
'Exam'
)
for
exam
in
Exam
.
objects
.
all
():
if
exam
.
type
in
[
'exam_answers'
,
'partial_answers'
,
'resit_answers'
,
'practice_answers'
]:
exam
.
type
=
'answers'
exam
.
save
(
update_fields
=
(
'type'
,))
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
# Without this dependency we get multiple leaf nodes
(
'education'
,
'0006_auto_20171013_1535'
),
# The real dependency
(
'education'
,
'0005_auto_20170906_2109'
),
]
operations
=
[
migrations
.
RunPython
(
forwards_func
,
reverse_func
),
]
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment