Commit 615d5edc authored by Arnaud Fabre's avatar Arnaud Fabre

update memopol representative model

parent 5b2c9c11
......@@ -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',),
),
]
......@@ -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'
representative = models.OneToOneField(
Representative,
parent_link=True,
related_name='extra',
null=True,
on_delete=models.SET_NULL
)
class MemopolRepresentative(Representative):
# 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment