Files
eventspace/backend/app/crud/event_theme.py
Felipe Cardoso fee7d8b5ec Refactor CRUD module imports and usage for clarity.
Replaces ambiguous shorthand references like `event` and `user` with more descriptive names such as `event_crud` and `user_crud`. Updates imports, function calls, tests, and other references across the codebase to maintain consistency. This improves code readability and reduces potential confusion.
2025-03-15 01:22:04 +01:00

25 lines
803 B
Python

from typing import List, Optional
from sqlalchemy.orm import Session
from app.crud.base import CRUDBase
from app.models.event_theme import EventTheme
from app.schemas.event_themes import EventThemeCreate, EventThemeUpdate
class CRUDEventTheme(CRUDBase[EventTheme, EventThemeCreate, EventThemeUpdate]):
def get_by_name(self, db: Session, *, name: str) -> Optional[EventTheme]:
return db.query(EventTheme).filter(EventTheme.name == name).first()
def get_active_themes(
self, db: Session, *, skip: int = 0, limit: int = 100
) -> List[EventTheme]:
return (
db.query(self.model)
.filter(self.model.events.any())
.offset(skip)
.limit(limit)
.all()
)
event_theme_crud = CRUDEventTheme(EventTheme)