Compare commits

...

2 Commits

Author SHA1 Message Date
Yohann D'ANELLO 03dc6f98c8 Section is not importable yet 2020-07-26 12:11:13 +02:00
Yohann D'ANELLO 126e5fa1e4 Anonymize data, fix remittancei import 2020-07-26 12:05:26 +02:00
4 changed files with 32 additions and 8 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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,

View File

@ -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()