diff --git a/api/urls.py b/api/urls.py index acdb689..e054f87 100644 --- a/api/urls.py +++ b/api/urls.py @@ -40,6 +40,8 @@ urlpatterns = [ path('refund-tournament//', views.process_refund, name='process-refund'), path('validate-stripe-account/', views.validate_stripe_account, name='validate_stripe_account'), path('xls-to-csv/', views.xls_to_csv, name='xls-to-csv'), + path('config/tournament/', views.get_tournament_config, name='tournament-config'), + path('config/payment/', views.get_payment_config, name='payment-config'), # authentication path("change-password/", ChangePasswordView.as_view(), name="change_password"), diff --git a/api/views.py b/api/views.py index 54f2b3d..0f8173a 100644 --- a/api/views.py +++ b/api/views.py @@ -407,3 +407,23 @@ def xls_to_csv(request): return response else: return HttpResponse("No file was uploaded", status=400) + +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def get_tournament_config(request): + """Return tournament-related configuration settings""" + config = settings.TOURNAMENT_SETTINGS['TIME_TO_CONFIRM'] + return Response({ + 'time_proximity_rules': config['TIME_PROXIMITY_RULES'], + 'waiting_list_rules': config['WAITING_LIST_RULES'], + 'business_rules': config['BUSINESS_RULES'], + 'urgency_override': config['URGENCY_OVERRIDE'] + }) + +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def get_payment_config(request): + """Return payment-related configuration settings""" + return Response({ + 'stripe_fee': getattr(settings, 'STRIPE_FEE', 0) + }) diff --git a/padelclub_backend/settings_app.py b/padelclub_backend/settings_app.py index 7a82bc5..e69f82e 100644 --- a/padelclub_backend/settings_app.py +++ b/padelclub_backend/settings_app.py @@ -58,5 +58,3 @@ SHOP_MANAGERS = [ ] SHOP_SITE_ROOT_URL = 'https://padelclub.app' SHOP_SUPPORT_EMAIL = 'shop@padelclub.app' - -STRIPE_FEE = 0.0075 diff --git a/padelclub_backend/settings_local.py.dist b/padelclub_backend/settings_local.py.dist index e03dde2..a9e417f 100644 --- a/padelclub_backend/settings_local.py.dist +++ b/padelclub_backend/settings_local.py.dist @@ -42,3 +42,38 @@ STRIPE_PUBLISHABLE_KEY = '' STRIPE_SECRET_KEY = '' SHOP_STRIPE_WEBHOOK_SECRET = 'whsec_...' # Your existing webhook secret TOURNAMENT_STRIPE_WEBHOOK_SECRET = 'whsec_...' # New webhook secret for tournaments +STRIPE_FEE = 0.0075 +TOURNAMENT_SETTINGS = { + 'TIME_TO_CONFIRM': { + 'TIME_PROXIMITY_RULES': { + 24: 30, # within 24h → 30 min + 48: 60, # within 48h → 60 min + 72: 120, # within 72h → 120 min + 'default': 240 + }, + 'WAITING_LIST_RULES': { + 30: 30, # 30+ teams → 30 min + 20: 60, # 20+ teams → 60 min + 10: 120, # 10+ teams → 120 min + 'default': 240 + }, + 'BUSINESS_RULES': { + 'hours': { + 'start': 8, # 8:00 + 'end': 21, # 21:00 + 'default_confirmation_hour': 8 # When extending to next day + }, + 'days': { + 'working_days': [0, 1, 2, 3, 4, 5, 6], # Monday = 0, Friday = 4 + 'weekend': [] # Saturday = 5, Sunday = 6 + } + }, + 'URGENCY_OVERRIDE': { + 'thresholds': { + 24: True, # If ≤ 24h until tournament: ignore business hours + 12: True # If ≤ 12h until tournament: ignore all restrictions + }, + 'minimum_response_time': 30 # minutes + } + } +} diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 48f0129..18439ed 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1490,40 +1490,11 @@ class Tournament(BaseModel): if waiting_list_count == 0: return None - # Configuration rules - TIME_PROXIMITY_RULES = { - 24: 30, # within 24h → 30 min - 48: 60, # within 48h → 60 min - 72: 120, # within 72h → 120 min - "default": 240 - } - - WAITING_LIST_RULES = { - 30: 30, # 30+ teams → 30 min - 20: 60, # 20+ teams → 60 min - 10: 120, # 10+ teams → 120 min - "default": 240 - } - - BUSINESS_RULES = { - "hours": { - "start": 8, # 8:00 - "end": 21, # 21:00 - "default_confirmation_hour": 8 # When extending to next day - }, - "days": { - "working_days": [0, 1, 2, 3, 4, 5, 6], # Monday = 0, Friday = 4 - "weekend": [] # Saturday = 5, Sunday = 6 - } - } - - URGENCY_OVERRIDE = { - "thresholds": { - 24: True, # If ≤ 24h until tournament: ignore business hours - 12: True # If ≤ 12h until tournament: ignore all restrictions - }, - "minimum_response_time": 30 # minutes - } + config = settings.TOURNAMENT_SETTINGS['TIME_TO_CONFIRM'] + TIME_PROXIMITY_RULES = config['TIME_PROXIMITY_RULES'] + WAITING_LIST_RULES = config['WAITING_LIST_RULES'] + BUSINESS_RULES = config['BUSINESS_RULES'] + URGENCY_OVERRIDE = config['URGENCY_OVERRIDE'] # 1. Get current time in tournament's timezone current_time = timezone.now()