diff --git a/home/__pycache__/admin.cpython-313.pyc b/home/__pycache__/admin.cpython-313.pyc index 6145892..5df01a2 100644 Binary files a/home/__pycache__/admin.cpython-313.pyc and b/home/__pycache__/admin.cpython-313.pyc differ diff --git a/home/__pycache__/models.cpython-313.pyc b/home/__pycache__/models.cpython-313.pyc index 48b97e4..eaebdf1 100644 Binary files a/home/__pycache__/models.cpython-313.pyc and b/home/__pycache__/models.cpython-313.pyc differ diff --git a/home/__pycache__/tasks.cpython-313.pyc b/home/__pycache__/tasks.cpython-313.pyc new file mode 100644 index 0000000..7732d18 Binary files /dev/null and b/home/__pycache__/tasks.cpython-313.pyc differ diff --git a/home/__pycache__/urls.cpython-313.pyc b/home/__pycache__/urls.cpython-313.pyc index 0e12934..bd4ad0c 100644 Binary files a/home/__pycache__/urls.cpython-313.pyc and b/home/__pycache__/urls.cpython-313.pyc differ diff --git a/home/__pycache__/views.cpython-313.pyc b/home/__pycache__/views.cpython-313.pyc index 8b17fbb..ee78eb0 100644 Binary files a/home/__pycache__/views.cpython-313.pyc and b/home/__pycache__/views.cpython-313.pyc differ diff --git a/home/admin.py b/home/admin.py index 903fb61..78d2fc8 100644 --- a/home/admin.py +++ b/home/admin.py @@ -3,7 +3,7 @@ from django.contrib import admin from django import forms from .models import ( Noticia, ClienteCategoria, SistemaOperativo, ServerSelection, - RecruitAFriend, DownloadClientPage, ContentCreator, RecruitReward, GuildRenameSettings + RecruitAFriend, DownloadClientPage, ContentCreator, RecruitReward, GuildRenameSettings, VoteSite ) from django.db import connections import logging @@ -139,7 +139,15 @@ class GuildRenameSettingsAdmin(admin.ModelAdmin): (None, { 'fields': ('cost',) }), - ) + ) + + +@admin.register(VoteSite) +class VoteSiteAdmin(admin.ModelAdmin): + list_display = ('name', 'points', 'url', 'image_url') + search_fields = ('name',) + list_editable = ('points',) + list_display_links = ('name',) # Registro de modelos en el admin diff --git a/home/models.py b/home/models.py index 1800ab3..c636101 100644 --- a/home/models.py +++ b/home/models.py @@ -106,11 +106,13 @@ class ClaimedReward(models.Model): class AccountActivation(models.Model): username = models.CharField(max_length=17) email = models.EmailField() + old_email = models.EmailField(null=True, blank=True) password = models.CharField(max_length=64) # Hash de la contraseña salt = models.BinaryField(max_length=32) verifier = models.BinaryField(max_length=32) recruiter_id = models.IntegerField(null=True, blank=True) hash = models.CharField(max_length=32, unique=True) + old_email_hash = models.CharField(max_length=32, null=True, blank=True) created_at = models.DateTimeField(default=timezone.now) def is_expired(self): @@ -118,14 +120,14 @@ class AccountActivation(models.Model): class SecurityToken(models.Model): - user_id = models.IntegerField() # Referencia al ID del usuario en `acore_auth` + user = models.ForeignKey(User, on_delete=models.CASCADE) token = models.CharField(max_length=6) created_at = models.DateTimeField(auto_now_add=True) expires_at = models.DateTimeField() ip_address = models.GenericIPAddressField() def __str__(self): - return f"Token for user_id {self.user_id}" + return f"Token for {self.user.username}" class GuildRenameSettings(models.Model): @@ -136,5 +138,40 @@ class GuildRenameSettings(models.Model): class Meta: verbose_name = "Configuración de Renombrar Hermandad" - verbose_name_plural = "Configuraciones de Renombrar Hermandad" + verbose_name_plural = "Configuraciones de Renombrar Hermandad" + + +class VoteSite(models.Model): + name = models.CharField(max_length=100, unique=True) + url = models.URLField(max_length=200, help_text="URL del sitio de votación") + image_url = models.URLField(max_length=300, help_text="URL completa de la imagen") + points = models.IntegerField(default=1, help_text="Puntos otorgados por votar") + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + + def __str__(self): + return self.name + +class VoteLog(models.Model): + account_id = models.IntegerField() + vote_site = models.ForeignKey('VoteSite', on_delete=models.CASCADE) + created_at = models.DateTimeField(auto_now_add=True) + last_vote_time = models.DateTimeField(null=True, blank=True) + processed = models.BooleanField(default=False) + processed_at = models.DateTimeField(null=True, blank=True) + + def __str__(self): + return f"Voto para {self.vote_site.name} por cuenta {self.account_id}" + + +class HomeApiPoints(models.Model): + accountID = models.IntegerField(unique=True) + vp = models.IntegerField(default=0) + dp = models.IntegerField(default=0) + + class Meta: + db_table = 'home_api_points' + + def __str__(self): + return f"Cuenta {self.accountID} - PV: {self.vp}, DP: {self.dp}" \ No newline at end of file diff --git a/home/static/nw-themes/nw-ryu/nw-js-handlers/change_email_response.js b/home/static/nw-themes/nw-ryu/nw-js-handlers/change_email_response.js index 28ddd43..cc0b6bb 100644 --- a/home/static/nw-themes/nw-ryu/nw-js-handlers/change_email_response.js +++ b/home/static/nw-themes/nw-ryu/nw-js-handlers/change_email_response.js @@ -1,70 +1,42 @@ -if (window.history.replaceState) { - window.history.replaceState(null, null, window.location.href); -}; - -$(function(){ - $(".toggle-password").click(function() { - $(this).toggleClass("fa-eye fa-eye-slash"); - var type = $(this).hasClass("fa-eye-slash") ? "text" : "password"; - $("#password").attr("type", type); - }); -}); - -$(function(){ - $(".toggle-token").click(function() { - $(this).toggleClass("fa-eye fa-eye-slash"); - var type = $(this).hasClass("fa-eye-slash") ? "text" : "password"; - $("#security-token").attr("type", type); - }); -}); - -$(function(){ - $('#conf-new-email').on("cut copy paste",function(e) { - e.preventDefault(); - }); -}); - -$(function(){ - $('.change-email-button').on('click', function(e) { - e.preventDefault(); - e.stopPropagation(); +$(document).ready(function() { + $('#nw-change-email-form').on('submit', function(e) { + e.preventDefault(); // Evitar el envío por defecto del formulario $("#change-email-response").empty(); - var button = $(this); - var buttonoriginal = button.html(); - var bValue = button.data('id'); - var data = {changeemail: bValue}; - data = $("#uw-change-email-form").serialize() + '&' + $.param(data); + var form = $(this); + var button = $('.change-email-button'); + var originalText = button.html(); - changeButton(button, 'Cambiando correo'); + button.html("Cambiando correo..."); + button.prop("disabled", true); $.ajax({ type: 'POST', - url: '', - data: data, + url: form.attr('action'), + data: form.serialize(), // Serializar los datos correctamente dataType: 'json', - success: function(data) { - $("#change-email-response").append(data.message).hide().slideDown(); + success: function(response) { + $("#change-email-response").html(response.message).hide().slideDown(); - if (data.success === true) { + if (response.success) { button.html("Correo cambiado"); - button.css("color","#d79602"); - } - else { + } else { setTimeout(function() { - $("#change-email-response").slideUp( function() { - $("#change-email-response").empty(); - restoreButton(button, buttonoriginal); + $("#change-email-response").slideUp(function() { + $("#change-email-response").empty(); + button.html(originalText); + button.prop("disabled", false); }); }, 5000); } }, - error: function() { - setTimeout(function() { - alert("Algo ha salido mal. Por favor intente más tarde"); - window.location.reload(); - }, 2000); + error: function(xhr, status, error) { + console.error("Error:", error); + console.error("Detalles:", xhr.responseText); + $("#change-email-response").html('Algo ha salido mal. Inténtelo de nuevo.'); + button.html(originalText); + button.prop("disabled", false); } }); }); -}); \ No newline at end of file +}); diff --git a/home/static/nw-themes/nw-ryu/nw-js-handlers/vote_points_response.js b/home/static/nw-themes/nw-ryu/nw-js-handlers/vote_points_response.js new file mode 100644 index 0000000..2f54003 --- /dev/null +++ b/home/static/nw-themes/nw-ryu/nw-js-handlers/vote_points_response.js @@ -0,0 +1,75 @@ +$(document).ready(function() { + $('.vote-button').each(function() { + var button = $(this); + var remainingTime = button.data('remaining-time'); + + if (remainingTime) { + startCooldownTimer(button, remainingTime); + } + }); + + $('.vote-button').on('click', function(e) { + e.preventDefault(); + $("#voteResponse").empty(); + + var button = $(this); + var voteUrl = button.data('url').trim(); + var data = { vote: voteUrl }; + + button.html("Votando..."); + button.prop("disabled", true); + + var otherWindow = window.open(voteUrl, "_blank"); + otherWindow.opener = null; + + $.ajax({ + type: 'POST', + url: '', + data: data, + dataType: 'json', + success: function(response) { + $("#voteResponse").html(response.message).hide().slideDown(); + + if (response.success) { + button.html("Votado"); + button.prop("disabled", true); + } else { + button.html("Votar"); + button.prop("disabled", false); + } + + // Ocultar el mensaje después de 5 segundos + setTimeout(function() { + $("#voteResponse").slideUp(function() { + $("#voteResponse").empty(); + }); + }, 5000); + }, + error: function() { + $("#voteResponse").html('Algo ha salido mal. Por favor, inténtalo más tarde.'); + + // Ocultar el mensaje después de 5 segundos en caso de error + setTimeout(function() { + $("#voteResponse").slideUp(function() { + $("#voteResponse").empty(); + }); + }, 5000); + } + }); + }); +}); + +function startCooldownTimer(button, remainingTime) { + var interval = setInterval(function() { + if (remainingTime <= 0) { + clearInterval(interval); + button.html("Votar"); + button.prop("disabled", false); + } else { + var hours = Math.floor(remainingTime / 3600); + var minutes = Math.floor((remainingTime % 3600) / 60); + button.html(`Espera ${hours}h ${minutes}m`); + remainingTime--; + } + }, 1000); +} diff --git a/home/templates/emails/confirm_new_email.html b/home/templates/emails/confirm_new_email.html new file mode 100644 index 0000000..ed97fd0 --- /dev/null +++ b/home/templates/emails/confirm_new_email.html @@ -0,0 +1,28 @@ + + +
+ +
+ Activación de Nuevo Correo+ |
+
|
+ Hola {{ username }}, +Tu solicitud para cambiar el correo electrónico en {{ NOMBRE_SERVIDOR }} ha sido recibida. +Por favor, haz clic en el siguiente enlace para confirmar tu nuevo correo: + +Si no realizaste esta solicitud, por favor contacta con soporte. +Atentamente, |
+
+ Confirmación de Cambio de Correo+ |
+
|
+ Hola {{ username }}, +Has solicitado cambiar tu correo electrónico registrado en {{ NOMBRE_SERVIDOR }}. +Para confirmar este cambio, haz clic en el siguiente enlace: ++ Confirmar cambio + +Si no solicitaste este cambio, por favor ignora este correo. +Atentamente, |
+
+ Cambio de Correo Exitoso+ |
+
|
+ Hola {{ username }}, +Te notificamos que tu correo electrónico en {{ NOMBRE_SERVIDOR }} ha sido cambiado exitosamente al siguiente correo: ++ {{ new_email }} + +Si no realizaste este cambio, por favor contacta inmediatamente con soporte. +Atentamente, |
+
PD: 0
-PV: 0
-Token de Seguridad: Sin solicitar
+PD: {{ dp }}
+PV: {{ vp }}
+Token de Seguridad: + + {% if token_status == "Solicitado" %} + {{ token_status }} - {{ token_date }} + {% else %} + {{ token_status }} + {% endif %} + +
{% if account_status.is_banned %}Cuenta baneada: Sí
diff --git a/home/templates/partials/vote_points.html b/home/templates/partials/vote_points.html index c69b3f3..db203e0 100644 --- a/home/templates/partials/vote_points.html +++ b/home/templates/partials/vote_points.html @@ -52,122 +52,32 @@Nota: Gtop100 puede demorar unos minutos en acreditar el voto.
![]() |
-
| Gtop100 | -
| PV: 1 | -
| - |
| - - | -
![]() |
-
| TopG | -
| PV: 1 | -
| - |
| - - | -
![]() |
-
| Top100arena | -
| PV: 1 | -
| - |
| - - | -
![]() |
-
| Arena-Top100 | -
| PV: 1 | -
| - |
| - - | -
| {{ site.name }} | +
| PV: {{ site.points }} | +
| + + | +