def changelist_view(self, request, extra_context=None):
        response = execute_empty_queryset_action(self, request)
        if response:
            return response

        if not is_search_request(request):
            self.init_parent_folder(request)
        else:
            self.reset_expanded_folders_pk(request)
        parent_folder = self.get_parent_folder(request)
        set_current_request(request)

        if not extra_context:
            extra_context = {}

        extra_context.update(self.init_changelist_view_options(request))

        if request.GET.get(IS_POPUP_VAR, None):
            extra_context.update({'select_button': True})

        if parent_folder:
            extra_context.update({'node': parent_folder})

        response = super(FileNodeAdmin, self).changelist_view(request, extra_context)
        if isinstance(response, HttpResponse) and parent_folder and not parent_folder.is_top_node():
            expanded_folders_pk = self.get_expanded_folders_pk(request)
            if not parent_folder.pk in expanded_folders_pk:
                expanded_folders_pk.append(parent_folder.pk)
                self.set_expanded_folders_pk(response, expanded_folders_pk)
        return response
示例#2
0
    def changelist_view(self, request, extra_context=None):
        response = execute_empty_queryset_action(self, request)
        if response:
            return response

        if not is_search_request(request):
            self.init_parent_folder(request)
        else:
            self.reset_expanded_folders_pk(request)
        parent_folder = self.get_parent_folder(request)
        set_current_request(request)

        if not extra_context:
            extra_context = {}

        extra_context.update(self.init_changelist_view_options(request))

        if request.GET.get(IS_POPUP_VAR, None):
            extra_context.update({'select_button': True})

        if parent_folder:
            extra_context.update({'node': parent_folder})

        response = super(FileNodeAdmin,
                         self).changelist_view(request, extra_context)
        if isinstance(response, HttpResponse
                      ) and parent_folder and not parent_folder.is_top_node():
            expanded_folders_pk = self.get_expanded_folders_pk(request)
            if not parent_folder.pk in expanded_folders_pk:
                expanded_folders_pk.append(parent_folder.pk)
                self.set_expanded_folders_pk(response, expanded_folders_pk)
        return response
示例#3
0
    def changelist_view(self, request, extra_context=None):
        response = execute_empty_queryset_action(self, request)
        if response:
            return response

        set_current_request(request)

        if not extra_context:
            extra_context = {}
        extra_context.update(self.get_changelist_view_options(request))

        if request.GET.get(IS_POPUP_VAR, None):
            extra_context.update({'select_button': True})

        response = super(BaseFileNodeAdmin, self) \
            .changelist_view(request, extra_context)
        return response
    def changelist_view(self, request, extra_context=None):
        response = execute_empty_queryset_action(self, request)
        if response:
            return response

        if not is_search_request(request):
            self.init_parent_folder(request)
        else:
            self.reset_expanded_folders_pk(request)
        parent_folder = self.get_parent_folder(request)
        set_current_request(request)

        if not extra_context:
            extra_context = {}

        extra_context.update(self.init_changelist_view_options(request))

        if app_settings.MEDIA_TREE_SWFUPLOAD:
            swfupload_upload_url = reverse('admin:media_tree_filenode_upload')
            #swfupload_flash_url = os.path.join(settings.MEDIA_URL, STATIC_SUBDIR, 'lib/swfupload/swfupload_fp10/swfupload.swf')
            swfupload_flash_url = reverse(
                'admin:media_tree_filenode_static_swfupload_swf')
            extra_context.update({
                'file_types': app_settings.MEDIA_TREE_ALLOWED_FILE_TYPES,
                'file_size_limit': app_settings.MEDIA_TREE_FILE_SIZE_LIMIT,
                'swfupload_flash_url': swfupload_flash_url,
                'swfupload_upload_url': swfupload_upload_url,
            })

        if request.GET.get(IS_POPUP_VAR, None):
            extra_context.update({'select_button': True})

        if parent_folder:
            extra_context.update({'node': parent_folder})

        response = super(FileNodeAdmin,
                         self).changelist_view(request, extra_context)
        if isinstance(response, HttpResponse
                      ) and parent_folder and not parent_folder.is_top_node():
            expanded_folders_pk = self.get_expanded_folders_pk(request)
            if not parent_folder.pk in expanded_folders_pk:
                expanded_folders_pk.append(parent_folder.pk)
                self.set_expanded_folders_pk(response, expanded_folders_pk)
        return response
    def changelist_view(self, request, extra_context=None):
        response = execute_empty_queryset_action(self, request)
        if response:
            return response

        if not is_search_request(request):
            self.init_parent_folder(request)
        else:
            self.reset_expanded_folders_pk(request)
        parent_folder = self.get_parent_folder(request)
        set_current_request(request)

        if not extra_context:
            extra_context = {}
        if app_settings.MEDIA_TREE_SWFUPLOAD:
            middleware = 'media_tree.middleware.SessionPostMiddleware'
            if not middleware in settings.MIDDLEWARE_CLASSES:
		pass
                #request.user.message_set.create(message=_('You need to put %s in your MIDDLEWARE_CLASSES setting to use SWFUpload.') % middleware)
            else:
                swfupload_upload_url = reverse('admin:media_tree_filenode_upload')
                #swfupload_flash_url = os.path.join(settings.MEDIA_URL, STATIC_SUBDIR, 'lib/swfupload/swfupload_fp10/swfupload.swf')
                swfupload_flash_url = reverse('admin:media_tree_filenode_static_swfupload_swf')
                extra_context.update({
                    'file_types': app_settings.MEDIA_TREE_ALLOWED_FILE_TYPES,
                    'file_size_limit': app_settings.MEDIA_TREE_FILE_SIZE_LIMIT,
                    'swfupload_flash_url': swfupload_flash_url,
                    'swfupload_upload_url': swfupload_upload_url,
                })
        if request.GET.get(IS_POPUP_VAR, None):
            extra_context.update({'select_button': True})

        if parent_folder:
            extra_context.update({'node': parent_folder})

        response = super(FileNodeAdmin, self).changelist_view(request, extra_context)
        if isinstance(response, HttpResponse) and parent_folder and not parent_folder.is_top_node():
            expanded_folders_pk = self.get_expanded_folders_pk(request)
            if not parent_folder.pk in expanded_folders_pk:
                expanded_folders_pk.append(parent_folder.pk)
                self.set_expanded_folders_pk(response, expanded_folders_pk)
        return response