Add auto-renewal and cancellation handling for tribute subscriptions

- Implemented a new method to handle expired tribute subscriptions, automatically renewing them if no cancellation was received.
- Added functionality to manage tribute subscription cancellations, setting a grace period and notifying users accordingly.
- Updated localization files to include messages for auto-renewal and cancellation notifications in both English and Russian, enhancing user communication.
This commit is contained in:
machka-pasla
2025-08-05 23:21:12 +03:00
parent 283fc6bad4
commit e537203209
6 changed files with 160 additions and 0 deletions
+10
View File
@@ -31,6 +31,16 @@ async def get_subscription_by_panel_subscription_uuid(
return result.scalar_one_or_none()
async def get_active_subscriptions_for_user(session: AsyncSession, user_id: int) -> List[Subscription]:
"""Get all active subscriptions for a user."""
stmt = select(Subscription).where(
Subscription.user_id == user_id,
Subscription.is_active == True
).order_by(Subscription.end_date.desc())
result = await session.execute(stmt)
return result.scalars().all()
async def update_subscription(
session: AsyncSession, subscription_id: int,
update_data: Dict[str, Any]) -> Optional[Subscription]: