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
Political Memory
django-representatives
Commits
178f5053
Commit
178f5053
authored
Jun 24, 2016
by
Nicolas Joyard
Browse files
Fix mandate.role field length + constituency fingerprint
parent
7e361a9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
representatives/migrations/0017_auto_20160623_2201.py
0 → 100644
View file @
178f5053
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
def
migrate_constituencies
(
apps
,
schema_editor
):
"""
Re-save constituencies to recompute fingerprints
"""
Constituency
=
apps
.
get_model
(
"representatives"
,
"Constituency"
)
for
c
in
Constituency
.
objects
.
all
():
c
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'representatives'
,
'0016_chamber_migrate_data'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'mandate'
,
name
=
'role'
,
field
=
models
.
CharField
(
default
=
b
''
,
help_text
=
b
'Eg.: president of a political group'
,
max_length
=
255
,
blank
=
True
),
),
migrations
.
RunPython
(
migrate_constituencies
)
]
representatives/models.py
View file @
178f5053
...
...
@@ -201,7 +201,7 @@ class Constituency(HashableModel, TimeStampedModel):
country
=
models
.
ForeignKey
(
'Country'
,
null
=
True
,
blank
=
True
,
related_name
=
'constituencies'
)
hashable_fields
=
[
'name'
]
hashable_fields
=
[
'name'
,
'country'
]
@
cached_property
def
active
(
self
):
...
...
@@ -230,7 +230,7 @@ class Mandate(HashableModel, TimeStampedModel):
Constituency
,
null
=
True
,
related_name
=
'mandates'
)
representative
=
models
.
ForeignKey
(
Representative
,
related_name
=
'mandates'
)
role
=
models
.
CharField
(
max_length
=
25
,
max_length
=
25
5
,
blank
=
True
,
default
=
''
,
help_text
=
"Eg.: president of a political group"
...
...
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