Anonymize data, fix remittancei import
This commit is contained in:
parent
748ad7eb48
commit
126e5fa1e4
|
@ -0,0 +1,21 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import connection
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Command to protect sensitive data during the beta phase, to prevent a right escalation.
|
||||
Phone number, email address, postal address, first and last name are removed.
|
||||
"""
|
||||
def handle(self, *args, **kwargs):
|
||||
cur = connection.cursor()
|
||||
cur.execute("UPDATE member_profile SET "
|
||||
"phone_number = '0123456789', "
|
||||
"address = '4 avenue des Sciences, 91190 GIF-SUR-YVETTE';")
|
||||
cur.execute("UPDATE auth_user SET "
|
||||
"first_name = 'Anne', "
|
||||
"last_name = 'Onyme';")
|
||||
cur.close()
|
|
@ -110,6 +110,7 @@ class Command(ImportCommand):
|
|||
"phone_number": row['tel'],
|
||||
"address": row['adresse'],
|
||||
"paid": row['normalien'],
|
||||
"section": row["section"],
|
||||
"registration_valid": True,
|
||||
"email_confirmed": True,
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ class Command(ImportCommand):
|
|||
|
||||
remittance_dict = {
|
||||
"pk": pk_remittance,
|
||||
"date": make_aware(row["date"]),
|
||||
"date": make_aware(row["date"][:19]),
|
||||
"remittance_type_id": 1, # Only Bank checks are supported in NK15
|
||||
"comment": row["commentaire"],
|
||||
"closed": row["close"],
|
||||
|
@ -315,6 +315,9 @@ class Command(ImportCommand):
|
|||
for idx, row in enumerate(cur):
|
||||
self.update_line(idx, n, row["nom"])
|
||||
|
||||
if not row["idremise"]:
|
||||
continue
|
||||
|
||||
tr = SpecialTransactionProxy.objects.get(transaction__id=MAP_TRANSACTION[row["idtransaction"]])
|
||||
tr.remittance_id = MAP_REMITTANCE[row["idremise"]]
|
||||
tr.save()
|
||||
|
|
|
@ -14,10 +14,6 @@ class Command(BaseCommand):
|
|||
"""
|
||||
Command to add the ten most used buttons of the past month to the highlighted buttons.
|
||||
"""
|
||||
|
||||
def add_arguments(self, parser):
|
||||
return parser
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
queryset = RecurrentTransaction.objects.filter(
|
||||
template__display=True,
|
||||
|
|
|
@ -11,7 +11,7 @@ from polymorphic.models import PolymorphicModel
|
|||
NO_SEQ = [
|
||||
"Session",
|
||||
"Token",
|
||||
"WEIRole", # dirty fix
|
||||
"WEIRole", # dirty fix
|
||||
]
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -33,10 +33,14 @@ class Command(BaseCommand):
|
|||
# no app specified, sync everything
|
||||
model_classes = apps.get_models(include_auto_created=True)
|
||||
|
||||
db_names = [ m._meta.db_table for m in model_classes if m.__base__.__base__ is not PolymorphicModel and m.__name__ not in NO_SEQ and m.objects.count()>1]
|
||||
db_names = [
|
||||
m._meta.db_table for m in model_classes
|
||||
if m.__base__.__base__ is not PolymorphicModel and m.__name__ not in NO_SEQ and m.objects.count() > 1
|
||||
]
|
||||
com = "BEGIN;\n"
|
||||
for db_name in db_names:
|
||||
com += f'SELECT setval(pg_get_serial_sequence(\'"{db_name}"\',\'id\'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "{db_name}";\n'
|
||||
com += f'SELECT setval(pg_get_serial_sequence(\'"{db_name}"\',\'id\'), coalesce(max("id"), 1),' \
|
||||
f' max("id") IS NOT null) FROM "{db_name}";\n'
|
||||
com += "COMMIT;"
|
||||
print(com)
|
||||
cur = connection.cursor()
|
||||
|
|
Loading…
Reference in New Issue