def get_queryset(self): queryset = super().get_queryset() user_groups = self.request.user.groups.all() if UNICEFUser.as_group( ) in user_groups or UNICEFAuditFocalPoint.as_group() in user_groups: # no need to filter queryset pass elif Auditor.as_group() in user_groups: queryset = queryset.filter(staff_members__user=self.request.user) else: queryset = queryset.none() queryset = queryset.prefetch_related( 'partner', Prefetch('agreement', PurchaseOrder.objects.prefetch_related('auditor_firm'))) if self.action in ['list', 'export_list_csv']: queryset = queryset.filter( agreement__auditor_firm__unicef_users_allowed=self. unicef_engagements) return queryset
def get_queryset(self): queryset = super().get_queryset() user_groups = self.request.user.groups.all() if UNICEFUser.as_group() in user_groups or UNICEFAuditFocalPoint.as_group() in user_groups: # no need to filter queryset pass elif Auditor.as_group() in user_groups: queryset = queryset.filter(staff_members__user=self.request.user) else: queryset = queryset.none() return queryset
def get_queryset(self): queryset = super().get_queryset() user_groups = self.request.user.groups.all() if UNICEFUser.as_group( ) in user_groups or UNICEFAuditFocalPoint.as_group() in user_groups: # no need to filter queryset pass elif Auditor.as_group() in user_groups: queryset = queryset.filter(staff_members__user=self.request.user) else: queryset = queryset.none() return queryset
def get_queryset(self): queryset = super(EngagementViewSet, self).get_queryset() user_groups = self.request.user.groups.all() if UNICEFUser.as_group( ) in user_groups or UNICEFAuditFocalPoint.as_group() in user_groups: # no need to filter queryset pass elif Auditor.as_group() in user_groups: queryset = queryset.filter(staff_members__user=self.request.user) else: queryset = queryset.none() queryset = queryset.prefetch_related( 'partner', Prefetch('agreement', PurchaseOrder.objects.prefetch_related('auditor_firm'))) return queryset
def get_queryset(self): queryset = super().get_queryset() user_groups = self.request.user.groups.all() if UNICEFUser.as_group() in user_groups or UNICEFAuditFocalPoint.as_group() in user_groups: # no need to filter queryset pass elif Auditor.as_group() in user_groups: queryset = queryset.filter(staff_members__user=self.request.user) else: queryset = queryset.none() queryset = queryset.prefetch_related( 'partner', Prefetch('agreement', PurchaseOrder.objects.prefetch_related('auditor_firm')) ) if self.action in ['list', 'export_list_csv']: queryset = queryset.filter(agreement__auditor_firm__unicef_users_allowed=self.unicef_engagements) return queryset
def is_focal_point(self, request, view): return request.user.groups.filter( id=UNICEFAuditFocalPoint.as_group().id ).exists()
def is_focal_point(self, request, view): return request.user.groups.filter( id=UNICEFAuditFocalPoint.as_group().id).exists()