From 05be5740e8cea28ed4c7659da357d1bf0e81d1a4 Mon Sep 17 00:00:00 2001 From: Heibert Date: Thu, 19 Sep 2024 17:09:22 -0500 Subject: [PATCH] Carousel images almost in production --- INSIGHTSAPI/api_token/cookie_jwt.py | 7 - .../migrations/0002_banner_order.py | 18 ++ .../migrations/0003_alter_banner_order.py | 18 ++ INSIGHTSAPI/carousel_image/models.py | 9 +- INSIGHTSAPI/carousel_image/serializer.py | 1 + INSIGHTSAPI/carousel_image/tests.py | 42 +++- INSIGHTSAPI/carousel_image/views.py | 10 + INSIGHTSAPI/hierarchy/admin.py | 12 +- INSIGHTSAPI/hierarchy/db_upload.py | 197 +++++++++--------- .../operational_risk/management/__init__.py | 0 .../management/commands/__init__.py | 0 .../management/commands/upload_events.py | 118 ----------- INSIGHTSAPI/services/test_endpoint.py | 39 ---- INSIGHTSAPI/services/urls.py | 5 +- 14 files changed, 196 insertions(+), 280 deletions(-) create mode 100644 INSIGHTSAPI/carousel_image/migrations/0002_banner_order.py create mode 100644 INSIGHTSAPI/carousel_image/migrations/0003_alter_banner_order.py delete mode 100644 INSIGHTSAPI/operational_risk/management/__init__.py delete mode 100644 INSIGHTSAPI/operational_risk/management/commands/__init__.py delete mode 100644 INSIGHTSAPI/operational_risk/management/commands/upload_events.py delete mode 100644 INSIGHTSAPI/services/test_endpoint.py diff --git a/INSIGHTSAPI/api_token/cookie_jwt.py b/INSIGHTSAPI/api_token/cookie_jwt.py index 2a7a91db..7a472e6a 100644 --- a/INSIGHTSAPI/api_token/cookie_jwt.py +++ b/INSIGHTSAPI/api_token/cookie_jwt.py @@ -53,10 +53,3 @@ def authenticate(self, request): return None validated_token = self.get_validated_token(raw_token) return self.get_user(validated_token), validated_token - - -def always_true(user): - """This function always return True""" - if user: - return True - return False diff --git a/INSIGHTSAPI/carousel_image/migrations/0002_banner_order.py b/INSIGHTSAPI/carousel_image/migrations/0002_banner_order.py new file mode 100644 index 00000000..bb238d37 --- /dev/null +++ b/INSIGHTSAPI/carousel_image/migrations/0002_banner_order.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.7 on 2024-09-19 11:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('carousel_image', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='banner', + name='order', + field=models.IntegerField(default=0), + ), + ] diff --git a/INSIGHTSAPI/carousel_image/migrations/0003_alter_banner_order.py b/INSIGHTSAPI/carousel_image/migrations/0003_alter_banner_order.py new file mode 100644 index 00000000..36b63baa --- /dev/null +++ b/INSIGHTSAPI/carousel_image/migrations/0003_alter_banner_order.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.7 on 2024-09-19 12:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('carousel_image', '0002_banner_order'), + ] + + operations = [ + migrations.AlterField( + model_name='banner', + name='order', + field=models.IntegerField(), + ), + ] diff --git a/INSIGHTSAPI/carousel_image/models.py b/INSIGHTSAPI/carousel_image/models.py index 0d7c75d8..abac9ffa 100644 --- a/INSIGHTSAPI/carousel_image/models.py +++ b/INSIGHTSAPI/carousel_image/models.py @@ -2,11 +2,18 @@ class Banner(models.Model): + order = models.IntegerField() title = models.CharField(max_length=100) link = models.URLField(blank=True, null=True) - active = models.BooleanField(default=True) image = models.ImageField(upload_to="carousel_images/banners/") created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title + + def save(self, *args, **kwargs): + if not self.pk: # only if the object is new + Banner.objects.filter(order__gte=self.order).update( + order=models.F("order") + 1 + ) + super().save(*args, **kwargs) diff --git a/INSIGHTSAPI/carousel_image/serializer.py b/INSIGHTSAPI/carousel_image/serializer.py index e402ea65..a0f12a71 100644 --- a/INSIGHTSAPI/carousel_image/serializer.py +++ b/INSIGHTSAPI/carousel_image/serializer.py @@ -1,3 +1,4 @@ +from attr import fields from rest_framework import serializers from .models import Banner diff --git a/INSIGHTSAPI/carousel_image/tests.py b/INSIGHTSAPI/carousel_image/tests.py index 28b5c32d..4334ea1e 100644 --- a/INSIGHTSAPI/carousel_image/tests.py +++ b/INSIGHTSAPI/carousel_image/tests.py @@ -11,16 +11,20 @@ def setUp(self): self.banner = Banner.objects.create( title="Test Banner", link="https://www.google.com", - active=True, image="carousel_images/banners/test.jpg", + order=1, ) + with open("static/test/Logo_cyc.png", "rb") as image_data: + self.image = SimpleUploadedFile( + "test3.jpg", image_data.read(), content_type="image/jpg" + ) def test_get_banner(self): Banner.objects.create( title="Test Banner 2", link="https://www.google.com", - active=True, image="carousel_images/banners/test2.jpg", + order=2, ) response = self.client.get(reverse("banners-list")) self.assertEqual(response.status_code, 200, response.data) @@ -35,28 +39,48 @@ def test_get_only_active_banner(self): link="https://www.google.com", active=False, image="carousel_images/banners/test2.jpg", + order=2, ) response = self.client.get(reverse("banners-list")) self.assertEqual(response.status_code, 200, response.data) self.assertEqual(len(response.data), 1) def test_create_banner(self): - with open("static/test/Logo_cyc.png", "rb") as image_data: - image = SimpleUploadedFile( - "test3.jpg", image_data.read(), content_type="image/jpg" - ) data = { "title": "Test Banner 3", "link": "https://www.google.com", - "active": True, - "image": image, + "image": self.image, + "order": 2, } + print("Create") response = self.client.post(reverse("banners-list"), data) + print("aqui",response.data.get("active")) self.assertEqual(response.status_code, 201, response.data) - self.assertEqual(Banner.objects.count(), 2) + get_banners = self.client.get(reverse("banners-list")) + self.assertEqual(len(get_banners.data), 2) def test_delete_banner(self): response = self.client.delete(reverse("banners-detail", args=[self.banner.id])) self.assertEqual(response.status_code, 204, response.data) self.assertEqual(Banner.objects.count(), 1) self.assertEqual(Banner.objects.filter(active=True).count(), 0) + + def test_update_banner_order(self): + banner2 = Banner.objects.create( + title="Test Banner 2", + link="https://www.google.com", + image="carousel_images/banners/test2.jpg", + order=2, + ) + response = self.client.post( + reverse("banners-list"), + { + "title": "Test Banner 3", + "link": "https://www.google.com", + "image": self.image, + "order": 2, + }, + ) + self.assertEqual(response.status_code, 201, response.data) + self.assertEqual(Banner.objects.count(), 3) + self.assertEqual(Banner.objects.get(id=banner2.id).order, 3) diff --git a/INSIGHTSAPI/carousel_image/views.py b/INSIGHTSAPI/carousel_image/views.py index fedbff39..b407026e 100644 --- a/INSIGHTSAPI/carousel_image/views.py +++ b/INSIGHTSAPI/carousel_image/views.py @@ -9,6 +9,16 @@ class BannerViewSet(viewsets.ModelViewSet): queryset = Banner.objects.filter(active=True) serializer_class = BannerSerializer + def create(self, request, *args, **kwargs): + print("Create2") + print("request:", request.data) + serializer = self.get_serializer(data=request.data) + serializer.is_valid(raise_exception=True) + print("serializer:", serializer.validated_data) + response = super().create(request, *args, **kwargs) + print(response.data) + return response + def destroy(self, request, *args, **kwargs): instance = self.get_object() instance.active = False diff --git a/INSIGHTSAPI/hierarchy/admin.py b/INSIGHTSAPI/hierarchy/admin.py index 50546f24..6e30182a 100644 --- a/INSIGHTSAPI/hierarchy/admin.py +++ b/INSIGHTSAPI/hierarchy/admin.py @@ -28,10 +28,14 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs): """Customize the queryset for the manager field.""" if db_field.name == "manager": # Customizing the queryset to show only users with a rank >= 4 or have the manage_area permission - kwargs["queryset"] = User.objects.filter( - Q(job_position__rank__gte=4) - | Q(user_permissions__codename="manage_area") - ).order_by("first_name") + kwargs["queryset"] = ( + User.objects.filter( + Q(job_position__rank__gte=4) + | Q(user_permissions__codename="manage_area") + ) + .distinct() + .order_by("first_name") + ) return super().formfield_for_foreignkey(db_field, request, **kwargs) diff --git a/INSIGHTSAPI/hierarchy/db_upload.py b/INSIGHTSAPI/hierarchy/db_upload.py index 4a9b0186..8347bc78 100644 --- a/INSIGHTSAPI/hierarchy/db_upload.py +++ b/INSIGHTSAPI/hierarchy/db_upload.py @@ -1,104 +1,105 @@ -import django +# ! Need be deleted +# import django -django.setup() +# django.setup() -from django.db import connections -from hierarchy.models import JobPosition -from users.models import User +# from django.db import connections +# from hierarchy.models import JobPosition +# from users.models import User -positions = [ - ("PRESIDENTE", "8"), - ("GERENTE GENERAL", "7"), - ("GERENTE DE OPERACIONES", "6"), - ("GERENTE DE PLANEACION", "6"), - ("GERENTE COMERCIAL Y DE LICITACIONES", "6"), - ("GERENTE DE RIESGO Y CONTROL INTERNO", "6"), - ("GERENTE DE CONTROL INTERNO", "6"), - ("GERENTE DE LEGAL Y DE RIESGO", "6"), - ("GERENTE DE CUENTAS", "6"), - ("GERENTE DE GESTION HUMANA", "6"), - ("GERENTE DE MERCADEO", "6"), - ("GERENTE DE CALIDAD", "6"), - ("GERENTE DE TECNOLOGIA", "6"), - ("GERENTE ADMINISTRATIVA", "6"), - ("GERENTE JR INFRAESTRUCTURA Y REDES", "5"), - ("GERENTE JR. DE APLICACIONES DE CONTACT CENTER", "5"), - ("GERENTE JR. DE MESA DE SERVICIO", "5"), - ("GERENTE DE CUENTAS JR", "5"), - ("DIRECTOR(A) DE DESARROLLO", "4"), - ("DIRECTOR(A) DE CALIDAD", "4"), - ("DIRECTOR(A) DE PROYECTO", "4"), - ("DIRECTOR(A) DE INVESTIGACIONES", "4"), - ( - "DIRECTOR(A) DE SEGURIDAD Y SALUD EN EL TRABAJO, GESTION AMBIENTAL Y BIENESTAR INTEGRAL", - "4", - ), - ("DIRECTOR(A) DE NOMINA Y ADMINISTRACION DE PERSONAL", "4"), - ("DIRECTOR(A) DE CONTROL INTERNO", "4"), - ("DIRECTOR(A) JURIDICO", "4"), - ("DIRECTOR(A) DE LICITACIONES", "4"), - ("DIRECTOR(A) DE RECURSOS FISICOS", "4"), - ("JEFE OPERACIONES OPERATIVO", "4"), - ("COORDINADOR(A) DE PROYECTO", "3"), - ("COORDINADOR DE COMUNICACIONES", "3"), - ("COORDINADOR(A) DE FORMACION Y DESARROLLO DEL TALENTO", "3"), - ("COORDINADOR(A) DE PLANEACION Y CALIDAD", "3"), - ("COORDINADOR(A) BI", "3"), - ("COORDINADOR CONTABLE", "3"), - ("JEFE OPERACIONES PROCESOS", "3"), - ("JEFE OPERACIONES JURIDICO", "3"), - ("AUXILIAR OPERATIVO", "2"), - ("DATA MARSHALL", "2"), - ("FORMADOR", "2"), - ("BACK OFFICE", "2"), - ("ABOGADO(A) JUNIOR", "2"), - ("AGENTE PROFESIONAL ABOGADO", "2"), - ("TEAM LIDER", "2"), - ("ANALISTA DE APLICACIONES DE CONTACT CENTER", "1"), - ("ANALISTA DE SOPORTE", "1"), - ("ANALISTA DE INFRAESTRUCTURA Y REDES", "1"), - ("ANALISTA DE BD Y APLICACIONES", "1"), - ("ANALISTA DE CALIDAD", "1"), - ("ANALISTA DE SEGURIDAD Y SALUD EN EL TRABAJO Y MEDIO AMBIENTE", "1"), - ("ANALISTA JURIDICO", "1"), - ("ANALISTA DE INVESTIGACION", "1"), - ("ANALISTA GESTION HUMANA", "1"), - ("ANALISTA BI", "1"), - ("ASESOR(A) COMERCIAL", "1"), - ("ASESOR(A) DE SERVICIO AL CLIENTE", "1"), - ("ASESOR(A) SENIOR", "1"), - ("ASESOR(A) DE NEGOCIACION", "1"), - ("INVESTIGADOR(A) DE CAMPO", "1"), - ("GESTOR DE COBRANZA MOVIL Y EN SITIO", "1"), - ("OPERADOR LOGISTICO", "1"), - ("ASESOR(A) DE NEGOCIACION JR", "1"), - ("AGENTE PROFESIONAL MINERO DE DATOS", "1"), - ("AGENTE VIDEOLLAMADA Y LENGUAJE DE SEÑAS", "1"), - ("AGENTE PROFESIONAL PSICOLOGA", "1"), - ("AGENTE BILINGÜE TECNICO", "1"), - ("AGENTE TECNICO", "1"), - ("AUXILIAR ADMINISTRATIVO", "1"), - ("AUXILIAR DE LICITACION", "1"), - ("AUXILIAR CONTABLE", "1"), - ("AUXILIAR DE CONTROL DE ACCESOS", "1"), - ("AUXILIAR DE MANTENIMIENTO", "1"), - ("SENA PRODUCTIVA", "1"), - ("SENA LECTIVA", "1"), - ("SERVICIOS GENERALES", "1"), - ("SUPERVISOR(A) DE CALIDAD", "1"), -] +# positions = [ +# ("PRESIDENTE", "8"), +# ("GERENTE GENERAL", "7"), +# ("GERENTE DE OPERACIONES", "6"), +# ("GERENTE DE PLANEACION", "6"), +# ("GERENTE COMERCIAL Y DE LICITACIONES", "6"), +# ("GERENTE DE RIESGO Y CONTROL INTERNO", "6"), +# ("GERENTE DE CONTROL INTERNO", "6"), +# ("GERENTE DE LEGAL Y DE RIESGO", "6"), +# ("GERENTE DE CUENTAS", "6"), +# ("GERENTE DE GESTION HUMANA", "6"), +# ("GERENTE DE MERCADEO", "6"), +# ("GERENTE DE CALIDAD", "6"), +# ("GERENTE DE TECNOLOGIA", "6"), +# ("GERENTE ADMINISTRATIVA", "6"), +# ("GERENTE JR INFRAESTRUCTURA Y REDES", "5"), +# ("GERENTE JR. DE APLICACIONES DE CONTACT CENTER", "5"), +# ("GERENTE JR. DE MESA DE SERVICIO", "5"), +# ("GERENTE DE CUENTAS JR", "5"), +# ("DIRECTOR(A) DE DESARROLLO", "4"), +# ("DIRECTOR(A) DE CALIDAD", "4"), +# ("DIRECTOR(A) DE PROYECTO", "4"), +# ("DIRECTOR(A) DE INVESTIGACIONES", "4"), +# ( +# "DIRECTOR(A) DE SEGURIDAD Y SALUD EN EL TRABAJO, GESTION AMBIENTAL Y BIENESTAR INTEGRAL", +# "4", +# ), +# ("DIRECTOR(A) DE NOMINA Y ADMINISTRACION DE PERSONAL", "4"), +# ("DIRECTOR(A) DE CONTROL INTERNO", "4"), +# ("DIRECTOR(A) JURIDICO", "4"), +# ("DIRECTOR(A) DE LICITACIONES", "4"), +# ("DIRECTOR(A) DE RECURSOS FISICOS", "4"), +# ("JEFE OPERACIONES OPERATIVO", "4"), +# ("COORDINADOR(A) DE PROYECTO", "3"), +# ("COORDINADOR DE COMUNICACIONES", "3"), +# ("COORDINADOR(A) DE FORMACION Y DESARROLLO DEL TALENTO", "3"), +# ("COORDINADOR(A) DE PLANEACION Y CALIDAD", "3"), +# ("COORDINADOR(A) BI", "3"), +# ("COORDINADOR CONTABLE", "3"), +# ("JEFE OPERACIONES PROCESOS", "3"), +# ("JEFE OPERACIONES JURIDICO", "3"), +# ("AUXILIAR OPERATIVO", "2"), +# ("DATA MARSHALL", "2"), +# ("FORMADOR", "2"), +# ("BACK OFFICE", "2"), +# ("ABOGADO(A) JUNIOR", "2"), +# ("AGENTE PROFESIONAL ABOGADO", "2"), +# ("TEAM LIDER", "2"), +# ("ANALISTA DE APLICACIONES DE CONTACT CENTER", "1"), +# ("ANALISTA DE SOPORTE", "1"), +# ("ANALISTA DE INFRAESTRUCTURA Y REDES", "1"), +# ("ANALISTA DE BD Y APLICACIONES", "1"), +# ("ANALISTA DE CALIDAD", "1"), +# ("ANALISTA DE SEGURIDAD Y SALUD EN EL TRABAJO Y MEDIO AMBIENTE", "1"), +# ("ANALISTA JURIDICO", "1"), +# ("ANALISTA DE INVESTIGACION", "1"), +# ("ANALISTA GESTION HUMANA", "1"), +# ("ANALISTA BI", "1"), +# ("ASESOR(A) COMERCIAL", "1"), +# ("ASESOR(A) DE SERVICIO AL CLIENTE", "1"), +# ("ASESOR(A) SENIOR", "1"), +# ("ASESOR(A) DE NEGOCIACION", "1"), +# ("INVESTIGADOR(A) DE CAMPO", "1"), +# ("GESTOR DE COBRANZA MOVIL Y EN SITIO", "1"), +# ("OPERADOR LOGISTICO", "1"), +# ("ASESOR(A) DE NEGOCIACION JR", "1"), +# ("AGENTE PROFESIONAL MINERO DE DATOS", "1"), +# ("AGENTE VIDEOLLAMADA Y LENGUAJE DE SEÑAS", "1"), +# ("AGENTE PROFESIONAL PSICOLOGA", "1"), +# ("AGENTE BILINGÜE TECNICO", "1"), +# ("AGENTE TECNICO", "1"), +# ("AUXILIAR ADMINISTRATIVO", "1"), +# ("AUXILIAR DE LICITACION", "1"), +# ("AUXILIAR CONTABLE", "1"), +# ("AUXILIAR DE CONTROL DE ACCESOS", "1"), +# ("AUXILIAR DE MANTENIMIENTO", "1"), +# ("SENA PRODUCTIVA", "1"), +# ("SENA LECTIVA", "1"), +# ("SERVICIOS GENERALES", "1"), +# ("SUPERVISOR(A) DE CALIDAD", "1"), +# ] -for name, rank in positions: - JobPosition.objects.get_or_create(name=name, rank=rank) +# for name, rank in positions: +# JobPosition.objects.get_or_create(name=name, rank=rank) -with connections["staffnet"].cursor() as cursor: - cursor.execute("SELECT cargo, cedula FROM employment_information") - for cargo, cedula in cursor.fetchall(): - try: - user = User.objects.get(cedula=cedula) - user.job_title = cargo - user.save() - except User.DoesNotExist: - print(f"User with cedula {cedula} not found") - continue \ No newline at end of file +# with connections["staffnet"].cursor() as cursor: +# cursor.execute("SELECT cargo, cedula FROM employment_information") +# for cargo, cedula in cursor.fetchall(): +# try: +# user = User.objects.get(cedula=cedula) +# user.job_title = cargo +# user.save() +# except User.DoesNotExist: +# print(f"User with cedula {cedula} not found") +# continue diff --git a/INSIGHTSAPI/operational_risk/management/__init__.py b/INSIGHTSAPI/operational_risk/management/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/INSIGHTSAPI/operational_risk/management/commands/__init__.py b/INSIGHTSAPI/operational_risk/management/commands/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/INSIGHTSAPI/operational_risk/management/commands/upload_events.py b/INSIGHTSAPI/operational_risk/management/commands/upload_events.py deleted file mode 100644 index f34b32f8..00000000 --- a/INSIGHTSAPI/operational_risk/management/commands/upload_events.py +++ /dev/null @@ -1,118 +0,0 @@ -"""This module contains the command to update the events from the external DB.""" -import os -import logging -from operational_risk.models import Events, EventClass, Level, Process, LostType, ProductLine -from django.core.management.base import BaseCommand -from ftfy import fix_text -import mysql.connector - - - -logger = logging.getLogger("requests") - - -class Command(BaseCommand): - """Class to update the events from the external DB""" - - help = "Update the events from the external DB" - - def handle(self, *args, **options): - """Method to handle the command""" - connection = mysql.connector.connect( - host="172.16.0.6", - user="root", - password=os.environ["LEYES"], - database="userscyc", - ) - cursor = connection.cursor(dictionary=True) - cursor.execute("SELECT * FROM userscyc.ero_claseevento") - event_class = cursor.fetchall() - cursor.execute("SELECT * FROM userscyc.ero_perdidas") - lost_type = cursor.fetchall() - cursor.execute("SELECT * FROM userscyc.ero_procesos") - process = cursor.fetchall() - cursor.execute("SELECT * FROM userscyc.ero_productos") - product = cursor.fetchall() - cursor.execute("SELECT * FROM userscyc.ero_eventos") - events = cursor.fetchall() - cursor.close() - - for event_class_row in event_class: - EventClass.objects.get_or_create( - pk=event_class_row["id"], name=fix_text(event_class_row["claseevento"]) - ) - for lost_type_row in lost_type: - LostType.objects.get_or_create( - pk=lost_type_row["id"], name=fix_text(lost_type_row["perdida"]) - ) - for process_row in process: - Process.objects.get_or_create( - pk=process_row["id"], name=fix_text(process_row["proceso"]) - ) - for product_row in product: - ProductLine.objects.get_or_create( - pk=product_row["id"], name=fix_text(product_row["producto"]) - ) - for event_row in events: - # Fix the values of the dictionary - for key, value in event_row.items(): - if isinstance(value, str): - event_row[key] = fix_text(value) - elif isinstance(value, int): - pass - event_class = EventClass.objects.get(id=event_row["clase_evento"]) - level = None - if event_row["nivel"] == "BAJO": - level, _ = Level.objects.get_or_create(name="BAJO") - elif event_row["nivel"] == "MEDIO": - level, _ = Level.objects.get_or_create(name="MEDIO") - elif event_row["nivel"] == "ALTO": - level, _ = Level.objects.get_or_create(name="ALTO") - process = Process.objects.get(id=event_row["proceso"]) - product = ProductLine.objects.get(id=event_row["linea_producto"]) - dates = [ - "fechainicio_evento", - "fechafin_evento", - "fechahora_descubrimiento", - "fecha_contabilizacion", - "fechacierre_incidencia" - ] - for date in dates: - if event_row[date] == "0000-00-00": - event_row[date] = None - if event_row["clasificacion"] == "CRITICO": - event_row["critico"] = True - else: - event_row["critico"] = False - if event_row["estadoactual_incidencia"] == "CERRADO": - event_row["estado"] = False - else: - event_row["estado"] = True - print(event_row["id"]) - Events.objects.get_or_create( - pk=event_row["id"], - start_date=event_row["fechainicio_evento"], - end_date=event_row["fechafin_evento"], - discovery_date=event_row["fechahora_descubrimiento"], - accounting_date=event_row["fecha_contabilizacion"], - currency=event_row["divisa"], - quantity=event_row["cuantia"], - recovered_quantity=event_row["cuantiatotal_recuperada"], - recovered_quantity_by_insurance=event_row["cuantiarecuperada_seguros"], - event_class=event_class, - reported_by=event_row["reportado"], - critical=event_row["critico"], - level=level, - plan=event_row["plan"], - event_title=event_row["evento"], - public_accounts_affected=event_row["cuentaspuc_afectadas"], - process=process, - lost_type=LostType.objects.get(id=event_row["tipoperdida"]), - description=event_row["descripcion_evento"], - product=product, - close_date=event_row["fechacierre_incidencia"], - learning=event_row["aprendizaje"], - status=event_row["estado"], - ) - connection.close() - self.stdout.write(self.style.SUCCESS("Events updated")) diff --git a/INSIGHTSAPI/services/test_endpoint.py b/INSIGHTSAPI/services/test_endpoint.py deleted file mode 100644 index ee94bd8b..00000000 --- a/INSIGHTSAPI/services/test_endpoint.py +++ /dev/null @@ -1,39 +0,0 @@ -import base64 -from django.conf import settings -from django.shortcuts import render -from django.http import HttpResponse - - -# return the view -def test_endpoint(request): - message = "Hello World" - subject = "Test" - with open(str(settings.STATIC_ROOT) + "/payslip/just_logo.png", "rb") as logo: - logo = logo.read() - logo = base64.b64encode(logo).decode("utf-8") - payslip = { - "title": "Test fecha", - "identification": "1234567890", - "name": "Test name", - "position": "Test position", - "salary": 1000000, - "total_deductions": 200000, - "net_pay": 1000000, - "days": 15, - "gross_earnings": 1000000, - "healthcare_contribution": 100000, - "pension_contribution": 100000, - "tax_withholding": 100000, - "additional_deductions": 100000, - "biweekly_period": 1000000, - "transport_allowance": 100000, - "bonus_paycheck": 100000, - "apsalpen": 100000, - "solidarity_fund_percentage": '0,015', - "solidarity_fund": 150000, - } - return render( - request, - "payslip.html", - {"payslip": payslip, "logo": logo}, - ) diff --git a/INSIGHTSAPI/services/urls.py b/INSIGHTSAPI/services/urls.py index 4b2fbf0f..0990f483 100644 --- a/INSIGHTSAPI/services/urls.py +++ b/INSIGHTSAPI/services/urls.py @@ -7,9 +7,8 @@ trigger_error, get_holidays, save_answer, - check_answered + check_answered, ) -from .test_endpoint import test_endpoint urlpatterns = [ @@ -19,5 +18,3 @@ path("save-answer/", save_answer, name="save_answer"), path("check-answered/", check_answered, name="check_answered"), ] -if settings.DEBUG: - urlpatterns.append(path("test-endpoint/", test_endpoint, name="test_endpoint"))