Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
 def is_focal_point(self, request, view):
     return request.user.groups.filter(
         id=UNICEFAuditFocalPoint.as_group().id
     ).exists()
Exemplo n.º 7
0
 def is_focal_point(self, request, view):
     return request.user.groups.filter(
         id=UNICEFAuditFocalPoint.as_group().id).exists()