Uprava queries a dotazovani se pres base query builder, fix nahledu fotky pro editor, cache na fotky
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
from operator import or_
|
||||
from typing import Set, Optional
|
||||
|
||||
from sqlalchemy import and_
|
||||
|
||||
from database import models
|
||||
from database.transaction import get_session
|
||||
from graphql_schema.entities.helpers.combobox import handle_combobox_save
|
||||
@@ -21,16 +24,20 @@ class AircraftQueryResolver(BaseQueryResolver):
|
||||
*args,
|
||||
**kwargs,
|
||||
):
|
||||
call_sign = kwargs.get("call_sign")
|
||||
filters = {}
|
||||
if object_id:
|
||||
filters['object_id'] = object_id
|
||||
if call_sign:
|
||||
filters['call_sign'] = call_sign
|
||||
if not organization_ids:
|
||||
filters['user_id'] = user_id
|
||||
if kwargs.get("call_sign"):
|
||||
filters['call_sign'] = kwargs["call_sign"]
|
||||
if kwargs.get("search"):
|
||||
filters['search'] = kwargs.pop("search", None)
|
||||
|
||||
query = super().get_query(
|
||||
order_by=[models.Aircraft.id.desc()],
|
||||
user_id=user_id if not organization_ids else None,
|
||||
only_my=False,
|
||||
only_public=kwargs.get("only_public", False),
|
||||
order_by=order_by,
|
||||
**filters
|
||||
)
|
||||
if organization_ids:
|
||||
@@ -38,7 +45,10 @@ class AircraftQueryResolver(BaseQueryResolver):
|
||||
query.filter(
|
||||
or_(
|
||||
models.Aircraft.created_by_id == user_id,
|
||||
models.Aircraft.organization_id.in_(organization_ids)
|
||||
and_(
|
||||
models.Aircraft.organization_id.in_(organization_ids),
|
||||
models.Aircraft.is_public.is_(True)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user