ソースを参照

Actually override the title

Colin Powell 3 年 前
コミット
6701a3deec
4 ファイル変更14 行追加2 行削除
  1. 6 0
      games/constants.py
  2. 1 1
      games/models.py
  3. 1 1
      games/urls.py
  4. 6 0
      games/utils.py

+ 6 - 0
games/constants.py

@@ -7,3 +7,9 @@ REGION_KEYWORDS = {
     "JP": ["(j)", "japan", "jp", "jpn"],
     "EU": ["(e)", "eur", "europe", "pal"],
 }
+
+# Only Bomberman 64 is known to do this, but the JP game is title identically to
+# the US but is a totally different game
+KNOWN_DUPLICATE_TITLES = [
+    "Bomberman 64",
+]

+ 1 - 1
games/models.py

@@ -224,7 +224,7 @@ class Game(BaseModel):
         return f"{self.name} for {self.game_system}"
 
     def get_absolute_url(self):
-        return reverse("games:game_detail", args=[self.slug, self.region])
+        return reverse("games:game_detail", args=[self.slug])
 
     @property
     def rating_by_100(self) -> float:

+ 1 - 1
games/urls.py

@@ -51,7 +51,7 @@ urlpatterns = [
         name="gamecollection_list",
     ),
     path(
-        "<str:slug>-<str:region>/",
+        "<str:slug>/",
         views.GameDetail.as_view(),
         name="game_detail",
     ),

+ 6 - 0
games/utils.py

@@ -1,6 +1,7 @@
 from games.constants import (
     ENGLISH_PATCHED_KEYWORDS,
     HACK_KEYWORDS,
+    KNOWN_DUPLICATE_TITLES,
     REGION_KEYWORDS,
     UNDUB_KEYWORDS,
 )
@@ -70,6 +71,11 @@ def import_gamelist_file_to_db_for_system(
             logger.warning(
                 f"While importing {name} for {game_system}, duplicate entry found"
             )
+            if name in KNOWN_DUPLICATE_TITLES:
+                obj, created = Game.objects.get_or_create(
+                    name=" ".join([name, region]), game_system=game_system
+                )
+
             print(f"While importing {name} for {game_system}, duplicate entry found")
             continue