Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions games/__tests__/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,20 @@ def test_latest_added_date_display(self):
newer_date = date.today() - timedelta(days=5)

# Add game to platform on different dates
gop1 = GameOnPlatform.objects.create(
GameOnPlatform.objects.create(
game=game,
platform=self.platform,
vendor=self.vendor1,
added=older_date,
deleted=False,
)
# Set the date after creation to bypass auto_now_add
GameOnPlatform.objects.filter(pk=gop1.pk).update(added=older_date)

gop2 = GameOnPlatform.objects.create(
GameOnPlatform.objects.create(
game=game,
platform=self.platform,
vendor=self.vendor2,
added=newer_date,
deleted=False,
)
# Set the date after creation to bypass auto_now_add
GameOnPlatform.objects.filter(pk=gop2.pk).update(added=newer_date)

# Annotate as admin would
game = (
Expand All @@ -123,16 +120,15 @@ def test_latest_added_date_display_never(self):
game = GameFactory(name="Undated Game", platforms=False)

# Create GameOnPlatform with added=None
gop = GameOnPlatform.objects.create(
GameOnPlatform.objects.create(
game=game,
platform=self.platform,
vendor=self.vendor1,
added=None,
deleted=False,
)
# Set added to None after creation (bypasses auto_now_add)
GameOnPlatform.objects.filter(pk=gop.pk).update(added=None)

# Annotate as admin would - AFTER updating the added field
# Annotate as admin would
game = (
Game.objects.all_with_orphaned()
.annotate(latest_added=models.Max("platforms_meta_data__added"))
Expand Down
3 changes: 2 additions & 1 deletion games/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
from datetime import date

from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
Expand Down Expand Up @@ -115,7 +116,7 @@ class GameOnPlatform(models.Model):
platform = models.ForeignKey(
Platform, on_delete=models.CASCADE, related_name="games_meta_data"
)
added = models.DateField(null=True, blank=True, auto_now_add=True)
added = models.DateField(null=True, blank=True, default=date.today)
identifier = models.CharField(
verbose_name="ID in the platform for generating URLs",
max_length=255,
Expand Down
2 changes: 1 addition & 1 deletion jewel/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv("JEWEL_DEBUG", "True") == "True"

ALLOWED_HOSTS = os.getenv("JEWEL_ALLOWED_HOSTS", "localhost").split(",")
ALLOWED_HOSTS = os.getenv("JEWEL_ALLOWED_HOSTS", "localhost,127.0.0.1").split(",")

# Application definition

Expand Down