Esempio n. 1
0
    def get_response(self, request, resource_type, resource_id, args):

        super(BlockWithList, self).get_response(request, resource_type,
                                                resource_id, args)

        if args == "":

            context = {
                'block_type': self.name,
                'resource': self.resource,
                'user_actions': self._get_user_actions(request),
            }

            template_name = self.BLOCK_TEMPLATE
            return render_to_xml_response(template_name, context)

        elif args == self.KW_DATA:

            querySet = self._get_resource_list(request)
            #columnIndexNameMap is required for correct sorting behavior
            columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP
            #path to template used to generate json (optional)
            jsonTemplatePath = 'blocks/%s/data.json' % self.BLOCK_NAME

            querySet, dt_params = prepare_datatables_queryset(
                request, querySet, columnIndexNameMap)
            return render_datatables(request, querySet, dt_params,
                                     jsonTemplatePath)

        elif args == EDIT_MULTIPLE:

            if request.method == 'POST':

                return self._do_post_edit_multiple()

            querySet = self._get_resource_list(request)
            #columnIndexNameMap is required for correct sorting behavior
            columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP
            #path to template used to generate json (optional)
            jsonTemplatePath = 'blocks/%s/edit_multiple.json' % self.BLOCK_NAME

            querySet, dt_params = prepare_datatables_queryset(
                request, querySet, columnIndexNameMap)
            formset, records, moreData = self._get_records(request, querySet)

            return render_datatables(request,
                                     records,
                                     dt_params,
                                     jsonTemplatePath,
                                     moreData=moreData)

        elif args == CREATE:

            with transaction.commit_on_success():
                rv = self._add_resource(request)
            return rv

        else:
            raise NotImplementedError("args = %s" % args)
Esempio n. 2
0
    def get_response(self, request, resource_type, resource_id, args):

        super(BlockWithList, self).get_response(request, resource_type, resource_id, args)

        if args == "":

            context = {
                'block_type' : self.name,
                'resource'   : self.resource,
                'user_actions'    : self._get_user_actions(request),
            }

            template_name = self.BLOCK_TEMPLATE
            return render_to_xml_response(template_name, context)

        elif args == self.KW_DATA:

            querySet = self._get_resource_list(request) 
            #columnIndexNameMap is required for correct sorting behavior
            columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP
            #path to template used to generate json (optional)
            jsonTemplatePath = 'blocks/%s/data.json' % self.BLOCK_NAME

            querySet, dt_params = prepare_datatables_queryset(request, querySet, columnIndexNameMap)
            return render_datatables(request, querySet, dt_params, jsonTemplatePath)

        elif args == EDIT_MULTIPLE:

            if request.method == 'POST':

                return self._do_post_edit_multiple()
                    
            querySet = self._get_resource_list(request) 
            #columnIndexNameMap is required for correct sorting behavior
            columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP
            #path to template used to generate json (optional)
            jsonTemplatePath = 'blocks/%s/edit_multiple.json' % self.BLOCK_NAME

            querySet, dt_params = prepare_datatables_queryset(request, querySet, columnIndexNameMap)
            formset, records, moreData = self._get_records(request, querySet)

            return render_datatables(request, records, dt_params, jsonTemplatePath, moreData=moreData)
            
        elif args == CREATE:

            with transaction.commit_on_success():
                rv = self._add_resource(request)
            return rv

        else:
            raise NotImplementedError("args = %s" % args)
Esempio n. 3
0
    def get_response(self, request, resource_type, resource_id, args):

        try:
            rv = super(Block, self).get_response(request, resource_type,
                                                 resource_id, args)
        except NotImplementedError:
            # Not implemented args are implemented in this method
            pass

        if args == CONFIRM:
            for gmo in self.resource.basket:
                log.debug(u"Sto confermando un ordine gasista(%s)" % gmo)
                gmo.confirm()
                gmo.save()

            #IMPORTANT: unset args to compute table results!
            args = self.KW_DATA

        elif args == CREATE_PDF:
            rv = self._create_pdf()
        elif args == SENDME_PDF:
            rv = self._send_email_logged()

        #TODO FIXME: ugly patch to fix AFTERrecords.append( 6
        if args == self.KW_DATA:
            from gasistafelice.lib.views_support import prepare_datatables_queryset, render_datatables

            querySet = self._get_resource_list(request)
            #columnIndexNameMap is required for correct sorting behavior
            columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP
            #path to template used to generate json (optional)
            jsonTemplatePath = 'blocks/%s/data.json' % self.BLOCK_NAME

            querySet, dt_params = prepare_datatables_queryset(
                request, querySet, columnIndexNameMap)
            #TODO FIXME: AFTER 6
            formset, records, moreData = self._get_records(request, querySet)
            rv = render_datatables(request, records, dt_params,
                                   jsonTemplatePath)

        return rv
Esempio n. 4
0
    def get_response(self, request, resource_type, resource_id, args):

        try:
            rv = super(Block, self).get_response(request, resource_type, resource_id, args)
        except NotImplementedError:
            # Not implemented args are implemented in this method
            pass

        if args == CONFIRM:
            for gmo in self.resource.basket:
                log.debug(u"Sto confermando un ordine gasista(%s)" % gmo)
                gmo.confirm()
                gmo.save()

            #IMPORTANT: unset args to compute table results!
            args = self.KW_DATA

        elif args == CREATE_PDF:
            rv = self._create_pdf()
        elif args == SENDME_PDF:
            rv = self._send_email_logged()
        
        #TODO FIXME: ugly patch to fix AFTERrecords.append( 6
        if args == self.KW_DATA:
            from gasistafelice.lib.views_support import prepare_datatables_queryset, render_datatables
            
            querySet = self._get_resource_list(request) 
            #columnIndexNameMap is required for correct sorting behavior
            columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP
            #path to template used to generate json (optional)
            jsonTemplatePath = 'blocks/%s/data.json' % self.BLOCK_NAME

            querySet, dt_params = prepare_datatables_queryset(request, querySet, columnIndexNameMap)
            #TODO FIXME: AFTER 6 
            formset, records, moreData = self._get_records(request, querySet)
            rv = render_datatables(request, records, dt_params, jsonTemplatePath)

        return rv