Skip to content

Commit

Permalink
Merge branch 'release/1.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
hedleyroos committed Apr 27, 2016
2 parents e4ab3b9 + d119f73 commit 5205920
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 141 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
language: python
install:
- pip install tox
- pip install tox
script:
- tox
env:
- TOXENV=django14
- TOXENV=django15
- TOXENV=django16
- TOXENV=django17
- TOXENV=django18
- TOXENV=django19
8 changes: 6 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
Changelog
=========

1.9
---
#. Django 1.9 compatibility.

1.0.3
-----
#. Fixed Django 1.4 templatetag issues
#. Fixed Django 1.4 templatetag issues.

1.0.2
-----
#. Django 1.7 Compatibility
#. Django 1.7 compatibility.

1.0.1
-----
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) Praekelt Foundation
Copyright (c) Praekelt Consulting
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
10 changes: 10 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
24 changes: 20 additions & 4 deletions object_tools/management/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import django
from django.contrib.auth import models as auth_app
from django.db.models import signals

Expand All @@ -17,7 +18,10 @@ def _get_all_permissions(opts, tools):
return perms


def create_permissions(app, created_models, verbosity, **kwargs):
from django.db import DEFAULT_DB_ALIAS
#def create_permissions(app, created_models, verbosity=2, **kwargs):

def _create_permissions(**kwargs):
"""
Almost exactly the same as django.contrib.auth.management.__init__.py
"""
Expand Down Expand Up @@ -55,8 +59,20 @@ def create_permissions(app, created_models, verbosity, **kwargs):
name=name,
content_type=ctype
)
if verbosity >= 2:
if kwargs.get("verbosity", 2) >= 2:
print "Adding permission '%s'" % p

signals.post_syncdb.connect(create_permissions,
dispatch_uid="object_tools.management.create_permissions")
if django.VERSION >= (1, 7):
def create_permissions(app_config, verbosity=2, interactive=True, using=DEFAULT_DB_ALIAS, **kwargs):
return _create_permissions(verbosity=2, interactive=True, using=DEFAULT_DB_ALIAS, **kwargs)
else:
def create_permissions(app, created_models, **kwargs):
return _create_permissions(**kwargs)


if django.VERSION >= (1, 7):
signals.post_migrate.connect(create_permissions,
dispatch_uid="object_tools.management.create_permissions")
else:
signals.post_syncdb.connect(create_permissions,
dispatch_uid="object_tools.management.create_permissions")
6 changes: 5 additions & 1 deletion object_tools/sites.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db.models import get_models
try:
from django.apps import apps
get_models = apps.get_models
except ImportError:
from django.db.models import get_models


class AlreadyRegistered(Exception):
Expand Down
108 changes: 5 additions & 103 deletions object_tools/templates/admin/change_list.html
Original file line number Diff line number Diff line change
@@ -1,105 +1,7 @@
{% extends "admin/base_site.html" %}
{% load admin_list i18n object_tools_inclusion_tags admin_static %}
{% load url from future %}
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" />
{% if cl.formset %}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
{% endif %}
{% if cl.formset or action_form %}
{% url 'admin:jsi18n' as jsi18nurl %}
<script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
{% endif %}
{{ media.css }}
{% if not actions_on_top and not actions_on_bottom %}
<style>
#changelist table thead th:first-child {width: inherit}
</style>
{% endif %}
{% endblock %}

{% block extrahead %}
{{ block.super }}
{{ media.js }}
{% if action_form %}{% if actions_on_top or actions_on_bottom %}
<script type="text/javascript">
(function($) {
$(document).ready(function($) {
$("tr input.action-select").actions();
});
})(django.jQuery);
</script>
{% endif %}{% endif %}
{% endblock %}

{% block bodyclass %}change-list{% endblock %}

{% if not is_popup %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="../../">
{% trans "Home" %}
</a>
&rsaquo;
<a href="../">
{{ app_label|capfirst }}
</a>
&rsaquo;
{{ cl.opts.verbose_name_plural|capfirst }}
</div>
{% endblock %}
{% endif %}

{% block coltype %}flex{% endblock %}

{% block content %}
<div id="content-main">
{% block object-tools %}
{% if has_add_permission %}
<ul class="object-tools">
{% block object-tools-items %}
{% object_tools cl.model user %}
<li>
<a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
</a>
</li>
{% endblock %}
</ul>
{% endif %}
{% endblock %}
{% if cl.formset.errors %}
<p class="errornote">
{% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
</p>
{{ cl.formset.non_form_errors }}
{% endif %}
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
{% block search %}{% search_form cl %}{% endblock %}
{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

{% block filters %}
{% if cl.has_filters %}
<div id="changelist-filter">
<h2>{% trans 'Filter' %}</h2>
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
</div>
{% endif %}
{% endblock %}

<form id="changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}
{% if cl.formset %}
<div>{{ cl.formset.management_form }}</div>
{% endif %}
{% extends "../../admin/templates/admin/change_list.html" %}
{% load object_tools_inclusion_tags %}

{% block result_list %}
{% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
{% result_list cl %}
{% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
{% endblock %}
{% block pagination %}{% pagination cl %}{% endblock %}
</form>
</div>
</div>
{% block object-tools-items %}
{% object_tools cl.model user %}
{{ block.super }}
{% endblock %}
2 changes: 1 addition & 1 deletion object_tools/templates/object_tools/tool_base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_modify %}
{% load url from future %}
{% load url from object_tools_compat %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}admin/css/forms.css" />{% endblock %}

Expand Down
18 changes: 18 additions & 0 deletions object_tools/templatetags/object_tools_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Handle future url tag deprecation so we don't leave pre Django 1.8 in either
an unmaintained state or in a different branch."""

from django.template import Library

try:
# Pre 1.8
from django.templatetags.future import url as base_url
except ImportError:
from django.template.defaulttags import url as base_url


register = Library()


@register.tag
def url(parser, token):
return base_url(parser, token)
Loading

0 comments on commit 5205920

Please sign in to comment.