Пример #1
0
    def get_xform_ids(self, request):
        if 'select_all' in self.request.POST:
            # Altough evaluating form_ids and sending to task would be cleaner,
            # heavier calls should be in an async task instead
            import urllib
            form_query_string = urllib.unquote(self.request.POST.get('select_all'))
            from django.http import HttpRequest, QueryDict

            _request = HttpRequest()
            _request.couch_user = request.couch_user
            _request.user = request.couch_user.get_django_user()
            _request.domain = self.domain
            _request.couch_user.current_domain = self.domain
            _request.can_access_all_locations = request.couch_user.has_permission(self.domain,
                                                                                  'access_all_locations')

            _request.GET = QueryDict(form_query_string)
            dispatcher = EditDataInterfaceDispatcher()
            xform_ids = dispatcher.dispatch(
                _request,
                render_as='form_ids',
                domain=self.domain,
                report_slug=BulkFormManagementInterface.slug,
                skip_permissions_check=True,
            )
        else:
            xform_ids = self.request.POST.getlist('xform_ids')

        return xform_ids
Пример #2
0
    def get_xform_ids(self, request):
        if 'select_all' in self.request.POST:
            # Altough evaluating form_ids and sending to task would be cleaner,
            # heavier calls should be in an async task instead
            import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
            form_query_string = six.moves.urllib.parse.unquote(self.request.POST.get('select_all'))
            from django.http import HttpRequest, QueryDict
            from django_otp.middleware import OTPMiddleware

            _request = HttpRequest()
            _request.couch_user = request.couch_user
            _request.user = request.couch_user.get_django_user()
            _request.domain = self.domain
            _request.couch_user.current_domain = self.domain
            _request.can_access_all_locations = request.couch_user.has_permission(self.domain,
                                                                                  'access_all_locations')
            _request.always_allow_project_access = True
            _request.session = request.session

            _request.GET = QueryDict(form_query_string)
            OTPMiddleware(lambda req: None)(_request)

            dispatcher = EditDataInterfaceDispatcher()
            xform_ids = dispatcher.dispatch(
                _request,
                render_as='form_ids',
                domain=self.domain,
                report_slug=BulkFormManagementInterface.slug,
                skip_permissions_check=True,
            )
        else:
            xform_ids = self.request.POST.getlist('xform_ids')

        return xform_ids