Skip to content

Commit

Permalink
Merge branch 'release/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
abidibo committed Nov 3, 2022
2 parents a4afc9c + 4013f2b commit b2f2d15
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admin_export_action/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.0'
__version__ = '0.3.1'
4 changes: 3 additions & 1 deletion admin_export_action/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import uuid
import json
from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext_lazy as _
from django.core.serializers.json import DjangoJSONEncoder
from .config import get_config


Expand All @@ -14,7 +16,7 @@ def export_selected_objects(modeladmin, request, queryset):

if len(selected) > 1000:
session_key = "export_action_%s" % uuid.uuid4()
request.session[session_key] = selected
request.session[session_key] = json.dumps(selected, cls=DjangoJSONEncoder)
return HttpResponseRedirect("%s?ct=%s&session_key=%s" % (url, ct.pk, session_key))
else:
return HttpResponseRedirect(
Expand Down
3 changes: 3 additions & 0 deletions admin_export_action/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import absolute_import, unicode_literals

import importlib
import json

from django.conf import settings
from django.contrib.contenttypes.models import ContentType
Expand All @@ -26,6 +27,8 @@ class AdminExport(TemplateView):
def get_queryset(self, model_class):
if self.request.GET.get("session_key"):
ids = self.request.session[self.request.GET["session_key"]]
if type(ids) == str:
ids = json.loads(ids)
else:
ids = self.request.GET['ids'].split(',')
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='django-admin-export-action',
version='0.3.0',
version='0.3.1',
packages=['admin_export_action'],
include_package_data=True,
license='MIT License',
Expand Down
5 changes: 3 additions & 2 deletions testapp/app/app/tests/test_export_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.test import TestCase, RequestFactory
from django.urls import reverse
from django.utils.http import urlencode
from news.models import Attachment, Category, News, NewsTag, Video
from news.models import News, NewsTag
from news.admin import NewsAdmin


Expand Down Expand Up @@ -65,7 +65,8 @@ def test_export_selected_objects_session(self):
export_selected_objects(modeladmin, request, qs)
self.assertEqual(len(request.session), 1)
els = list(request.session.items())
self.assertEqual(els[0][1], qs.values_list('id'))
selected_ids = json.loads(els[0][1])
self.assertEqual(selected_ids, qs.values_list('id'))

def test_get_field_verbose_name(self):
res = report.get_field_verbose_name(News.objects, 'tags__name')
Expand Down
Binary file modified testapp/app/db.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion testapp/app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Django==4.1.1
django-baton==2.4.1
django-js-asset==1.2.2
django-mptt==0.14.0
easy-thumbnails==2.7.1
easy-thumbnails==2.8.3
et-xmlfile==1.0.1
google-api-core==1.23.0
google-api-python-client==1.12.8
Expand Down

0 comments on commit b2f2d15

Please sign in to comment.