Skip to content
Extraits de code Groupes Projets
Valider b7f45e45 rédigé par luxcem's avatar luxcem
Parcourir les fichiers

Removes memopol operations

parent 1ea7c6ba
Branches
Étiquettes
Aucune requête de fusion associée trouvée
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('representatives', '0004_representative_country'),
]
operations = [
migrations.RemoveField(
model_name='representative',
name='active',
),
migrations.RemoveField(
model_name='representative',
name='country',
),
]
......@@ -29,28 +29,12 @@ class Representative(models.Model):
birth_date = models.DateField(blank=True, null=True)
cv = models.TextField(blank=True, null=True)
photo = models.CharField(max_length=512, null=True)
active = models.BooleanField(default=False)
country = models.ForeignKey(Country, null=True)
def active_mandates(self):
return self.mandate_set.filter(active=True)
def former_mandates(self):
return self.mandate_set.filter(active=False)
def current_group(self):
return self.mandate_set.get(
active=True,
group__kind='group'
)
def __unicode__(self):
return self.full_name
# Contact related models
class Contact(models.Model):
representative = models.ForeignKey(Representative)
......
......@@ -174,19 +174,6 @@ def import_representatives_from_format(data, verbose=False):
active=mandate["current"],
)
# Create a country if it does not exist
# The representative's country is the one associated
# with the last 'country' mandate
country_mandate = representative.mandate_set.filter(
group__kind='country'
).order_by('-begin_date')[0:1].get()
country, created = Country.objects.get_or_create(
name=country_mandate.group.name,
code=country_mandate.group.abbreviation
)
representative.country = country
representative.save()
if verbose:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter