Fix otaceni fotek, drobny refaktoring
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from typing import Optional, Type
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, or_
|
||||
from database import models
|
||||
|
||||
|
||||
@@ -23,7 +23,12 @@ class QueryBuilder:
|
||||
query = query.filter(self.model.deleted.is_(False))
|
||||
|
||||
if hasattr(self.model, "created_by_id") and created_by_id:
|
||||
query = query.filter(self.model.created_by_id == created_by_id)
|
||||
ownership = [self.model.created_by_id == created_by_id]
|
||||
|
||||
if hasattr(self.model, "is_public"):
|
||||
ownership.append(self.model.is_public.is_(True))
|
||||
|
||||
query = query.filter(or_(*ownership))
|
||||
|
||||
if order_by:
|
||||
query = query.order_by(*order_by)
|
||||
|
||||
Reference in New Issue
Block a user