From 2474f5ba9a07e1173b9180baeec413b0438a3cec Mon Sep 17 00:00:00 2001 From: trevorskaggs Date: Wed, 3 Apr 2024 08:16:00 -0700 Subject: [PATCH] Add site to new incident email, order orgs, fix MR admin pane (#707) Co-authored-by: Trevor Skaggs --- incident/views.py | 4 +++- templates/new_incident_email.html | 2 +- templates/new_incident_email.txt | 2 +- vet/admin.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/incident/views.py b/incident/views.py index c47334f9..9a513cc2 100644 --- a/incident/views.py +++ b/incident/views.py @@ -1,4 +1,5 @@ from datetime import datetime +from django.contrib.sites.models import Site from django.core.mail import send_mail from django.template.loader import render_to_string from rest_framework import permissions, viewsets @@ -35,6 +36,7 @@ def perform_create(self, serializer): if not inc.training: emails = [user.email for user in ShelterlyUser.objects.filter(is_superuser=True)] message_data = { + 'site': Site.objects.get_current(), 'user_email': self.request.user.email, 'organization_name': inc.organization.name, 'organization_slug': inc.organization.slug, @@ -83,7 +85,7 @@ class OrganizationViewSet(viewsets.ModelViewSet): serializer_class = OrganizationSerializer def get_queryset(self): - queryset = Organization.objects.filter(id__in=self.request.user.organizations.all()) + queryset = Organization.objects.filter(id__in=self.request.user.organizations.all()).order_by('name') if self.request.GET.get('slug'): queryset = queryset.filter(slug=self.request.GET.get('slug')) diff --git a/templates/new_incident_email.html b/templates/new_incident_email.html index 00098936..1839646b 100644 --- a/templates/new_incident_email.html +++ b/templates/new_incident_email.html @@ -2,6 +2,6 @@ -{{ user_email }} from the {{ organization_name }} has created a new incident: {{ incident_name }}. Click

here

to open the incident. +{{ user_email }} from {{ organization_name }} has created a new incident: {{ incident_name }}. Click

here

to open the incident. \ No newline at end of file diff --git a/templates/new_incident_email.txt b/templates/new_incident_email.txt index 93bb65b6..3d7665b3 100644 --- a/templates/new_incident_email.txt +++ b/templates/new_incident_email.txt @@ -1 +1 @@ -{{ user_email }} from the {{ organization_name }} has created a new incident: {{ incident_name }}. Click

here

to open the incident. \ No newline at end of file +{{ user_email }} from the {{ organization_name }} has created a new incident: {{ incident_name }}. Click here to open the incident. \ No newline at end of file diff --git a/vet/admin.py b/vet/admin.py index 2a48e87a..0ddec0b1 100644 --- a/vet/admin.py +++ b/vet/admin.py @@ -6,7 +6,7 @@ class ExamQuestionAdmin(admin.ModelAdmin): list_display = ('id', 'name', 'default',) class MedicalRecordAdmin(admin.ModelAdmin): - list_display = ('id', 'patient', 'exam',) + list_display = ('id', 'patient',) class VetRequestAdmin(admin.ModelAdmin): list_display = ('id', 'requested_by', 'medical_record',)