Skip to content

Commit 917dccf

Browse files
committed
Merge branch 'develop' – OpsLearning get_queryset for the Admin page
2 parents 3ed51b0 + 7d78342 commit 917dccf

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

notifications/templates/design/main_newop3.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!-- Main -->
22
{% load humanize %}
3+
{% load custom_tags %}
34

45
{% if records|length %}
56
{% for op in records %}

per/admin.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,23 @@ class OpsLearningAdmin(GotoNextModelAdmin):
198198
actions = ["export_selected_records"]
199199
_original_is_validated = False
200200

201+
def get_queryset(self, request):
202+
return (
203+
super()
204+
.get_queryset(request)
205+
.select_related(
206+
"appeal_code",
207+
)
208+
.prefetch_related(
209+
"sector",
210+
"sector_validated",
211+
"organization",
212+
"organization_validated",
213+
"per_component",
214+
"per_component_validated",
215+
)
216+
)
217+
201218
def get_fields(self, request, obj=None):
202219
if obj and obj.is_validated:
203220
return (

per/drf_views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,10 @@ def get_queryset(self):
792792
"appeal_code",
793793
).prefetch_related(
794794
"sector",
795-
"organization",
796-
"per_component",
797795
"sector_validated",
796+
"organization",
798797
"organization_validated",
798+
"per_component",
799799
"per_component_validated",
800800
"appeal_code__event__countries_for_preview",
801801
)
@@ -806,10 +806,10 @@ def get_queryset(self):
806806
)
807807
.prefetch_related(
808808
"sector",
809-
"organization",
810-
"per_component",
811809
"sector_validated",
810+
"organization",
812811
"organization_validated",
812+
"per_component",
813813
"per_component_validated",
814814
"appeal_code__event__countries_for_preview",
815815
)

0 commit comments

Comments
 (0)