File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,21 @@ class DrefOperationalUpdateAdmin(admin.ModelAdmin):
4646 'national_society' ,
4747 'disaster_type' ,
4848 'images' ,
49+ 'users' ,
50+ 'event_map' ,
51+ 'images' ,
52+ 'budget_file' ,
53+ 'cover_image' ,
4954 )
5055 list_filter = ['dref' ]
5156
57+ def get_queryset (self , request ):
58+ return super ().get_queryset (request ).prefetch_related (
59+ 'planned_interventions' ,
60+ 'needs_identified' ,
61+ 'national_society_actions' ,
62+ 'users'
63+ )
5264
5365@admin .register (DrefFinalReport )
5466class DrefFinalReportAdmin (admin .ModelAdmin ):
Original file line number Diff line number Diff line change @@ -78,10 +78,25 @@ class DrefOperationalUpdateViewSet(viewsets.ModelViewSet):
7878 filterset_class = DrefOperationalUpdateFilter
7979
8080 def get_queryset (self ):
81- return DrefOperationalUpdate .objects .prefetch_related (
82- 'dref__planned_interventions' ,
83- 'dref__needs_identified' ,
84- 'dref__national_society_actions' ,
81+ return DrefOperationalUpdate .objects .filter (
82+ models .Q (created_by = self .request .user ) |
83+ models .Q (users = self .request .user )
84+ ).select_related (
85+ 'national_society' ,
86+ 'national_society' ,
87+ 'disaster_type' ,
88+ 'event_map' ,
89+ 'cover_image' ,
90+ 'budget_file' ,
91+ 'assessment_report'
92+ ).prefetch_related (
93+ 'dref' ,
94+ 'planned_interventions' ,
95+ 'needs_identified' ,
96+ 'national_society_actions' ,
97+ 'users' ,
98+ 'images' ,
99+ 'photos' ,
85100 ).order_by ('-created_at' ).distinct ()
86101
87102 @action (
You can’t perform that action at this time.
0 commit comments