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 @@ - {{ NOMBRE_SERVIDOR }} Server de WoW WotLK 3.3.5a Latino y Español 💎 - - + {{ NOMBRE_SERVIDOR }} Server de WoW WotLK 3.4.3 Latino y Español 💎 + + @@ -17,9 +17,9 @@ - + - + diff --git a/home/templates/partials/noticias.html b/home/templates/partials/noticias.html index f6d8ea2..20f47c1 100644 --- a/home/templates/partials/noticias.html +++ b/home/templates/partials/noticias.html @@ -3,7 +3,7 @@
-

{{ NOMBRE_SERVIDOR }} WOTLK 3.3.5A

+

{{ NOMBRE_SERVIDOR }} WOTLK 3.4.3

diff --git a/home/views/api.py b/home/views/api.py index 25d7d77..bc898ca 100644 --- a/home/views/api.py +++ b/home/views/api.py @@ -27,7 +27,7 @@ def home_status_api(request): server = ServerSelection.objects.first() online = get_online_characters_count() status = "Online" if (server and check_server_status(server.address, server.port)) else "Offline" - expansion = "WotLK" if (server and server.gamebuild == 12340) else "Cataclysm" + expansion = server.expansion if server else "Unknown" return JsonResponse( { "server_name": server.name if server else None, diff --git a/home/views/pages.py b/home/views/pages.py index f9a84aa..42e152d 100644 --- a/home/views/pages.py +++ b/home/views/pages.py @@ -28,7 +28,7 @@ def home_view(request): online_characters = get_online_characters_count() server_selection = ServerSelection.objects.first() status = check_server_status(server_selection.address, server_selection.port) if server_selection else None - game_version = 'WotLK' if server_selection and server_selection.gamebuild == 12340 else 'Cataclysm' + game_version = server_selection.expansion if server_selection else 'Unknown' context = { 'noticias': noticias, @@ -54,7 +54,7 @@ def server_status_view(request): server_selection = ServerSelection.objects.first() if server_selection: status = check_server_status(server_selection.address, server_selection.port) - game_version = 'WotLK' if server_selection.gamebuild == 12340 else 'Cataclysm' + game_version = server_selection.expansion else: status = None game_version = None