Skip to content
Extraits de code Groupes Projets
Valider 615d5edc rédigé par Arnaud Fabre's avatar Arnaud Fabre
Parcourir les fichiers

update memopol representative model

parent 5b2c9c11
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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'
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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter