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

updates to django 1.7

parent 1850d5e9
Branches
Étiquettes
Aucune requête de fusion associée trouvée
import json
from urllib2 import urlopen
from django.core.management.base import BaseCommand
from representatives.utils import import_representatives_from_format
from django.conf import settings
from representatives.utils import import_representatives_from_format
class Command(BaseCommand):
def handle(self, *args, **options):
import_representatives_from_format(json.load(urlopen("http://compotista.mm.staz.be/latest/")), verbose=True)
compotista_server = getattr(settings, 'REPRESENTATIVES_COMPOTISTA_SERVER', 'http://compotista.mm.staz.be')
import_representatives_from_format(json.load(urlopen(compotista_server + "/latest/")), verbose=True)
......@@ -8,7 +8,7 @@ class Country(models.Model):
code = models.CharField(max_length=2)
def __unicode__(self):
return "%s - %s" % (self.name, self.code)
return "%s [%s]" % (self.name, self.code)
class Representative(models.Model):
......@@ -35,6 +35,9 @@ class Representative(models.Model):
cv = models.TextField(blank=True, null=True)
photo = models.CharField(max_length=512, null=True)
def __unicode__(self):
return self.full_name
class Contact(models.Model):
representative = models.ForeignKey(Representative)
......
......@@ -56,7 +56,8 @@ def import_representatives_from_format(data, verbose=False):
reverted_gender_dict = {x[1]: x[0] for x in Representative.GENDER}
a = 0
end = len(data)
with transaction.commit_on_success():
with transaction.atomic():
for reps in data:
a += 1
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