Skip to content

Commit

Permalink
Merge pull request #149 from CodeHive-Solutions/dev
Browse files Browse the repository at this point in the history
Add admin interface for PQRS model and enhance email notification wit…
  • Loading branch information
Heibert authored Dec 10, 2024
2 parents fbeb888 + 6c57ba7 commit 946d841
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 11 additions & 0 deletions INSIGHTSAPI/pqrs/admin.py
Original file line number Diff line number Diff line change
@@ -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",)
3 changes: 2 additions & 1 deletion INSIGHTSAPI/pqrs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
4 changes: 0 additions & 4 deletions INSIGHTSAPI/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -34,15 +33,13 @@ 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:
self.fail(f"Error: {err}")
finally:
if conn:
conn.unbind_s()
print("3")

def test_login(self):
"""Tests that the user can login using LDAP."""
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 946d841

Please sign in to comment.