Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tox to manage tests with multiple environments #11

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hello - this project is looking for a new maintainer. Please open an issue if you'd like to help maintain.
Hello - this project is looking for a new maintainer. Please open an issue if you'd like to help maintain.

Most pressing issue is to support modern python/django See [#6](https://github.com/burke-software/django-admin-export/issues/6)

Expand Down Expand Up @@ -35,6 +35,13 @@ Running tests
2. ``pip install -e . -r test_requirements.txt``
3. ``py.test tests``

Or to run tests with all supported environments:

1. Acquire a checkout of the repository
2. Install tox with ``pip install tox``
3. ``tox``


Security
--------

Expand Down
5 changes: 3 additions & 2 deletions admin_export/templates/admin_export/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

{% block extrahead %}
{{ block.super }}
<script src="{% static "admin/js/jquery.min.js" %}"></script>
<script src="{% static "admin/js/vendor/jquery/jquery.min.js" %}"></script>
<script src="{% static "admin/js/jquery.init.js" %}"></script>
<script type="text/javascript">
(function ($) {
window.show_fields = function (event, model_ct, field, path, path_verbose) {
Expand All @@ -22,7 +23,7 @@
$('.check_field').prop('checked', checked);
});
});
}(jQuery));
}(django.jQuery));

</script>
{% endblock %}
Expand Down
9 changes: 5 additions & 4 deletions admin_export/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
from django.http.response import HttpResponse
from django.template import loader, Context
from django.template import Context, Engine
from django.utils.text import force_text
from django.views.generic import TemplateView
import csv
from report_utils.mixins import GetFieldsMixin, DataExportMixin
Expand Down Expand Up @@ -33,14 +34,14 @@
class ExtDataExportMixin(DataExportMixin):

def list_to_html_response(self, data, title='', header=None):
html = loader.get_template_from_string(HTML_TEMPLATE).render(Context(locals()))
html = Engine().from_string(HTML_TEMPLATE).render(Context(locals()))
return HttpResponse(html)

def list_to_csv_response(self, data, title='', header=None):
resp = HttpResponse(content_type="text/csv; charset=UTF-8")
cw = csv.writer(resp)
for row in chain([header] if header else [], data):
cw.writerow([unicode(s).encode(resp._charset) for s in row])
cw.writerow([force_text(s).encode(resp.charset) for s in row])
return resp


Expand Down Expand Up @@ -99,7 +100,7 @@ def post(self, request, **kwargs):
return self.list_to_xlsx_response(data_list, header=fields)

def get(self, request, *args, **kwargs):
if request.REQUEST.get("related"): # Dispatch to the other view
if request.GET.get("related", request.POST.get("related")): # Dispatch to the other view
return AdminExportRelated.as_view()(request=self.request)
return super(AdminExport, self).get(request, *args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
'Intended Audience :: System Administrators',
"License :: OSI Approved :: BSD License",
],
install_requires=['django-report-utils'],
install_requires=['django-report-utils', 'openpyxl'],
)
13 changes: 13 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tox]
envlist =
{py27}-django1{8,9,10}

[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/admin_export
commands = py.test tests
deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
-r{toxinidir}/test_requirements.txt