Example #1
0
class ActivityReportAttachmentsViewSet(BaseTPMAttachmentsViewSet):
    serializer_class = ActivityReportSerializer
    permission_classes = BaseTPMViewSet.permission_classes + [
        get_permission_for_targets('tpm.tpmactivity.report_attachments')
    ]

    def get_view_name(self):
        return _('Reports by Task')

    def get_parent_filter(self):
        parent = self.get_parent_object()
        if not parent:
            return {}

        return {
            'code': 'activity_report',
            'content_type_id':
            ContentType.objects.get_for_model(TPMActivity).id,
            'object_id__in': parent.tpm_activities.values_list('id',
                                                               flat=True),
        }

    def perform_create(self, serializer):
        serializer.save(
            content_type=ContentType.objects.get_for_model(TPMActivity))
Example #2
0
class ReportAttachmentsViewSet(BaseAuditAttachmentsViewSet):
    serializer_class = ReportAttachmentSerializer
    permission_classes = BaseAuditViewSet.permission_classes + [
        get_permission_for_targets('audit.engagement.report_attachments')
    ]

    def get_view_name(self):
        return _('Report Attachments')

    def get_parent_filter(self):
        filters = super().get_parent_filter()
        filters.update({'code': 'audit_report'})
        return filters
Example #3
0
class VisitReportAttachmentsViewSet(BaseTPMAttachmentsViewSet):
    serializer_class = TPMVisitReportAttachmentsSerializer
    permission_classes = BaseTPMViewSet.permission_classes + [
        get_permission_for_targets('tpm.tpmvisit.report_attachments')
    ]

    def get_view_name(self):
        return _('Related Documents')

    def get_parent_filter(self):
        parent = self.get_parent_object()
        if not parent:
            return {}

        return {
            'content_type_id': ContentType.objects.get_for_model(TPMVisit).id,
            'object_id': parent.pk,
        }

    def perform_create(self, serializer):
        serializer.save(content_object=self.get_parent_object())