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
memopol
Commits
615d5edc
Commit
615d5edc
authored
Jul 01, 2015
by
Arnaud Fabre
Browse files
update memopol representative model
parent
5b2c9c11
Changes
2
Hide whitespace changes
Inline
Side-by-side
legislature/migrations/0001_initial.py
View file @
615d5edc
...
...
@@ -2,7 +2,6 @@
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
...
...
@@ -15,11 +14,13 @@ class Migration(migrations.Migration):
migrations
.
CreateModel
(
name
=
'MemopolRepresentative'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
,
primary_key
=
True
)),
(
'representative'
,
models
.
OneToOneField
(
parent_link
=
True
,
related_name
=
'extra'
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
'representatives.Representative'
)),
(
'representative_remote_id'
,
models
.
CharField
(
unique
=
True
,
max_length
=
255
)),
(
'representative_ptr'
,
models
.
OneToOneField
(
parent_link
=
True
,
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'representatives.Representative'
)),
(
'score'
,
models
.
IntegerField
(
default
=
0
)),
(
'country'
,
models
.
ForeignKey
(
to
=
'representatives.Country'
,
null
=
True
)),
],
options
=
{
'abstract'
:
False
,
},
bases
=
(
'representatives.representative'
,),
),
]
legislature/models.py
View file @
615d5edc
...
...
@@ -31,22 +31,11 @@ from representatives_votes.models import Vote
from
core.utils
import
create_child_instance_from_parent
class
MemopolRepresentative
(
models
.
Model
):
# We should link a memopol representative to a representative based
# on the remote_id attribute
parent_identifier
=
'remote_id'
child_parent_identifier
=
'representative_remote_id'
class
MemopolRepresentative
(
Representative
):
representative
=
models
.
OneToOneField
(
Representative
,
parent_link
=
True
,
related_name
=
'extra'
,
null
=
True
,
on_delete
=
models
.
SET_NULL
)
# parent_identifier = 'fingerprint'
# representative_finger = models.CharField(max_length=255, unique=True)
representative_remote_id
=
models
.
CharField
(
max_length
=
255
,
unique
=
True
)
country
=
models
.
ForeignKey
(
Country
,
null
=
True
)
score
=
models
.
IntegerField
(
default
=
0
)
...
...
@@ -117,7 +106,7 @@ class MemopolRepresentative(models.Model):
@
receiver
(
post_save
,
sender
=
Representative
)
def
create_memopolrepresentative_from_representative
(
instance
,
**
kwargs
):
#
create_child_instance_from_parent(MemopolRepresentative, instance)
create_child_instance_from_parent
(
MemopolRepresentative
,
instance
)
pass
...
...
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