Compare commits

..

2 Commits

4 changed files with 73 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="padding: 20px;">
<table width="600" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #eeeeee; background-color: #ffffff;">
<tr>
<td align="center" style="background-color: #007bff; padding: 40px;">
<h1 style="color: #ffffff; font-family: sans-serif; margin: 0;">Su cuenta ha sido bloqueada</h1>
</td>
</tr>
<tr>
<td align="center" style="padding: 40px">
<svg fill="#FF0000" width="128px" height="128px" viewBox="-3.2 -3.2 38.40 38.40" version="1.1" xmlns="http://www.w3.org/2000/svg" stroke="#FF0000" stroke-width="0.00032"><g id="SVGRepo_bgCarrier" stroke-width="0" transform="translate(6.4,6.4), scale(0.6)"><rect x="-3.2" y="-3.2" width="38.40" height="38.40" rx="19.2" fill="#1a5fb4" strokewidth="0"></rect></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="1.152"> <title>alert</title> <path d="M14.611 18.856c-0.346 0.352-0.52 0.782-0.52 1.292 0 0.551 0.197 1.014 0.59 1.389 0.363 0.346 0.799 0.519 1.309 0.519 0.521 0 0.971-0.188 1.346-0.566s0.562-0.828 0.562-1.35c0-0.504-0.182-0.943-0.545-1.318-0.363-0.381-0.801-0.571-1.311-0.571-0.567-0.001-1.044 0.201-1.431 0.605v0zM14.391 10.788c-0.299 0.451-0.447 1.011-0.447 1.679 0 0.545 0.092 1.146 0.276 1.802s0.435 1.271 0.751 1.846c0.428 0.779 0.76 1.169 0.994 1.169 0.24 0 0.557-0.305 0.949-0.914 0.346-0.539 0.622-1.152 0.83-1.841s0.312-1.332 0.312-1.93c0-0.902-0.244-1.6-0.73-2.092-0.363-0.375-0.805-0.563-1.326-0.563-0.703 0-1.24 0.282-1.609 0.844v0z"></path> </g><g id="SVGRepo_iconCarrier"> <title>alert</title> <path d="M14.611 18.856c-0.346 0.352-0.52 0.782-0.52 1.292 0 0.551 0.197 1.014 0.59 1.389 0.363 0.346 0.799 0.519 1.309 0.519 0.521 0 0.971-0.188 1.346-0.566s0.562-0.828 0.562-1.35c0-0.504-0.182-0.943-0.545-1.318-0.363-0.381-0.801-0.571-1.311-0.571-0.567-0.001-1.044 0.201-1.431 0.605v0zM14.391 10.788c-0.299 0.451-0.447 1.011-0.447 1.679 0 0.545 0.092 1.146 0.276 1.802s0.435 1.271 0.751 1.846c0.428 0.779 0.76 1.169 0.994 1.169 0.24 0 0.557-0.305 0.949-0.914 0.346-0.539 0.622-1.152 0.83-1.841s0.312-1.332 0.312-1.93c0-0.902-0.244-1.6-0.73-2.092-0.363-0.375-0.805-0.563-1.326-0.563-0.703 0-1.24 0.282-1.609 0.844v0z"></path> </g></svg>
</td>
</tr>
<tr>
<td style="padding: 30px; font-family: sans-serif; line-height: 1.5; color: #444444;">
<p>Lamentamos informarle de que el equipo de moderación ha tomado acciones en su cuenta</p>
<p>Su cuenta ha sido bloqueada indefinidamente y sus productos han sido eliminados de la tienda.</p>
<p>Si desea apelar, por favor, contacte con Soporte Técnico</p>
<p></p>
<p style="color: gray;">Este email ha sido enviado automaticamente, no responda a este correo.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
+31 -1
View File
@@ -1,12 +1,42 @@
from django.contrib import admin from django.contrib import admin
from .models import Category, Image, Product, Cart, CartItem, Order, OrderItem, OrderMessage, StockReservation, StockReservationItem, User, VerificationCode, SavedPaymentMethod from .models import Category, Image, Product, Cart, CartItem, Order, OrderItem, OrderMessage, StockReservation, StockReservationItem, User, VerificationCode, SavedPaymentMethod
# Register your models here. # Register your models here.
from django.shortcuts import redirect
from django.urls import path
from . import tasks
admin.site.register(Category) admin.site.register(Category)
admin.site.register(Image) admin.site.register(Image)
admin.site.register(User)
admin.site.register(VerificationCode) admin.site.register(VerificationCode)
@admin.register(User)
class UserAdmin(admin.ModelAdmin):
search_fields = ('username',)
def has_change_permission(self, request, obj = ...):
return super().has_change_permission(request, obj)
def get_urls(self):
urls = super().get_urls()
my_urls = [
path("<int:pk>/ban/", self.admin_site.admin_view(self.ban_view)),
]
return my_urls + urls
def ban_view(self, request, pk):
user = User.objects.get(pk=pk)
user.is_active = False # Desactivar cuenta de usuario
user.save() # Guardar datos
tasks.banear_usuario.delay(user.email)
# Borrar productos
productos = Product.objects.filter(user=user).all()
for producto in productos:
producto.delete()
return redirect("admin")
@admin.register(Product) @admin.register(Product)
class ProductAdmin(admin.ModelAdmin): class ProductAdmin(admin.ModelAdmin):
+10
View File
@@ -20,6 +20,16 @@ def enviar_correo_bienvenida(email_usuario: str, nombre_usuario: str):
send_hemail(email_usuario, "Inicio de Sesión correcto", html_content, "Has iniciado sesión...") send_hemail(email_usuario, "Inicio de Sesión correcto", html_content, "Has iniciado sesión...")
@shared_task @shared_task
def banear_usuario(email_usuario: str):
html_content = render_to_string(
'emails/ban.html',
{
},
using='jinja2'
)
send_hemail(email_usuario, "Cuenta Bloqueada", html_content, "Tu cuenta ha sido bloqueada...")
@shared_task
def enviar_correo_confirmacion(id: int): def enviar_correo_confirmacion(id: int):
usuario = User.objects.get(id=id) usuario = User.objects.get(id=id)
code = VerificationCode.objects.create( code = VerificationCode.objects.create(
@@ -0,0 +1,5 @@
{% extends "admin/submit_line.html" %}
{% load i18n admin_urls %}
{% block submit-row %}
<a href="../ban/" class="closelink" style="background:red;">BAN USER</a>
{% endblock %}