Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
darklow committed Aug 18, 2016
2 parents 4f4ba73 + 8243d11 commit 9852fed
Show file tree
Hide file tree
Showing 25 changed files with 189 additions and 63 deletions.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
If this is a bug please specify versions you're using first.

Django version:
Django Suit version:
Python version:

Issue:
27 changes: 15 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@ language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
- pypy
env:
- DJANGO=1.4.20
- DJANGO=1.4.22
- DJANGO=1.5.12
- DJANGO=1.6.11
- DJANGO=1.7.7
- DJANGO=1.8.3
- DJANGO=1.7.11
- DJANGO=1.8.14
- DJANGO=1.9.9
- DJANGO=1.10
before_install:
- export DJANGO_SETTINGS_MODULE=suit.tests.settings
install:
- pip install -q Django==$DJANGO --use-mirrors
- pip install . --use-mirrors
- pip install -q Django==$DJANGO
- pip install .
script:
- python manage.py test suit
matrix:
exclude:
# Django doesn't support following combinations
- python: 3.3
env: DJANGO=1.4.20
- python: 3.4
env: DJANGO=1.4.20
env: DJANGO=1.4.22
- python: 2.6
env: DJANGO=1.6.11
- python: 2.6
env: DJANGO=1.7.7
env: DJANGO=1.7.11
- python: 2.6
env: DJANGO=1.8.3
env: DJANGO=1.8.14
- python: 2.6
env: DJANGO=1.9.9
- python: 2.6
env: DJANGO=1.10
- python: pypy
env: DJANGO=1.4.20
env: DJANGO=1.4.22
- python: pypy
env: DJANGO=1.5.12
- python: pypy
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Changelog
Only important changes are mentioned below. See `commit log <https://github.com/darklow/django-suit/commits/develop>`_, `closed issues <https://github.com/darklow/django-suit/issues?direction=desc&sort=updated&state=closed>`_ and `closed pull
requests <https://github.com/darklow/django-suit/pulls?q=sort%3Aupdated-desc+is%3Apr+is%3Aclosed>`_ for full changes.

v0.2.21 (2016-08-18)
--------------------

* [Fix] Django 1.10 compatibility and Travis tests fixes


v0.2.20 (2016-08-09)
--------------------

* [Fix] Django 1.10 compatibility fixes `#526 <https://github.com/darklow/django-suit/pull/526>`_


v0.2.19 (2016-06-23)
--------------------

Expand Down
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Build Status

Django Suit uses Travis CI to perform tests on different Django and Python versions.

Tested using Python: 2.5-3.4. Django: 1.4-1.8. Develop / Master:
Tested using Python: 2.5-3.4. Django: 1.4-1.10. Develop / Master:

.. |develop| image:: https://travis-ci.org/darklow/django-suit.png?branch=develop
:alt: Build Status - develop branch
Expand All @@ -62,3 +62,9 @@ Preview
.. image:: https://raw.github.com/darklow/django-suit/develop/docs/_static/img/django-suit.png
:alt: Django Suit Preview
:target: http://djangosuit.com/admin/


v2.0-dev
========

Check out new v2.0-dev version notes: https://github.com/darklow/django-suit/issues/475
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
# built documents.
#
# The short X.Y version.
version = '0.2.19'
version = '0.2.21'
# The full version, including alpha/beta/rc tags.
release = '0.2.19'
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 2 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Resources
* Github: https://github.com/darklow/django-suit
* Demo app on Github: https://github.com/darklow/django-suit-examples
* Changelog: `Changelog.rst <https://github.com/darklow/django-suit/blob/develop/CHANGELOG.rst>`_
* Supports: Django 1.4-1.9. Python: 2.6-3.4 |master|
* Supports: Django 1.4-1.10. Python: 2.6-3.4 |master|
* `Supported apps`_


Expand All @@ -47,9 +47,7 @@ Installation

1. You can get stable version of Django Suit by using pip or easy_install::

pip install django-suit==0.2.18
# or
easy_install django-suit==0.2.18
pip install django-suit==0.2.21

2. You will need to add the ``'suit'`` application to the ``INSTALLED_APPS`` setting of your Django project ``settings.py`` file.::

Expand Down
2 changes: 1 addition & 1 deletion suit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.2.19'
VERSION = '0.2.21'
7 changes: 3 additions & 4 deletions suit/templates/admin/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@
{% endif %}

{% block content %}
{% suit_django_version as django_version %}
<div id="content-main" class="inner-two-columns">

<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post"
id="{% firstof opts.model_name opts.module_name %}_form" class="form-horizontal">
id="{% firstof opts.model_name opts.module_name %}_form" class="form-horizontal" novalidate>

<div class="inner-right-column">

Expand All @@ -100,7 +99,7 @@ <h4 class="italic-title">{% trans 'tools'|capfirst %}</h4>
<ul class="box menu-box">
{% block object-tools-items %}
<li>
{% if django_version < 1.9 %}
{% if '1.9'|django_version_lt %}
<a href="history/" class="historylink">
{% else %}
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
Expand All @@ -116,7 +115,7 @@ <h4 class="italic-title">{% trans 'tools'|capfirst %}</h4>

{% if has_add_permission %}
<li>
{% if django_version < 1.9 %}
{% if '1.9'|django_version_lt %}
<a href="../add/">
{% else %}
<a href="{% url opts|admin_urlname:'add' %}">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<form id="changelist-form" action="" method="post"
{% if cl.formset.is_multipart %}
enctype="multipart/form-data"{% endif %} class="form-inline">{% csrf_token %}
enctype="multipart/form-data"{% endif %} class="form-inline" novalidate>{% csrf_token %}
{% if cl.formset %}
<div>{{ cl.formset.management_form }}</div>
{% endif %}
Expand Down
3 changes: 1 addition & 2 deletions suit/templates/admin/edit_inline/stacked.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{% load i18n admin_static admin_urls suit_tags %}
{% suit_django_version as django_version %}
<div class="inline-group {{ inline_admin_formset.opts.suit_classes }}" id="{{ inline_admin_formset.formset.prefix }}-group">
<h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
{{ inline_admin_formset.formset.management_form }}
{{ inline_admin_formset.formset.non_form_errors }}

{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
<h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;<span class="inline_label">{% if inline_admin_form.original %}
{% if django_version > 1.7 and inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">{{ inline_admin_form.original }}</a>
{% if '1.8'|django_version_gte and inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">{{ inline_admin_form.original }}</a>
{% else %}
{{ inline_admin_form.original }}
{% endif %}
Expand Down
5 changes: 2 additions & 3 deletions suit/templates/admin/edit_inline/tabular.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load i18n admin_static admin_modify suit_tags admin_urls %}
{% suit_django_version as django_version %}
<div class="inline-group {{ inline_admin_formset.opts.suit_classes }}" id="{{ inline_admin_formset.formset.prefix }}-group">
<div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
{{ inline_admin_formset.formset.management_form }}
Expand All @@ -16,7 +15,7 @@ <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
{% endif %}
{% endfor %}
{% if inline_admin_formset.opts.show_change_link and inline_admin_formset.opts.has_registered_model %}<th class="text-center">{% trans "Change" %}</th>{% endif %}
{% if django_version > 1.7 and inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
{% if '1.7'|django_version_gt and inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
</tr></thead>

<tbody>
Expand Down Expand Up @@ -62,7 +61,7 @@ <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
{% endfor %}
{% endfor %}
{% endfor %}
{% if django_version > 1.7 and inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}
{% if '1.8'|django_version_gte and inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}
<td class="text-center">
{% if inline_admin_form.original %}
<p><a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">{% trans "Change" %}</a></p>
Expand Down
5 changes: 2 additions & 3 deletions suit/templates/admin/page_submit_line.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{% load i18n admin_urls suit_tags %}
{% suit_django_version as django_version %}
<div class="submit-row clearfix">
{% if show_save %}<button type="submit" class="btn btn-high btn-info" name="_save">{% trans 'Save' %}</button>{% endif %}
{% if show_save_and_continue %}<button type="submit" name="_continue" class=" btn btn-high">{% trans 'Save and continue editing' %}</button>{% endif %}
{% if show_save_as_new %}<button type="submit" name="_saveasnew" class="btn">{% trans 'Save as new' %}</button>{%endif%}
{% if show_save_and_add_another %}<button type="submit" name="_addanother" class="btn">{% trans 'Save and add another' %}</button>{% endif %}

{% if show_delete_link %}
{% if django_version < 1.9 %}
{% if '1.9'|django_version_lt %}
<a href="delete/" class="text-error deletelink">{% trans "Delete" %}</a>
{% else %}
<a href="{% url opts|admin_urlname:'delete' original.pk|admin_urlquote %}" class="text-error deletelink">{% trans "Delete" %}</a>
Expand All @@ -17,7 +16,7 @@
{% if show_delete_link %}
<br>
{% endif %}
{% if django_version < 1.9 %}
{% if '1.9'|django_version_lt %}
<a href="delete-translation/?language={{ language }}" class="text-error deletelink delete-translation">{% blocktrans with language_name|lower as language %}Delete {{ language }} translation{% endblocktrans %}</a>
{% else %}
<a href="{% url opts|admin_urlname:'delete' original.pk|admin_urlquote %}-translation/?language={{ language }}" class="text-error deletelink delete-translation">{% blocktrans with language_name|lower as language %}Delete {{ language }} translation{% endblocktrans %}</a>
Expand Down
3 changes: 1 addition & 2 deletions suit/templates/admin/submit_line.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{% load i18n admin_urls suit_tags %}
{% suit_django_version as django_version %}
<div class="submit-row clearfix">
{% if show_save %}<button type="submit" class="btn btn-high btn-info" name="_save">{% trans 'Save' %}</button>{% endif %}
{% if show_save_and_continue %}<button type="submit" name="_continue" class=" btn btn-high">{% trans 'Save and continue editing' %}</button>{% endif %}
{% if show_save_as_new %}<button type="submit" name="_saveasnew" class="btn">{% trans 'Save as new' %}</button>{%endif%}
{% if show_save_and_add_another %}<button type="submit" name="_addanother" class="btn">{% trans 'Save and add another' %}</button>{% endif %}

{% if show_delete_link %}
{% if django_version < 1.9 %}
{% if '1.9'|django_version_lt %}
<a href="delete/" class="text-error deletelink">{% trans "Delete" %}</a>
{% else %}
{% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %}
Expand Down
7 changes: 6 additions & 1 deletion suit/templatetags/suit_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def get_menu(context, request):
# Django 1.8 uses request.current_app instead of context.current_app
template_response = get_admin_site(request.current_app).index(request)
else:
template_response = get_admin_site(context.current_app).index(request)
try:
template_response = get_admin_site(context.current_app).index(request)
# Django 1.10 removed the current_app parameter for some classes and functions.
# Check the release notes.
except AttributeError:
template_response = get_admin_site(context.request.resolver_match.namespace).index(request)

try:
app_list = template_response.context_data['app_list']
Expand Down
34 changes: 30 additions & 4 deletions suit/templatetags/suit_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def field_contents_foreign_linked(admin_field):

if not hasattr(admin_field.model_admin,
'linked_readonly_fields') or fieldname not in admin_field \
.model_admin \
.linked_readonly_fields:
.model_admin \
.linked_readonly_fields:
return displayed

try:
Expand Down Expand Up @@ -100,15 +100,41 @@ def suit_django_version():
return django_version


if django_version < 1.9:
@register.filter
def django_version_lt(string):
return django_version < str_to_version(string)


@register.filter
def django_version_lte(string):
return django_version <= str_to_version(string)


@register.filter
def django_version_gt(string):
return django_version > str_to_version(string)


@register.filter
def django_version_gte(string):
return django_version >= str_to_version(string)


def str_to_version(string):
return tuple([int(s) for s in string.split('.')])


if django_version < (1, 9):
# Add empty tags to avoid Django template errors if < Django 1.9
@register.simple_tag
def add_preserved_filters(*args, **kwargs):
pass

if django_version < 1.5:
if django_version < (1, 5):
# Add admin_urlquote filter to support Django 1.4
from django.contrib.admin.util import quote


@register.filter
def admin_urlquote(value):
return quote(value)
9 changes: 8 additions & 1 deletion suit/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import django
try:
# Django 1.9+
django.setup()
except Exception:
pass

from suit.tests.templatetags.suit_menu import SuitMenuTestCase, \
SuitMenuAdminRootURLTestCase, SuitMenuAdminI18NURLTestCase, \
SuitMenuAdminCustomURLTestCase
Expand All @@ -8,7 +15,6 @@
from suit.tests.widgets import WidgetsTestCase
from suit.tests.utils import UtilsTestCase


try:
# Django 1.7+
from django.test.runner import DiscoverRunner as DjangoTestSuiteRunner
Expand All @@ -18,6 +24,7 @@

class NoDbTestRunner(DjangoTestSuiteRunner):
"""A test suite runner that does not set up and tear down a database."""

def setup_databases(self):
"""Overrides DjangoTestSuiteRunner"""
pass
Expand Down
36 changes: 36 additions & 0 deletions suit/tests/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Album',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='Book',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64)),
],
options={
'ordering': ('-id',),
},
),
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64)),
],
),
]
Empty file.

0 comments on commit 9852fed

Please sign in to comment.