All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 6m4s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m6s
In Revisão the card gets "Revisar": a photo or a video of up to 30 s of the printed sheet, from the computer's or the phone's camera in the browser, or a file already recorded. It is attached to the order as DTF-<n>-revisao-<seq> with when and who, kept 180 days, and copied by the computers with the order folders to Kanban/Revisões/. A photo needs 1600 px on its longer side. An order above 1 m cannot reach Finalizado without one. In Finalizado the customer's order page shows the photo. The Revisor, Gestão and the administrators take it (capability "inspect"). Dialogs opened from a card's face or the board (Revisar, Editar tempos) now show over the page when the order panel is closed; inside the closed panel they were invisible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
4.9 KiB
Python
112 lines
4.9 KiB
Python
"""Clear the test board before the Site opens to customers, once, by hand.
|
|
|
|
Run from the worker's console (Portainer > Containers > worker > Console):
|
|
|
|
python -m ops.launch_reset shows what would be removed
|
|
python -m ops.launch_reset --confirmar APAGAR removes it
|
|
python -m ops.launch_reset --confirmar APAGAR --contas also customer accounts
|
|
python -m ops.launch_reset --root /srv/Kanban --confirmar APAGAR
|
|
also empties the flow folders
|
|
|
|
Removes every order with its moves, files, notices and history, every quote,
|
|
payment attempt and payment notification, and the artwork pictures. The
|
|
artwork files are marked expired, so the worker deletes them from storage
|
|
within a minute. Operators, machines, prices, the Tiny connection and the
|
|
backups are kept.
|
|
|
|
It refuses if any payment was made with real money (Mercado Pago's
|
|
live_mode): those are customers' orders, not tests.
|
|
|
|
The order numbering is **not** reset (Dropstar, 2026-11-05): DTF-1…DTF-15
|
|
already exist as Tiny order numbers. DELETE keeps the identity sequence, so
|
|
the next card continues from where it stopped.
|
|
"""
|
|
import argparse
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from app.core import db
|
|
|
|
TABLES = [ # in an order the foreign keys allow
|
|
('hot_parts', 'peças nas pastas das máquinas'),
|
|
('print_parts', 'partes dos arquivos de impressão'),
|
|
('reworks', 'retrabalhos'),
|
|
('contact_waits', 'esperas de contato'),
|
|
('movements', 'movimentos de etapa'),
|
|
('order_files', 'arquivos finais e correções'),
|
|
('print_files', 'arquivos de impressão gerados'),
|
|
('outbox', 'envios ao Tiny e avisos'),
|
|
('order_reviews', 'fotos e vídeos de revisão'),
|
|
('orders', 'pedidos'),
|
|
('payment_intents', 'tentativas de pagamento'),
|
|
('payment_events', 'avisos de pagamento'),
|
|
('quotes', 'cotações'),
|
|
('upload_thumbnails', 'miniaturas das artes'),
|
|
]
|
|
ACCOUNTS = [('sessions', 'sessões de clientes'), ('accounts', 'contas de clientes')]
|
|
FLOW_FOLDERS = ('1. Arte recebida', '2. Arte conferida', '3. Imprimindo',
|
|
'4. Revisão', '5. Finalizado', 'Recibos', 'Revisões')
|
|
CONFIRM = 'APAGAR'
|
|
|
|
|
|
def counts(c, tables):
|
|
return {table: c.execute(f'SELECT count(*) AS n FROM dtf_local.{table}').fetchone()['n'] for table, _ in tables}
|
|
|
|
|
|
def clean_folders(root, dry_run=True):
|
|
"""Empty the flow folders under `root`, recreating them; keep Estampas/."""
|
|
root = Path(root)
|
|
if not any((root / name).exists() for name in FLOW_FOLDERS):
|
|
raise SystemExit(f'{root} does not look like the Kanban root: no flow folders found.')
|
|
if dry_run:
|
|
return [str(root / name) for name in FLOW_FOLDERS if (root / name).exists()]
|
|
cleaned = []
|
|
for name in FLOW_FOLDERS:
|
|
path = root / name
|
|
if path.is_dir():
|
|
shutil.rmtree(path)
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
cleaned.append(str(path))
|
|
return cleaned
|
|
|
|
|
|
def main(argv=None, out=print, connect=db.connect):
|
|
parser = argparse.ArgumentParser(prog='python -m ops.launch_reset')
|
|
parser.add_argument('--confirmar', default='', help=f'escreva {CONFIRM} para apagar')
|
|
parser.add_argument('--contas', action='store_true', help='apagar também as contas de clientes')
|
|
parser.add_argument('--root', type=Path, help='raiz Kanban, a pasta com "1. Arte recebida"')
|
|
parser.add_argument('--keep-files', action='store_true', help='não mexer nas pastas do Kanban')
|
|
args = parser.parse_args(argv)
|
|
tables = TABLES + (ACCOUNTS if args.contas else [])
|
|
with connect() as c:
|
|
live = c.execute("""SELECT count(*) AS n FROM dtf_local.payment_intents
|
|
WHERE response->>'live_mode'='true'""").fetchone()['n']
|
|
if live:
|
|
out(f'Recusado: {live} pagamento(s) com dinheiro real (live_mode). Esses pedidos são de clientes.')
|
|
return 1
|
|
before = counts(c, tables)
|
|
files = c.execute('SELECT count(*) AS n FROM dtf_local.uploads WHERE purged_at IS NULL').fetchone()['n']
|
|
for table, label in tables:
|
|
out(f'{before[table]:>7} {label}')
|
|
out(f'{files:>7} arquivos de arte (o worker apaga do armazenamento)')
|
|
if args.root and not args.keep_files:
|
|
out('Pastas que serão esvaziadas:')
|
|
for folder in clean_folders(args.root, dry_run=True):
|
|
out(f' {folder}')
|
|
if args.confirmar != CONFIRM:
|
|
out(f'Nada foi apagado. Repita com --confirmar {CONFIRM} para apagar.')
|
|
return 0
|
|
for table, _ in tables:
|
|
c.execute(f'DELETE FROM dtf_local.{table}')
|
|
c.execute('UPDATE dtf_local.uploads SET expires_at=now() WHERE purged_at IS NULL')
|
|
if args.root and not args.keep_files:
|
|
for folder in clean_folders(args.root, dry_run=False):
|
|
out(f'esvaziada {folder}')
|
|
out('Apagado. A numeração dos pedidos continua de onde parou.')
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|