mirror of
https://gitlab.crans.org/bde/nk20-scripts
synced 2024-11-26 18:37:15 +00:00
Compare commits
No commits in common. "03dc6f98c8cb8eb3879914366eca89a23b9a644a" and "748ad7eb4813f2bb2f273a5e29cadeda1d58c3a1" have entirely different histories.
03dc6f98c8
...
748ad7eb48
@ -1,21 +0,0 @@
|
|||||||
# 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()
|
|
@ -295,7 +295,7 @@ class Command(ImportCommand):
|
|||||||
|
|
||||||
remittance_dict = {
|
remittance_dict = {
|
||||||
"pk": pk_remittance,
|
"pk": pk_remittance,
|
||||||
"date": make_aware(row["date"][:19]),
|
"date": make_aware(row["date"]),
|
||||||
"remittance_type_id": 1, # Only Bank checks are supported in NK15
|
"remittance_type_id": 1, # Only Bank checks are supported in NK15
|
||||||
"comment": row["commentaire"],
|
"comment": row["commentaire"],
|
||||||
"closed": row["close"],
|
"closed": row["close"],
|
||||||
@ -315,9 +315,6 @@ class Command(ImportCommand):
|
|||||||
for idx, row in enumerate(cur):
|
for idx, row in enumerate(cur):
|
||||||
self.update_line(idx, n, row["nom"])
|
self.update_line(idx, n, row["nom"])
|
||||||
|
|
||||||
if not row["idremise"]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
tr = SpecialTransactionProxy.objects.get(transaction__id=MAP_TRANSACTION[row["idtransaction"]])
|
tr = SpecialTransactionProxy.objects.get(transaction__id=MAP_TRANSACTION[row["idtransaction"]])
|
||||||
tr.remittance_id = MAP_REMITTANCE[row["idremise"]]
|
tr.remittance_id = MAP_REMITTANCE[row["idremise"]]
|
||||||
tr.save()
|
tr.save()
|
||||||
|
@ -14,6 +14,10 @@ class Command(BaseCommand):
|
|||||||
"""
|
"""
|
||||||
Command to add the ten most used buttons of the past month to the highlighted buttons.
|
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):
|
def handle(self, *args, **kwargs):
|
||||||
queryset = RecurrentTransaction.objects.filter(
|
queryset = RecurrentTransaction.objects.filter(
|
||||||
template__display=True,
|
template__display=True,
|
||||||
|
@ -11,7 +11,7 @@ from polymorphic.models import PolymorphicModel
|
|||||||
NO_SEQ = [
|
NO_SEQ = [
|
||||||
"Session",
|
"Session",
|
||||||
"Token",
|
"Token",
|
||||||
"WEIRole", # dirty fix
|
"WEIRole", # dirty fix
|
||||||
]
|
]
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@ -33,14 +33,10 @@ class Command(BaseCommand):
|
|||||||
# no app specified, sync everything
|
# no app specified, sync everything
|
||||||
model_classes = apps.get_models(include_auto_created=True)
|
model_classes = apps.get_models(include_auto_created=True)
|
||||||
|
|
||||||
db_names = [
|
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]
|
||||||
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"
|
com = "BEGIN;\n"
|
||||||
for db_name in db_names:
|
for db_name in db_names:
|
||||||
com += f'SELECT setval(pg_get_serial_sequence(\'"{db_name}"\',\'id\'), coalesce(max("id"), 1),' \
|
com += f'SELECT setval(pg_get_serial_sequence(\'"{db_name}"\',\'id\'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "{db_name}";\n'
|
||||||
f' max("id") IS NOT null) FROM "{db_name}";\n'
|
|
||||||
com += "COMMIT;"
|
com += "COMMIT;"
|
||||||
print(com)
|
print(com)
|
||||||
cur = connection.cursor()
|
cur = connection.cursor()
|
||||||
|
Loading…
Reference in New Issue
Block a user