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

update memopol representative model

parent 5b2c9c11
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import models, migrations from django.db import models, migrations
import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
...@@ -15,11 +14,13 @@ class Migration(migrations.Migration): ...@@ -15,11 +14,13 @@ class Migration(migrations.Migration):
migrations.CreateModel( migrations.CreateModel(
name='MemopolRepresentative', name='MemopolRepresentative',
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('representative_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='representatives.Representative')),
('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)),
('score', models.IntegerField(default=0)), ('score', models.IntegerField(default=0)),
('country', models.ForeignKey(to='representatives.Country', null=True)), ('country', models.ForeignKey(to='representatives.Country', null=True)),
], ],
options={
'abstract': False,
},
bases=('representatives.representative',),
), ),
] ]
...@@ -31,22 +31,11 @@ from representatives_votes.models import Vote ...@@ -31,22 +31,11 @@ from representatives_votes.models import Vote
from core.utils import create_child_instance_from_parent from core.utils import create_child_instance_from_parent
class MemopolRepresentative(models.Model): class MemopolRepresentative(Representative):
# 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( # parent_identifier = 'fingerprint'
Representative, # representative_finger = models.CharField(max_length=255, unique=True)
parent_link=True,
related_name='extra',
null=True,
on_delete=models.SET_NULL
)
representative_remote_id = models.CharField(max_length=255, unique=True)
country = models.ForeignKey(Country, null=True) country = models.ForeignKey(Country, null=True)
score = models.IntegerField(default=0) score = models.IntegerField(default=0)
...@@ -117,7 +106,7 @@ class MemopolRepresentative(models.Model): ...@@ -117,7 +106,7 @@ class MemopolRepresentative(models.Model):
@receiver(post_save, sender=Representative) @receiver(post_save, sender=Representative)
def create_memopolrepresentative_from_representative(instance, **kwargs): def create_memopolrepresentative_from_representative(instance, **kwargs):
# create_child_instance_from_parent(MemopolRepresentative, instance) create_child_instance_from_parent(MemopolRepresentative, instance)
pass 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