Skip to content

Commit

Permalink
Fix RemovedInDjango19Warning and other warnings. Fixes #396 #365 #383
Browse files Browse the repository at this point in the history
  • Loading branch information
darklow committed Jul 23, 2015
1 parent 2121da8 commit 868b4ab
Show file tree
Hide file tree
Showing 30 changed files with 61 additions and 32 deletions.
6 changes: 1 addition & 5 deletions suit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
from django.contrib import admin
from django.db import models
from suit.widgets import NumberInput, SuitSplitDateTimeWidget
try:
# Django 1.8 +
from django.contrib.contenttypes import admin as ct_admin
except ImportError:
from django.contrib.contenttypes import generic as ct_admin
from suit.compat import ct_admin


class SortableModelAdminBase(object):
Expand Down
24 changes: 24 additions & 0 deletions suit/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
This file exists to contain all Django and Python compatibility issues.
In order to avoid circular references, nothing should be imported from suit lib.
Based on:
https://github.com/django-debug-toolbar/django-debug-toolbar/blob/master/debug_toolbar/compat.py
"""
import django

try:
from importlib import import_module
except ImportError: # python = 2.6
from django.utils.importlib import import_module # Django < 1.9

if django.VERSION[:2] < (1, 5):
from django.templatetags.future import url
else:
from django.template.defaulttags import url

try:
from django.contrib.contenttypes import admin as ct_admin
except ImportError:
from django.contrib.contenttypes import generic as ct_admin # Django < 1.8
2 changes: 1 addition & 1 deletion suit/templates/admin/app_index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/index.html" %}
{% load i18n %}
{% load url from future %}
{% load url from suit_compat %}

{% if not is_popup %}
{% block breadcrumbs %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/auth/user/change_password.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_modify admin_urls %}
{% load url from future %}
{% load url from suit_compat %}

{% block extrahead %}{{ block.super }}
{% url 'admin:jsi18n' as jsi18nurl %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load admin_static %}{% load suit_tags %}{% load url from future %}<!DOCTYPE html>
{% load admin_static %}{% load suit_tags %}{% load url from suit_compat %}<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/change_form.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_modify suit_tags admin_urls %}
{% load url from future %}
{% load url from suit_compat %}

{% block extrahead %}{{ block.super }}
{% url 'admin:jsi18n' as jsi18nurl %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/change_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_list admin_urls suit_list suit_tags %}
{% load url from future %}
{% load url from suit_compat %}

{% block extrastyle %}
{{ block.super }}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/cms/page/change_form.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/change_form.html" %}
{% load i18n admin_modify cms_tags cms_admin %}
{% load url from future %}
{% load url from suit_compat %}
{% block title %}{% trans "Change a page" %}{% endblock %}

{% block extrahead %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/cms/page/plugin_change_form.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_modify cms_admin %}
{% load url from future %}
{% load url from suit_compat %}
{% block extrahead %}{{ block.super }}

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}suit/css/djangocms.css">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/delete_confirmation.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_urls %}
{% load url from future %}
{% load url from suit_compat %}

{% block breadcrumbs %}
<ul class="breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/delete_selected_confirmation.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n l10n admin_urls %}
{% load url from future %}
{% load url from suit_compat %}

{% block breadcrumbs %}
<ul class="breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/filer/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load url from future %}
{% load url from suit_compat %}
<ul class="breadcrumb">
<li>
<a href="{% url 'admin:index' %}" title="{% trans "Go back to admin homepage" %}">{% trans "Home" %}</a>
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/filer/delete_confirmation.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/filer/base_site.html" %}
{% load i18n %}
{% load url from future %}
{% load url from suit_compat %}

{% block breadcrumbs %}
{% include "admin/filer/breadcrumbs.html" with instance=object breadcrumbs_action="Delete" %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/filer/folder/change_form.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/change_form.html" %}
{% load i18n admin_modify filermedia %}
{% load url from future %}
{% load url from suit_compat %}

{% block breadcrumbs %}
<ul class="breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/filer/folder/directory_listing.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load filer_admin_tags filermedia i18n %}
{% load url from future %}
{% load url from suit_compat %}

{% block extrahead %}{{ block.super }}
{# upload stuff #}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/filer/folder/directory_table.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load admin_list filermedia filer_tags %}
{% load url from future %}
{% load url from suit_compat %}

<div id="toolbartable" class="results">
<table id="result_list" class="table table-striped table-bordered table-hover table-condensed">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/filer/tools/clipboard/clipboard.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load thumbnail i18n %}
{% load url from future %}
{% load url from suit_compat %}

<h4 class="italic-title clipboard-header{{ folder.is_root|yesno:' clipboard-root,' }}">{% trans "Clipboard" %}</h4>
{% for clipboard in user.filer_clipboards.all %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/import_export/base.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_modify %}
{% load admin_urls %}
{% load url from future %}
{% load url from suit_compat %}

{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}
{% if not is_popup %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/import_export/export.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "admin/import_export/base.html" %}
{% load url from future %}
{% load url from suit_compat %}
{% load i18n admin_urls import_export_tags %}

{% block breadcrumbs_last %}{% trans "Export" %}{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/import_export/import.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "admin/import_export/base.html" %}
{% load url from future %}
{% load url from suit_compat %}
{% load i18n admin_urls import_export_tags %}

{% block breadcrumbs_last %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/login.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_static suit_tags %}
{% load url from future %}
{% load url from suit_compat %}

{% block extrastyle %}{{ block.super }}
{# <link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />#}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/admin/object_history.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_urls %}
{% load url from future %}
{% load url from suit_compat %}

{% block breadcrumbs %}
<div class="breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/registration/logged_out.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n %}
{% load url from future %}
{% load url from suit_compat %}

{% block breadcrumbs %}
<div class="breadcrumbs"><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></div>{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/registration/password_change_form.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n static %}
{% load url from future %}
{% load url from suit_compat %}

{% block extrastyle %}{{ block.super }}
{# <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}"/>#}
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/reversion/recover_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "reversion/revision_form.html" %}
{% load url from future %}
{% load url from suit_compat %}
{% load i18n %}


Expand Down
2 changes: 1 addition & 1 deletion suit/templates/reversion/recover_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "admin/base_site.html" %}
{% load url from future %}
{% load url from suit_compat %}
{% load i18n %}


Expand Down
2 changes: 1 addition & 1 deletion suit/templates/reversion/revision_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "admin/change_form.html" %}
{% load url from future %}
{% load url from suit_compat %}
{% load i18n %}


Expand Down
2 changes: 1 addition & 1 deletion suit/templates/suit/error_base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load admin_static i18n %}{% load url from future %}<!DOCTYPE html>
{% load admin_static i18n %}{% load url from suit_compat %}<!DOCTYPE html>
<!--[if lt IE 9 ]><html lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en" xmlns="http://www.w3.org/1999/html"> <!--<![endif]-->
Expand Down
2 changes: 1 addition & 1 deletion suit/templates/suit/menu.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#{% load sitetree %}#}
{% load i18n suit_menu %}
{% load url from future %}
{% load url from suit_compat %}

<div class="left-nav" id="left-nav">
<ul>
Expand Down
9 changes: 9 additions & 0 deletions suit/templatetags/suit_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.template.base import Library
from ..compat import url as url_compat

register = Library()


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

0 comments on commit 868b4ab

Please sign in to comment.