Implements flexible feature access control with 3-tier hierarchy:
1. User-specific restrictions (highest priority)
2. Tier limits
3. Feature defaults
New functions:
- get_effective_tier(profile_id) - Checks access_grants, falls back to profile.tier
- check_feature_access(profile_id, feature_id) - Complete access check
Returns: {allowed, limit, used, remaining, reason}
- increment_feature_usage(profile_id, feature_id) - Usage tracking
- _calculate_next_reset(reset_period) - Helper for daily/monthly resets
Supports:
- Boolean features (enabled/disabled)
- Count-based features with limits
- Automatic reset (daily/monthly/never)
- Unlimited (NULL) and disabled (0) states
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| migrations | ||
| routers | ||
| apply_v9c_migration.py | ||
| auth.py | ||
| db_init.py | ||
| db.py | ||
| Dockerfile | ||
| main_old.py | ||
| main.py | ||
| migrate_to_postgres.py | ||
| models.py | ||
| requirements.txt | ||
| schema.sql | ||
| startup.sh | ||