Merge branch 'master' into simplify

This commit is contained in:
Bojan Mihelac 2018-11-05 09:05:13 +01:00 committed by GitHub
commit baa65746bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 25 additions and 67 deletions

View File

@ -71,4 +71,3 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

View File

@ -4,10 +4,10 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

View File

@ -14,7 +14,7 @@ django-import-export
:alt: Current version on PyPi
.. image:: http://readthedocs.org/projects/django-import-export/badge/?version=stable
:target: http://django-import-export.readthedocs.io/en/stable/
:target: https://django-import-export.readthedocs.io/en/stable/
:alt: Documentation
django-import-export is a Django application and library for importing
@ -36,7 +36,7 @@ Features:
.. image:: docs/_static/images/django-import-export-change.png
* Documentation: http://django-import-export.readthedocs.io/en/stable/
* Documentation: https://django-import-export.readthedocs.io/en/stable/
* GitHub: https://github.com/django-import-export/django-import-export/
* Free software: BSD license
* PyPI: https://pypi.org/project/django-import-export/

View File

@ -28,7 +28,7 @@ Widgets
.. autoclass:: import_export.widgets.DurationWidget
:members:
.. autoclass:: import_export.widgets.JSONWidget
:members:

View File

@ -17,7 +17,7 @@ Changelog
- JSONWidget for jsonb fields (#803)
- Add ExportActionMixin (#809)
- Add ExportActionMixin (#809)
- Add Import Export Permissioning #608 (#804)
@ -166,7 +166,7 @@ Changelog
- Append rows to Result object via function call to allow overriding (#462)
- Add get_resource_kwargs to allow passing request to resource (#457)
- Add get_resource_kwargs to allow passing request to resource (#457)
- Expose Django user to get_export_data() and export() (#447)

View File

@ -20,9 +20,9 @@ try:
except ImportError: # Django<2.0
from django.core.urlresolvers import reverse
from django.conf import settings
from django.template.defaultfilters import pluralize
from django.utils.decorators import method_decorator
from django.utils.module_loading import import_string
from django.utils.encoding import force_text
from django.views.decorators.http import require_POST
from .forms import (
@ -39,10 +39,6 @@ from .results import RowResult
from .tmp_storages import TempFolderStorage
from .signals import post_export, post_import
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
SKIP_ADMIN_LOG = getattr(settings, 'IMPORT_EXPORT_SKIP_ADMIN_LOG', False)
TMP_STORAGE_CLASS = getattr(settings, 'IMPORT_EXPORT_TMP_STORAGE_CLASS',

View File

@ -4,6 +4,7 @@ from django.utils.six import moves
import sys
import warnings
import tablib
from importlib import import_module
try:
from tablib.compat import xlrd
@ -35,12 +36,6 @@ except ImportError:
XLSX_IMPORT = False
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
class Format(object):
def get_title(self):
return type(self)
@ -77,7 +72,7 @@ class Format(object):
def get_content_type(self):
# For content types see
# http://www.iana.org/assignments/media-types/media-types.xhtml
# https://www.iana.org/assignments/media-types/media-types.xhtml
return 'application/octet-stream'
def can_import(self):
@ -156,7 +151,7 @@ class JSON(TextFormat):
class YAML(TextFormat):
TABLIB_MODULE = 'tablib.formats._yaml'
# See http://stackoverflow.com/questions/332129/yaml-mime-type
# See https://stackoverflow.com/questions/332129/yaml-mime-type
CONTENT_TYPE = 'text/yaml'

View File

@ -64,7 +64,7 @@ class ExportViewMixin(object):
class ExportViewFormMixin(ExportViewMixin, FormView):
def form_valid(self, form):
def form_valid(self, form):
formats = self.get_export_formats()
file_format = formats[
int(form.cleaned_data['file_format'])

View File

@ -9,7 +9,6 @@ from copy import deepcopy
from diff_match_patch import diff_match_patch
from django import VERSION
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management.color import no_style
@ -19,6 +18,7 @@ from django.db.models.query import QuerySet
from django.db.transaction import TransactionManagementError
from django.utils import six
from django.utils.safestring import mark_safe
from django.utils.encoding import force_text
from . import widgets
from .fields import Field
@ -34,10 +34,6 @@ except ImportError:
from django.db.models.fields.related import ForeignObjectRel
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
logger = logging.getLogger(__name__)
# Set default logging handler to avoid "No handler found" warnings.

View File

@ -4,18 +4,13 @@ from __future__ import unicode_literals
from decimal import Decimal
from datetime import datetime, date
from django.utils import datetime_safe, timezone, six
from django.utils.encoding import smart_text
from django.utils.encoding import smart_text, force_text
from django.utils.dateparse import parse_duration
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
import json
import ast
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
class Widget(object):
"""
@ -269,7 +264,7 @@ class SimpleArrayWidget(Widget):
def render(self, value, obj=None):
return self.separator.join(six.text_type(v) for v in value)
class JSONWidget(Widget):
"""
Widget for a JSON object (especially required for jsonb fields in PostgreSQL database.)
@ -310,7 +305,7 @@ class ForeignKeyWidget(Widget):
from import_export import fields, resources
from import_export.widgets import ForeignKeyWidget
class BookResource(resources.ModelResource):
author = fields.Field(
column_name='author',

View File

@ -1,5 +1,4 @@
from distutils.core import setup
from setuptools import find_packages
from setuptools import find_packages, setup
VERSION = __import__("import_export").__version__

View File

@ -64,7 +64,7 @@ class ImportExportAdminIntegrationTest(TestCase):
response = self.client.post('/admin/core/book/process_import/', data,
follow=True)
self.assertEqual(response.status_code, 200)
self.assertContains(response,
self.assertContains(response,
_('Import finished, with {} new and {} updated {}.').format(
1, 0, Book._meta.verbose_name_plural)
)
@ -101,7 +101,7 @@ class ImportExportAdminIntegrationTest(TestCase):
response = self.client.post('/admin/core/book/process_import/', data,
follow=True)
self.assertEqual(response.status_code, 200)
self.assertContains(response,
self.assertContains(response,
_('Import finished, with {} new and {} updated {}.').format(
1, 0, Book._meta.verbose_name_plural)
)
@ -207,7 +207,7 @@ class ImportExportAdminIntegrationTest(TestCase):
self.assertEqual(child.object_id, str(1))
def test_logentry_creation_with_import_obj_exception(self):
# from http://mail.python.org/pipermail/python-dev/2008-January/076194.html
# from https://mail.python.org/pipermail/python-dev/2008-January/076194.html
def monkeypatch_method(cls):
def decorator(func):
setattr(cls, func.__name__, func)

View File

@ -4,11 +4,7 @@ from __future__ import unicode_literals
import os
from django.test import TestCase
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
from django.utils.encoding import force_text
from import_export.formats import base_formats

View File

@ -2,18 +2,10 @@ from __future__ import unicode_literals
import os.path
from django.contrib.auth import get_permission_codename
from django.contrib.auth.models import Permission
from django.test.utils import override_settings
from django.test.testcases import TestCase
from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
from django.utils.translation import ugettext_lazy as _
from django.contrib.admin.models import LogEntry
from tablib import Dataset
from core.admin import BookAdmin, AuthorAdmin, BookResource
from core.models import Category, Parent, Book
class ImportExportPermissionTest(TestCase):

View File

@ -1,12 +1,12 @@
from __future__ import unicode_literals
import tablib
from collections import OrderedDict
from copy import deepcopy
from datetime import date
from decimal import Decimal
from unittest import skip, skipUnless
from django import VERSION
from django.conf import settings
from django.contrib.auth.models import User
from django.db import IntegrityError, DatabaseError
@ -14,6 +14,7 @@ from django.db.models import Count
from django.db.models.fields import FieldDoesNotExist
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
from django.utils.html import strip_tags
from django.utils.encoding import force_text
from import_export import fields, resources, results, widgets
from import_export.instance_loaders import ModelInstanceLoader
@ -24,16 +25,6 @@ from ..models import (
WithFloatField, Person, Role
)
try:
from collections import OrderedDict
except ImportError:
from django.utils.datastructures import SortedDict as OrderedDict
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
class MyResource(resources.Resource):
name = fields.Field()

View File

@ -3,7 +3,6 @@ from __future__ import unicode_literals
from decimal import Decimal
from datetime import date, datetime, time, timedelta
from unittest import SkipTest
from django.test.utils import override_settings
from django.test import TestCase

Binary file not shown.

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from django.conf.urls import url, include
from django.conf.urls import url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin