diff --git a/INSIGHTSAPI/pqrs/admin.py b/INSIGHTSAPI/pqrs/admin.py new file mode 100644 index 0000000..4a8c8f5 --- /dev/null +++ b/INSIGHTSAPI/pqrs/admin.py @@ -0,0 +1,11 @@ +from django.contrib import admin + +from .models import PQRS + + +@admin.register(PQRS) +class PQRSAdmin(admin.ModelAdmin): + list_display = ("reason", "user", "management", "created_at") + search_fields = ("reason", "user", "management", "created_at") + list_filter = ("reason", "management", "created_at") + readonly_fields = ("created_at",) diff --git a/INSIGHTSAPI/pqrs/views.py b/INSIGHTSAPI/pqrs/views.py index e55cc59..1a9ac4c 100644 --- a/INSIGHTSAPI/pqrs/views.py +++ b/INSIGHTSAPI/pqrs/views.py @@ -5,6 +5,7 @@ from django.core.mail import mail_admins, send_mail from rest_framework import status from rest_framework.generics import CreateAPIView, ListAPIView + from users.models import User from .models import PQRS, Management @@ -59,7 +60,7 @@ def create(self, request, *args, **kwargs): return response send_mail( "Nueva PQRS", - f"Se ha creado una nueva PQRS: {request.data['description']}", + f"{request.user.get_full_name()}-({request.user.cedula}) ha creado una nueva PQRS: {request.data['description']}", None, mail, ) diff --git a/INSIGHTSAPI/users/tests.py b/INSIGHTSAPI/users/tests.py index db08694..bb244ab 100644 --- a/INSIGHTSAPI/users/tests.py +++ b/INSIGHTSAPI/users/tests.py @@ -25,7 +25,6 @@ class LDAPAuthenticationTest(TestCase): def setUp(self): """Sets up the test client.""" self.client = Client() - print("wtf1") def test_ldap_connection(self): """Tests that the connection to the LDAP server is successful.""" @@ -34,7 +33,6 @@ def test_ldap_connection(self): ldap_bind_password = settings.AUTH_LDAP_BIND_PASSWORD conn = None try: - print("2") conn = ldap.initialize(ldap_server_uri) conn.simple_bind_s(ldap_bind_dn, ldap_bind_password) except ldap.LDAPError as err: @@ -42,7 +40,6 @@ def test_ldap_connection(self): finally: if conn: conn.unbind_s() - print("3") def test_login(self): """Tests that the user can login using LDAP.""" @@ -151,7 +148,6 @@ class UserTestCase(BaseTestCase): def setUp(self): """Sets up the test client.""" super().setUp() - print("wtf") self.user.user_permissions.add(Permission.objects.get(codename="upload_points")) def test_get_full_name(self):