feat: the team no longer gets alert e-mails; the Kanban user form drops the option
All checks were successful
Build and deploy / Validate source (push) Successful in 47s
Build and deploy / Integration suite on a real stack (push) Successful in 3m38s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m20s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-20 09:37:41 -03:00
parent 14a43f2ada
commit c8857a5bf5
11 changed files with 43 additions and 114 deletions

View File

@@ -7,7 +7,7 @@ from uuid import UUID, uuid4
from fastapi import APIRouter, Depends, HTTPException
from psycopg.types.json import Jsonb
from .. import mail, payments
from .. import payments
from ..core import db
from ..core.auth import owner
from ..core.models import QuoteRequest
@@ -61,9 +61,6 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
if row['id'] == uid:
# An operator reviews it first; the files wait for that review.
payments.hold_uploads(c, payments.quote_uploads(draft), payments.REVIEW_HOLD)
mail.alert(c, 'Cotação esperando revisão',
['Um cliente montou um carrinho que precisa de revisão antes do pagamento.',
f'Motivo: {reason}', '', *mail.summary(draft)], '/')
return {'id': row['id'], 'status': 'approved' if row['approved'] else 'pending_review'}
@router.get('/api/quotes/{uid}')

View File

@@ -1,9 +1,7 @@
"""Kanban users and print machines, managed by the administrators.
An administrator creates each account with a first password and the person
changes it in "Minha senha". Whoever wants the team's alerts by e-mail has
them switched on here. The superadmin is
the system's own account, set from the console (python -m app.operators);
changes it in "Minha senha". The superadmin is the system's own account, set from the console (python -m app.operators);
administrators manage everyone else. Nobody can remove, disable or demote
themselves, so the last administrator cannot lock the team out by accident.
"""
@@ -29,8 +27,6 @@ class UserIn(StrictModel):
password: str | None = Field(default=None, min_length=8, max_length=128)
active: bool = True
machines: list[UUID] = Field(default_factory=list, max_length=50)
# The team's alerts by e-mail: orders paid, carts waiting for review, payments to look at.
alerts: bool = False
@field_validator('email')
@classmethod
@@ -74,7 +70,7 @@ def change_password(body: PasswordChange, request: Request):
def user_rows(c):
rows = c.execute('''SELECT o.id,o.email,o.name,o.role,o.active,o.alerts,o.last_login_at,o.created_at,
rows = c.execute('''SELECT o.id,o.email,o.name,o.role,o.active,o.last_login_at,o.created_at,
COALESCE(array_agg(m.machine_id) FILTER (WHERE m.machine_id IS NOT NULL), '{}') AS machines
FROM dtf_local.operators o LEFT JOIN dtf_local.operator_machines m ON m.operator_id=o.id
GROUP BY o.id ORDER BY o.active DESC, o.name, o.email''').fetchall()
@@ -117,9 +113,9 @@ def create_user(body: UserIn, request: Request, user=Depends(can('users'))):
with db.connect() as c:
if c.execute('SELECT 1 FROM dtf_local.operators WHERE email=%s', (body.email,)).fetchone():
raise HTTPException(409, 'Já existe um usuário com este e-mail.')
c.execute('''INSERT INTO dtf_local.operators(id,email,name,password_hash,role,active,alerts)
VALUES(%s,%s,%s,%s,%s,%s,%s)''', (uid, body.email, body.name.strip(), password_hash(body.password),
body.role, body.active, body.alerts))
c.execute('''INSERT INTO dtf_local.operators(id,email,name,password_hash,role,active)
VALUES(%s,%s,%s,%s,%s,%s)''', (uid, body.email, body.name.strip(), password_hash(body.password),
body.role, body.active))
set_machines(c, uid, body.machines)
audit('operator_created', operator=user, account=body.email, role=body.role)
return {'id': str(uid)}
@@ -137,8 +133,8 @@ def update_user(uid: UUID, body: UserIn, request: Request, user=Depends(can('use
if body.email != row['email'] and c.execute(
'SELECT 1 FROM dtf_local.operators WHERE email=%s AND id<>%s', (body.email, uid)).fetchone():
raise HTTPException(409, 'Já existe um usuário com este e-mail.')
c.execute('UPDATE dtf_local.operators SET name=%s,email=%s,role=%s,active=%s,alerts=%s WHERE id=%s',
(body.name.strip(), body.email, role, body.active, body.alerts, uid))
c.execute('UPDATE dtf_local.operators SET name=%s,email=%s,role=%s,active=%s WHERE id=%s',
(body.name.strip(), body.email, role, body.active, uid))
if body.password:
c.execute('UPDATE dtf_local.operators SET password_hash=%s WHERE id=%s', (password_hash(body.password), uid))
if body.email != row['email']:
@@ -220,7 +216,7 @@ def test_mail(request: Request, user=Depends(can('manage'))):
with db.connect() as c:
if not mail.queue(c, 'test', user, 'Teste de e-mail · Kanban DTF',
'Este é um teste do Kanban DTF. Se chegou, o envio de e-mails está funcionando: '
'recuperação de senha dos clientes e alertas da equipe.'):
'os e-mails dos clientes.'):
raise HTTPException(409, 'O envio de e-mails não está configurado no servidor.')
audit('mail_test_queued', operator=user)
return {'ok': True, 'to': user}