fix settings and add api to explain waiting list configs and payment fee

timetoconfirm
Raz 7 months ago
parent 1c5cc25e49
commit 82ec8f8471
  1. 2
      api/urls.py
  2. 20
      api/views.py
  3. 2
      padelclub_backend/settings_app.py
  4. 35
      padelclub_backend/settings_local.py.dist
  5. 39
      tournaments/models/tournament.py

@ -40,6 +40,8 @@ urlpatterns = [
path('refund-tournament/<str:team_registration_id>/', 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"),

@ -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)
})

@ -58,5 +58,3 @@ SHOP_MANAGERS = [
]
SHOP_SITE_ROOT_URL = 'https://padelclub.app'
SHOP_SUPPORT_EMAIL = 'shop@padelclub.app'
STRIPE_FEE = 0.0075

@ -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
}
}
}

@ -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()

Loading…
Cancel
Save