diff --git a/home/context_processors.py b/home/context_processors.py index f3639ee..1d7f7b5 100644 --- a/home/context_processors.py +++ b/home/context_processors.py @@ -35,5 +35,5 @@ def get_server_info(request): return { 'server': server_selection, 'online_characters': online_count, - 'expansion': 'WotLK' if server_selection and server_selection.gamebuild == 12340 else 'Cataclysm', + 'expansion': server_selection.expansion if server_selection else 'Unknown', } diff --git a/home/models/site.py b/home/models/site.py index 8383827..2ac18cd 100644 --- a/home/models/site.py +++ b/home/models/site.py @@ -2,6 +2,22 @@ from django.db import models from django_ckeditor_5.fields import CKEditor5Field +def expansion_from_gamebuild(gamebuild): + """Etiqueta de expansión a partir del build del cliente. + + Reconoce tanto los clientes retail antiguos (3.3.5a=12340, 4.3.4=15595) como + los de WoW Classic: WotLK Classic 3.4.x (~44832–51536) y Cataclysm Classic + 4.4.x (~54332+). Nova WoW corre 3.4.3 (WotLK Classic), luego debe dar 'WotLK'. + """ + if gamebuild is None: + return 'Unknown' + if gamebuild == 12340 or 44000 <= gamebuild <= 52000: + return 'WotLK' + if gamebuild == 15595 or 53000 <= gamebuild <= 60000: + return 'Cataclysm' + return 'Unknown' + + class Noticia(models.Model): titulo = models.CharField(max_length=200) contenido = CKEditor5Field('Contenido', config_name='default') @@ -40,9 +56,12 @@ class ServerSelection(models.Model): port = models.IntegerField() gamebuild = models.IntegerField() + @property + def expansion(self): + return expansion_from_gamebuild(self.gamebuild) + def __str__(self): - expansion = 'WotLK' if self.gamebuild == 12340 else 'Cataclysm' if self.gamebuild == 15595 else 'Unknown' - return f"{self.name} ({expansion})" + return f"{self.name} ({self.expansion})" class DownloadClientPage(models.Model): title = models.CharField(max_length=255, default="Descarga del cliente") diff --git a/home/templates/partials/head.html b/home/templates/partials/head.html index bf117cb..5c00e7c 100644 --- a/home/templates/partials/head.html +++ b/home/templates/partials/head.html @@ -4,9 +4,9 @@ -