69715ecd06
Co-authored-by: Cursor <cursoragent@cursor.com>
17 lines
440 B
Python
17 lines
440 B
Python
from app.models import AdBanner
|
|
|
|
|
|
def get_banners(position=None):
|
|
query = AdBanner.query.filter_by(is_active=True).order_by(AdBanner.sort_order, AdBanner.id)
|
|
if position:
|
|
query = query.filter_by(position=position)
|
|
return query.all()
|
|
|
|
|
|
def get_banners_by_position():
|
|
banners = get_banners()
|
|
grouped = {}
|
|
for banner in banners:
|
|
grouped.setdefault(banner.position, []).append(banner)
|
|
return grouped
|