added application page

This commit is contained in:
2025-04-28 02:30:06 +03:00
parent 346b132f4c
commit ac344773c5
27 changed files with 1796 additions and 347 deletions

View File

@@ -4,8 +4,8 @@ Advanced filtering functionality for SQLAlchemy models.
This module provides a comprehensive set of filtering capabilities for SQLAlchemy models,
including pagination, ordering, and complex query building.
"""
from __future__ import annotations
import arrow
from typing import Any, TypeVar, Type, Union, Optional
@@ -23,7 +23,7 @@ T = TypeVar("T", bound="QueryModel")
class QueryModel:
__abstract__ = True
pre_query = None
pre_query: Optional[Query] = None
@classmethod
def _query(cls: Type[T], db: Session) -> Query:
@@ -149,11 +149,29 @@ class QueryModel:
Returns:
Tuple of SQLAlchemy filter expressions or None if validation fails
"""
if validate_model is not None:
# Add validation logic here if needed
pass
return tuple(cls.filter_expr(**smart_options))
try:
# Let SQLAlchemy handle the validation by attempting to create the filter expressions
return tuple(cls.filter_expr(**smart_options))
except Exception as e:
# If there's an error, provide a helpful message with valid columns and relationships
valid_columns = set()
relationship_names = set()
# Get column names if available
if hasattr(cls, '__table__') and hasattr(cls.__table__, 'columns'):
valid_columns = set(column.key for column in cls.__table__.columns)
# Get relationship names if available
if hasattr(cls, '__mapper__') and hasattr(cls.__mapper__, 'relationships'):
relationship_names = set(rel.key for rel in cls.__mapper__.relationships)
# Create a helpful error message
error_msg = f"Error in filter expression: {str(e)}\n"
error_msg += f"Attempted to filter with: {smart_options}\n"
error_msg += f"Valid columns are: {', '.join(valid_columns)}\n"
error_msg += f"Valid relationships are: {', '.join(relationship_names)}"
raise ValueError(error_msg) from e
@classmethod
def filter_by_one(

View File

@@ -122,8 +122,6 @@ class EndpointResponse(BaseModel):
def response(self):
"""Convert response to dictionary format."""
resutl_data = getattr(self.pagination_result, "data", None)
if not resutl_data:
raise ValueError("Invalid pagination result data.")
result_pagination = getattr(self.pagination_result, "pagination", None)
if not result_pagination:
raise ValueError("Invalid pagination result pagination.")