Compare commits
No commits in common. "6cfae5fd69deb8beccb342cb589c6d8c594cf1b8" and "dc1daf0a2ddd6a74be0f2c06473a6ad16596d10b" have entirely different histories.
6cfae5fd69
...
dc1daf0a2d
|
@ -44,14 +44,14 @@ class ImportCommand(BaseCommand):
|
|||
n = str(n)
|
||||
total = str(total)
|
||||
n.rjust(len(total))
|
||||
print(f"\r ({n}/{total}) {content:16.16}", end="")
|
||||
print(f"\r ({n}/{total}) {content:10.10}", end="")
|
||||
|
||||
def create_parser(self, prog_name, subcommand, **kwargs):
|
||||
parser = super().create_parser(prog_name, subcommand, **kwargs)
|
||||
parser.add_argument('--nk15db', action='store', default='nk15', help='NK15 database name')
|
||||
parser.add_argument('--nk15user', action='store', default='nk15_user', help='NK15 database owner')
|
||||
parser.add_argument('-s', '--save', default='map.json', action='store', help="save mapping of idbde")
|
||||
parser.add_argument('-m', '--map', default='map.json', action='store', help="import mapping of idbde")
|
||||
parser.add_argument('-s', '--save', action='store', help="save mapping of idbde")
|
||||
parser.add_argument('-m', '--map', action='store', help="import mapping of idbde")
|
||||
parser.add_argument('-c', '--chunk', type=int, default=100, help="chunk size for bulk_create")
|
||||
return parser
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.db import transaction
|
|||
|
||||
from activity.models import ActivityType, Activity, Guest, Entry
|
||||
from member.models import Club
|
||||
from note.models import Note, NoteUser
|
||||
from note.models import Note
|
||||
from ._import_utils import ImportCommand, BulkCreateManager, timed
|
||||
|
||||
MAP_ACTIVITY = dict()
|
||||
|
@ -22,10 +22,6 @@ CLUB_RELOU = [
|
|||
5164, #S & L
|
||||
625, #Aspique
|
||||
5154, #Frekens
|
||||
3944, # DiskJok[ENS]
|
||||
5153, # Monopo[list]
|
||||
2351, # JdRM
|
||||
2365, # Pot Vieux
|
||||
]
|
||||
|
||||
class Command(ImportCommand):
|
||||
|
@ -44,13 +40,11 @@ class Command(ImportCommand):
|
|||
pk_activity = 1
|
||||
for idx, row in enumerate(cur):
|
||||
self.update_line(idx, n, row["titre"])
|
||||
if row["responsable"] in CLUB_RELOU:
|
||||
row["responsable"] = 3508
|
||||
note = self.MAP_IDBDE[row["responsable"]]
|
||||
if note == 6244:
|
||||
# Licorne magique ne doit pas utiliser son compte club pour proposer des activités
|
||||
note = Note.objects.get(pk=self.MAP_IDBDE[6524])
|
||||
note = note.id
|
||||
note = note.user_id
|
||||
organizer = Club.objects.filter(name=row["signature"])
|
||||
if organizer.exists():
|
||||
# Try to find the club that organizes the activity.
|
||||
|
@ -63,7 +57,7 @@ class Command(ImportCommand):
|
|||
"name": row["titre"],
|
||||
"description": row["description"],
|
||||
"activity_type_id": activity_type_id, # By default Pot
|
||||
"creater_id": NoteUser.objects.get(pk=note).user.id,
|
||||
"creater_id": note,
|
||||
"organizer_id": organizer.pk,
|
||||
"attendees_club_id": kfet.pk, # Maybe fix manually
|
||||
"date_start": make_aware(row["debut"]),
|
||||
|
|
|
@ -4,9 +4,7 @@ import subprocess
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.core.management import call_command
|
||||
|
||||
from ._import_utils import ImportCommand
|
||||
|
||||
class Command(ImportCommand):
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Command for importing the database of NK15.
|
||||
Need to be run by a user with a registered role in postgres for the database nk15.
|
||||
|
@ -14,22 +12,8 @@ class Command(ImportCommand):
|
|||
|
||||
def handle(self, *args, **kwargs):
|
||||
subprocess.call("./apps/scripts/shell/tabularasa")
|
||||
|
||||
kwargs["alias"] = True
|
||||
kwargs["chunk"] = 1000
|
||||
kwargs["save"] = "map.json"
|
||||
call_command('import_account', **kwargs)
|
||||
|
||||
del kwargs["alias"]
|
||||
del kwargs["save"]
|
||||
kwargs["chunk"] = 100
|
||||
kwargs["map"] = "map.json"
|
||||
call_command('import_activities', **kwargs)
|
||||
|
||||
kwargs["chunk"] = 10000
|
||||
kwargs["map"] = "map.json"
|
||||
kwargs["buttons"] = True
|
||||
call_command('import_transaction', **kwargs)
|
||||
|
||||
call_command('import_account', alias=True, chunk=5000, save = "map.json")
|
||||
call_command('import_activities', chunk=5000, map="map.json")
|
||||
call_command('import_transaction', chunk=5000, buttons=True, map="map.json")
|
||||
call_command('make_su','-sS', 'Coq', 'erdnaxe', 'PAC', 'Pollion', 'ÿnérant')
|
||||
call_command('syncsql')
|
||||
|
|
|
@ -20,7 +20,7 @@ from note.models import (TemplateCategory,
|
|||
from note.models import Note, NoteClub
|
||||
from activity.models import Guest, GuestTransaction
|
||||
|
||||
from member.models import Membership, MembershipTransaction, Role
|
||||
from member.models import Membership
|
||||
from ._import_utils import ImportCommand, BulkCreateManager, timed
|
||||
|
||||
# from member/fixtures/initial
|
||||
|
@ -63,7 +63,7 @@ class Command(ImportCommand):
|
|||
parser.add_argument('-t', '--transactions', action='store', default=0, help="start id for transaction import")
|
||||
|
||||
@timed
|
||||
def import_buttons(self, cur, chunk_size, import_buttons):
|
||||
def import_buttons(self, cur, chunk_size):
|
||||
self.categories = dict()
|
||||
self.buttons = dict()
|
||||
bulk_mgr = BulkCreateManager(chunk_size=chunk_size)
|
||||
|
@ -72,7 +72,7 @@ class Command(ImportCommand):
|
|||
for idx, row in enumerate(cur):
|
||||
self.update_line(idx, n, row["label"])
|
||||
if row["categorie"] not in self.categories:
|
||||
cat = TemplateCategory.objects.get_or_create(name=row["categorie"])[0]
|
||||
cat = TemplateCategory.objects.create(name=row["categorie"])
|
||||
cat.save()
|
||||
self.categories[row["categorie"]] = cat.pk
|
||||
obj_dict = {
|
||||
|
@ -86,7 +86,6 @@ class Command(ImportCommand):
|
|||
}
|
||||
if row["label"] in self.buttons:
|
||||
obj_dict["name"] = f"{obj_dict['name']}_{obj_dict['destination_id']}"
|
||||
if import_buttons:
|
||||
bulk_mgr.add(TransactionTemplate(**obj_dict))
|
||||
self.buttons[obj_dict["name"]] = (row["id"], self.categories[row["categorie"]])
|
||||
bulk_mgr.done()
|
||||
|
@ -149,8 +148,6 @@ class Command(ImportCommand):
|
|||
m = re.search(r"Invitation (.*?)(?:\s\()(.*?)\s(.*?)\)", row["description"])
|
||||
if m:
|
||||
first_name, last_name = m.group(2), m.group(3)
|
||||
if first_name == "Marion" and last_name == "Bizu Pose":
|
||||
first_name, last_name = "Marion Bizu", "Pose"
|
||||
guest_id = Guest.objects.filter(first_name__iexact=first_name,
|
||||
last_name__iexact=last_name).first().pk
|
||||
child_dict["guest_id"] = guest_id
|
||||
|
@ -182,9 +179,6 @@ class Command(ImportCommand):
|
|||
except (pytz.NonExistentTimeError, pytz.AmbiguousTimeError):
|
||||
date = make_aware(row["transac_date"] + datetime.timedelta(hours=1))
|
||||
|
||||
if len(row["description"]) > 255:
|
||||
row["description"] = row["description"][:252] + "..."
|
||||
|
||||
# standart transaction object
|
||||
obj_dict = {
|
||||
"pk": pk_transaction,
|
||||
|
@ -288,6 +282,6 @@ class Command(ImportCommand):
|
|||
|
||||
if kwargs["map"]:
|
||||
self.load_map(kwargs["map"])
|
||||
self.import_buttons(cur, kwargs["chunk"], kwargs["buttons"])
|
||||
self.import_transaction(cur, kwargs["chunk"], kwargs["transactions"])
|
||||
self.import_buttons(cur, kwargs["chunk"])
|
||||
self.import_transaction(cur, kwargs["chunk"], 0)
|
||||
self.set_roles()
|
||||
|
|
Loading…
Reference in New Issue