fix integrity error
This commit is contained in:
parent
a088c6baea
commit
123466cfa9
|
@ -8,6 +8,7 @@ import psycopg2.extras as pge
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.timezone import make_aware
|
from django.utils.timezone import make_aware
|
||||||
|
@ -28,6 +29,10 @@ TODO: import activite
|
||||||
TODO: import ...
|
TODO: import ...
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
M_DURATION = timedelta(days=396)
|
||||||
|
M_START = timedelta(days=213)
|
||||||
|
M_END = timedelta(days=273)
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def import_special(cur):
|
def import_special(cur):
|
||||||
cur.execute("SELECT * FROM comptes WHERE idbde <0 ORDER BY idbde;")
|
cur.execute("SELECT * FROM comptes WHERE idbde <0 ORDER BY idbde;")
|
||||||
|
@ -45,17 +50,17 @@ def import_special(cur):
|
||||||
clubBde, c = Club.objects.get_or_create(pk = 1,
|
clubBde, c = Club.objects.get_or_create(pk = 1,
|
||||||
name = "Bde",
|
name = "Bde",
|
||||||
email = "bureau.bde@lists.crans.org",
|
email = "bureau.bde@lists.crans.org",
|
||||||
membership_duration = "396 00:00:00",
|
membership_duration = M_DURATION,
|
||||||
membership_start = "213 00:00:00",
|
membership_start = M_START,
|
||||||
membership_end = "273 00:00:00",
|
membership_end = M_END,
|
||||||
membership_fee = 5,
|
membership_fee = 5,
|
||||||
)
|
)
|
||||||
clubKfet, c = Club.objects.get_or_create(pk = 2,
|
clubKfet, c = Club.objects.get_or_create(pk = 2,
|
||||||
name = "Kfet",
|
name = "Kfet",
|
||||||
email = "tresorerie.bde@lists.crans.org",
|
email = "tresorerie.bde@lists.crans.org",
|
||||||
membership_duration = "396 00:00:00",
|
membership_duration = M_DURATION,
|
||||||
membership_start = "213 00:00:00",
|
membership_start = M_START,
|
||||||
membership_end = "273 00:00:00",
|
membership_end = M_END,
|
||||||
membership_fee = 35,
|
membership_fee = 35,
|
||||||
)
|
)
|
||||||
clubBde.save()
|
clubBde.save()
|
||||||
|
@ -93,15 +98,12 @@ def import_comptes(cur,map_idbde):
|
||||||
user = User.objects.create(**obj_dict)
|
user = User.objects.create(**obj_dict)
|
||||||
else:
|
else:
|
||||||
raise(e)
|
raise(e)
|
||||||
else:
|
# profile and note created via signal.
|
||||||
pass
|
profile = user.profile
|
||||||
obj_dict ={
|
profile.phone_number = row["tel"]
|
||||||
"phone_number": row["tel"],
|
profile.address = row["adresse"]
|
||||||
"address": row["adresse"],
|
profile.paid = row["normalien"]
|
||||||
"paid": row["normalien"],
|
|
||||||
"user": user,
|
|
||||||
}
|
|
||||||
profile = Profile.objects.create(**obj_dict)
|
|
||||||
note = user.note
|
note = user.note
|
||||||
date = row.get("last_negatif",None)
|
date = row.get("last_negatif",None)
|
||||||
if date != None:
|
if date != None:
|
||||||
|
@ -113,9 +115,9 @@ def import_comptes(cur,map_idbde):
|
||||||
"pk":pkclub,
|
"pk":pkclub,
|
||||||
"name": row["pseudo"],
|
"name": row["pseudo"],
|
||||||
"email": row["mail"],
|
"email": row["mail"],
|
||||||
"membership_duration": "396 00:00:00",
|
"membership_duration": M_DURATION,
|
||||||
"membership_start": "213 00:00:00",
|
"membership_start": M_START,
|
||||||
"membership_end": "273 00:00:00",
|
"membership_end": M_END,
|
||||||
"membership_fee": 0,
|
"membership_fee": 0,
|
||||||
}
|
}
|
||||||
club,c = Club.objects.get_or_create(**obj_dict)
|
club,c = Club.objects.get_or_create(**obj_dict)
|
||||||
|
@ -184,9 +186,9 @@ def import_transaction(cur, map_idbde):
|
||||||
transac = TemplateTransaction.objects.create(**obj_dict)
|
transac = TemplateTransaction.objects.create(**obj_dict)
|
||||||
transac.save()
|
transac.save()
|
||||||
elif row["type"] == "adhésion":
|
elif row["type"] == "adhésion":
|
||||||
|
print("adhesion not supported yet")
|
||||||
else:
|
else:
|
||||||
|
print("other type not supported yet")
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
|
Loading…
Reference in New Issue