1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2025-02-24 00:51:25 +00:00

Compare commits

..

No commits in common. "0c7070aea177e12fae099488e2ea6f8146b97e4d" and "5ce65e36a8665ad2388190851db66e82abeb4c05" have entirely different histories.

4 changed files with 13 additions and 20 deletions

View File

@ -10,16 +10,7 @@ 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 add_arguments(self, parser):
parser.add_argument('--force', '-f', action='store_true', help="Actually anonymize data.")
def handle(self, *args, **kwargs):
if not kwargs['force']:
self.stderr.write("CAUTION: This is a dangerous script. This will reset all personal data with "
"sample data. Don't use this in production! If you know what you are doing, "
"please add --force option.")
exit(1)
cur = connection.cursor()
cur.execute("UPDATE member_profile SET "
"phone_number = '0123456789', "

View File

@ -1,6 +1,6 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.core.mail import send_mail
from django.core.management import BaseCommand
from django.db.models import Sum, F
@ -14,6 +14,7 @@ class Command(BaseCommand):
parser.add_argument('--check-all', '-a', action='store_true', help='Check all notes')
parser.add_argument('--check', '-c', type=int, nargs='+', help='Select note ids')
parser.add_argument('--fix', '-f', action='store_true', help='Fix note balances')
parser.add_argument('--mail', '-m', action='store_true', help='Send mail to admins if there is an error')
def handle(self, *args, **options):
error = False

View File

@ -1,6 +1,5 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
import os
from django.conf import settings
@ -13,6 +12,9 @@ class Command(BaseCommand):
"""
Generate Javascript translation files
"""
def add_arguments(self, parser):
parser.add_argument('--out', '-o', type=str, default='static', help='Output directory, where static files are.')
def handle(self, *args, **kwargs):
for code, _ in settings.LANGUAGES:
if code == settings.LANGUAGE_CODE:
@ -21,7 +23,7 @@ class Command(BaseCommand):
self.stdout.write(f"Generate {code} javascript localization file")
with translation.override(code):
resp = JavaScriptCatalog().get(None, packages="member+note")
if not os.path.isdir(settings.STATIC_ROOT + "/js/jsi18n"):
os.makedirs(settings.STATIC_ROOT + "/js/jsi18n")
with open(settings.STATIC_ROOT + f"/js/jsi18n/{code}.js", "wb") as f:
if not os.path.isdir(kwargs["out"] + "/js/jsi18n"):
os.makedirs(kwargs["out"] + "/js/jsi18n")
with open(kwargs["out"] + f"/js/jsi18n/{code}.js", "wb") as f:
f.write(resp.content)

View File

@ -78,11 +78,11 @@ class Command(BaseCommand):
# Deleting transactions
transactions = Transaction.objects.filter(Q(source=user.note) | Q(destination=user.note)).all()
local_deleted += list(transactions)
for tr in transactions:
if kwargs['verbosity'] >= 1:
if kwargs['verbosity'] >= 1:
for tr in transactions:
self.stdout.write(f"Removing {tr}...")
if force:
tr.delete()
if force:
transactions.delete()
# Deleting memberships
memberships = user.memberships.all()
@ -173,5 +173,4 @@ class Command(BaseCommand):
message += "Ont été supprimés en conséquence les objets suivants :\n\n"
for obj in deleted:
message += f"{repr(obj)} (pk: {obj.pk})\n"
if force and kwargs['doit']:
mail_admins("Utilisateurs supprimés", message)
mail_admins("Utilisateurs supprimés", message)