fix all pylint warnings, add tests (wip) fix recap

This commit is contained in:
2026-03-06 00:00:01 +01:00
parent 60812652cf
commit b4b4fa7643
25 changed files with 845 additions and 376 deletions

View File

@@ -1,7 +1,6 @@
import src.messages as messages
import src.productors.exceptions as exceptions
from sqlmodel import Session, select
from src import models
from src import messages, models
from src.productors import exceptions
def get_all(
@@ -50,9 +49,10 @@ def create_one(
def update_one(
session: Session,
id: int,
productor: models.ProductorUpdate) -> models.ProductorPublic:
statement = select(models.Productor).where(models.Productor.id == id)
_id: int,
productor: models.ProductorUpdate
) -> models.ProductorPublic:
statement = select(models.Productor).where(models.Productor.id == _id)
result = session.exec(statement)
new_productor = result.first()
if not new_productor:
@@ -94,11 +94,13 @@ def delete_one(session: Session, _id: int) -> models.ProductorPublic:
return result
def is_allowed(
session: Session,
user: models.User,
_id: int,
productor: models.ProductorCreate
session: Session,
user: models.User,
_id: int = None,
productor: models.ProductorCreate = None
) -> bool:
if not _id and not productor:
return False
if not _id:
return productor.type in [r.name for r in user.roles]
statement = (