Forráskód Böngészése

Fixing settings conf

Colin Powell 3 hete
szülő
commit
983b89cfd4

+ 4 - 2
coffee_wars/settings.py

@@ -10,6 +10,7 @@ For the full list of settings and their values, see
 https://docs.djangoproject.com/en/5.2/ref/settings/
 """
 
+import os
 from pathlib import Path
 
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -20,7 +21,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
 # See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
 
 # SECURITY WARNING: keep the secret key used in production secret!
-SECRET_KEY = 'django-insecure-*vwm-dvu0_4&jn^^_2^9b2+va@f)-g^g_yrh_!tr5^^f75#obb'
+SECRET_KEY = os.getenv("CW_SECRET_KEY", 'django-insecure-*vwm-dvu0_4&jn^^_2^9b2+va@f)-g^g_yrh_!tr5^^f75#obb')
 
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = True
@@ -28,7 +29,8 @@ DEBUG = True
 ALLOWED_HOSTS = []
 
 
-INTEREST_RATE = 0.04
+INTEREST_RATE = float(os.getenv("CW_INTEREST_RATE", 0.04))
+MAX_DAYS = int(os.getenv("CW_MAX_DAYS", 30))
 
 # Application definition
 

+ 23 - 0
game/migrations/0003_gamesession_interest_gamesession_max_days.py

@@ -0,0 +1,23 @@
+# Generated by Django 4.2.24 on 2025-09-17 04:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('game', '0002_gamesession_completed_gamesession_final_score_and_more'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='gamesession',
+            name='interest',
+            field=models.DecimalField(decimal_places=2, default=0.04, max_digits=10),
+        ),
+        migrations.AddField(
+            model_name='gamesession',
+            name='max_days',
+            field=models.DecimalField(decimal_places=2, default=30, max_digits=10),
+        ),
+    ]

+ 3 - 0
game/models.py

@@ -1,3 +1,4 @@
+from django.conf import settings
 from django.db import models
 from django.contrib.auth.models import User
 import json
@@ -12,6 +13,8 @@ class GameSession(models.Model):
     inventory = models.TextField(default='{}')  # JSON string
     capacity = models.IntegerField(default=100)
     high_score = models.DecimalField(max_digits=10, decimal_places=2, default=0)
+    interest = models.DecimalField(max_digits=10, decimal_places=2, default=settings.INTEREST_RATE)
+    max_days = models.DecimalField(max_digits=10, decimal_places=2, default=settings.MAX_DAYS)
     is_active = models.BooleanField(default=True)  # Track active games
     completed = models.BooleanField(default=False)  # Track completed games
     final_score = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)

+ 1 - 1
game/templates/game/home.html

@@ -2,7 +2,7 @@
 <div class="game-header">
   <div class="stat">
     <div class="stat-label">Day</div>
-    <div class="stat-value">{{ game.day }}/30</div>
+    <div class="stat-value">{{ game.day }}/{{max_days}}</div>
   </div>
   <div class="stat">
     <div class="stat-label">Location</div>

+ 1 - 1
game/templates/game/my_games.html

@@ -7,7 +7,7 @@
 <div class="high-scores">
   {% for game in active_games %}
   <div class="high-score-row">
-    <div>Day {{ game.day }}/30</div>
+    <div>Day {{ game.day }}/{{game.max_days}}</div>
     <div>{{ game.location }}</div>
     <div>Cash: ${{ game.cash|floatformat:2 }}</div>
     <div>

+ 2 - 0
game/views.py

@@ -124,6 +124,7 @@ def home(request):
         'capacity_left': game.capacity - total_items,
         'net_worth': Decimal(game.cash) + Decimal(inventory_value) - Decimal(game.debt),
         'interest': INTEREST_RATE * 100,
+        'max_days': MAX_DAYS,
     }
 
     return render(request, 'game/home.html', context)
@@ -405,4 +406,5 @@ def my_games(request):
     return render(request, 'game/my_games.html', {
         'active_games': active_games,
         'completed_games': completed_games,
+        'max_days': MAX_DAYS,
     })