use Note Parent Polymorphic id for consistency

This commit is contained in:
Pierre-antoine Comby 2020-04-18 16:02:49 +02:00
parent fa0ac58999
commit 11e8b66a5d
1 changed files with 4 additions and 4 deletions

View File

@ -18,8 +18,8 @@ from django.db import IntegrityError
from django.contrib.auth.models import User from django.contrib.auth.models import User
from note.models import Note, NoteSpecial, NoteUser, NoteClub from note.models import Note, NoteSpecial, NoteUser, NoteClub
from note.models import Alias from note.models import Alias
from note.models import Transaction, TransactionTemplate,\ from note.models import TemplateCategory, TransactionTemplate,\
TemplateCategory, RecurrentTransaction, MembershipTransaction Transaction, RecurrentTransaction, MembershipTransaction, SpecialTransaction
from member.models import Profile, Club, Membership from member.models import Profile, Club, Membership
""" """
@ -115,7 +115,7 @@ def import_comptes(cur):
club.save() club.save()
note.save() note.save()
MAP_IDBDE[row["idbde"]] = note.pk MAP_IDBDE[row["idbde"]] = note.note_ptr_id
@transaction.atomic @transaction.atomic
def import_boutons(cur): def import_boutons(cur):
@ -141,7 +141,7 @@ def import_boutons(cur):
except IntegrityError as e: except IntegrityError as e:
# button with the same name is not possible in NK20. # button with the same name is not possible in NK20.
if "unique" in e.args[0]: if "unique" in e.args[0]:
qs = Club.objects.filter(note__id=MAP_IDBDE[row["destinataire"]]).values('name') qs = Club.objects.filter(note__note_ptr=MAP_IDBDE[row["destinataire"]]).values('name')
note_name = qs[0]["name"] note_name = qs[0]["name"]
#rename button name #rename button name
obj_dict["name"] ="{} {}".format(obj_dict["name"],note_name) obj_dict["name"] ="{} {}".format(obj_dict["name"],note_name)