Skip to content

Commit

Permalink
Fix all django warnings
Browse files Browse the repository at this point in the history
Mainly involved updating django-compressor and related changes
  • Loading branch information
frankh committed Feb 16, 2017
1 parent 9388274 commit 9f61f9e
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 50 deletions.
17 changes: 9 additions & 8 deletions cabot/cabotapp/tests/test_urlprefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from django.core.urlresolvers import reverse, clear_url_caches
from django.conf import settings
from django.test.utils import override_settings
from django.utils.importlib import import_module
from importlib import import_module

from rest_framework import status, HTTP_HEADER_ENCODING

from tests_basic import LocalTestCase


class override_urlprefix(override_settings):
def clear_cache(self):
# If we don't do this, nothing gets correctly set for the URL Prefix
Expand All @@ -25,13 +26,13 @@ def __init__(self, urlprefix):

# Have to turn off the compressor here, can't find a way to reload
# the COMPRESS_URL into it on the fly

super(override_urlprefix, self).__init__(
URL_PREFIX = urlprefix,
MEDIA_URL = "%s/media/" % urlprefix,
STATIC_URL = "%s/static/" % urlprefix,
COMPRESS_URL = "%s/static/" % urlprefix,
COMPRESS_ENABLED = False
URL_PREFIX=urlprefix,
MEDIA_URL="%s/media/" % urlprefix,
STATIC_URL="%s/static/" % urlprefix,
COMPRESS_URL="%s/static/" % urlprefix,
COMPRESS_ENABLED=False,
COMPRESS_PRECOMPILERS=()
)

def __enter__(self):
Expand All @@ -42,6 +43,7 @@ def __exit__(self, exc_type, exc_value, traceback):
super(override_urlprefix, self).__exit__(exc_type, exc_value, traceback)
self.clear_cache()


class URLPrefixTestCase(LocalTestCase):
def set_url_prefix(self, prefix):
return override_urlprefix(prefix)
Expand All @@ -67,7 +69,6 @@ def test_loginurl(self):

def test_query(self):
prefix = '/test'

self.client.login(username=self.username, password=self.password)

before_services = self.client.get(reverse('services'))
Expand Down
21 changes: 10 additions & 11 deletions cabot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
settings_dir = os.path.dirname(__file__)
PROJECT_ROOT = os.path.abspath(settings_dir)

TEMPLATE_DEBUG = DEBUG = os.environ.get("DEBUG", False)
DEBUG = os.environ.get("DEBUG", False)

ADMINS = (
('Admin', os.environ.get('ADMIN_EMAIL', '[email protected]')),
Expand Down Expand Up @@ -75,6 +75,7 @@
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '%s/static/' % URL_PREFIX
COMPRESS_URL = STATIC_URL

# Additional locations of static files
STATICFILES_DIRS = [os.path.join(PROJECT_ROOT, 'static')]
Expand All @@ -92,25 +93,25 @@
'DJANGO_SECRET_KEY', '2FL6ORhHwr5eX34pP9mMugnIOd3jzVuT45f7w430Mt5PnEwbcJgma0q8zUXNZ68A')

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (
os.path.join(PROJECT_ROOT, 'templates'),
),
'APP_DIRS': True,
}]

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'cabot.urls'

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -157,8 +158,6 @@

COMPRESS_OFFLINE = not DEBUG

COMPRESS_URL = '%s/static/' % URL_PREFIX

RECOVERY_SNIPPETS_WHITELIST = (
r'https?://[^.]+\.hackpad\.com/[^./]+\.js',
r'https?://gist\.github\.com/[^.]+\.js',
Expand Down
43 changes: 22 additions & 21 deletions cabot/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load static from staticfiles %}
<!DOCTYPE html>
<html>
<head>
Expand All @@ -8,17 +9,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
{% load compress %}
{% compress css %}
<link href="{{ STATIC_URL }}bootstrap/css/bootstrap.css" rel="stylesheet">
<link id="chosen-css" href="{{ STATIC_URL }}theme/css/chosen.css" rel="stylesheet">
<link href="{{ STATIC_URL }}bootstrap/css/dashboard.css" rel="stylesheet">
<link href="{{ STATIC_URL }}theme/css/jquery-ui-1.8.21.custom.css" type="text/css" rel="stylesheet">
<link href="{{ STATIC_URL }}arachnys/css/base.less" type="text/less" rel="stylesheet">
<link rel="stylesheet" href="{{ STATIC_URL }}arachnys/css/morris.css" type="text/css">
<link rel="stylesheet" href="{{ STATIC_URL }}arachnys/css/graph.css" type="text/css">
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
<link id="chosen-css" href="{% static 'theme/css/chosen.css' %}" rel="stylesheet">
<link href="{% static 'bootstrap/css/dashboard.css' %}" rel="stylesheet">
<link href="{% static 'theme/css/jquery-ui-1.8.21.custom.css' %}" type="text/css" rel="stylesheet">
<link href="{% static 'arachnys/css/base.less' %}" type="text/less" rel="stylesheet">
<link rel="stylesheet" href="{% static 'arachnys/css/morris.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'arachnys/css/graph.css' %}" type="text/css">
{% endcompress %}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">

<link rel="icon" href="{{ STATIC_URL }}arachnys/img/icon_48x48.png" type="image/png">
<link rel="icon" href="{% static 'arachnys/img/icon_48x48.png'%}" type="image/png">
{% compress js %}
<script type="text/coffeescript">
if window.location.host.indexOf('localhost') != -1
Expand All @@ -33,7 +34,7 @@
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a href="{% url "services" %}" class="navbar-brand"><img src="{{ STATIC_URL }}arachnys/img/icon_48x48.png" width='20' height='20' /> Cabot by Arachnys</a>
<a href="{% url "services" %}" class="navbar-brand"><img src="{% static 'arachnys/img/icon_48x48.png' %}" width='20' height='20' /> Cabot by Arachnys</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
Expand Down Expand Up @@ -127,23 +128,23 @@ <h4 class="alert-heading">Warning!</h4>
{% block js %}

{% compress js %}
<script src="{{ STATIC_URL }}bootstrap/js/jquery-1.10.2.js"></script>
<script src="{{ STATIC_URL }}theme/js/jquery-ui.js"></script>
<script src="{{ STATIC_URL }}theme/js/jquery.ui.core.js"></script>
<script src="{{ STATIC_URL }}theme/js/jquery.ui.position.js"></script>
<script src="{{ STATIC_URL }}theme/js/jquery.ui.autocomplete.js"></script>
<script src="{% static 'bootstrap/js/jquery-1.10.2.js' %}"></script>
<script src="{% static 'theme/js/jquery-ui.js' %}"></script>
<script src="{% static 'theme/js/jquery.ui.core.js' %}"></script>
<script src="{% static 'theme/js/jquery.ui.position.js' %}"></script>
<script src="{% static 'theme/js/jquery.ui.autocomplete.js' %}"></script>

<script src="{{ STATIC_URL }}bootstrap/js/bootstrap.js"></script>
<script src="{% static 'bootstrap/js/bootstrap.js' %}"></script>

<script src='{{ STATIC_URL }}theme/js/jquery.dataTables.min.js'></script>
<script src="{% static 'theme/js/jquery.dataTables.min.js' %}"></script>

<script src="{{ STATIC_URL }}theme/js/chosen.jquery.js"></script>
<script src="{% static 'theme/js/chosen.jquery.js' %}"></script>

<script src="{{ STATIC_URL }}theme/js/jquery.sparkline.min.js"></script>
<script src="{% static 'theme/js/jquery.sparkline.min.js' %}"></script>

<script src="{{ STATIC_URL }}theme/js/custom.js"></script>
<script src="{{ STATIC_URL }}arachnys/js/raphael.js"></script>
<script src="{{ STATIC_URL }}arachnys/js/morris.js"></script>
<script src="{% static 'theme/js/custom.js' %}"></script>
<script src="{% static 'arachnys/js/raphael.js' %}"></script>
<script src="{% static 'arachnys/js/morris.js' %}"></script>
<!-- end: JavaScript-->
<script type="text/coffeescript">
$ () ->
Expand Down
8 changes: 4 additions & 4 deletions cabot/templates/cabotapp/instance_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'base.html' %}

{% load static from staticfiles %}
{% block title %}{{ block.super }} - {{ instance.name }}{% endblock title %}

{% block content %}
Expand Down Expand Up @@ -134,9 +134,9 @@ <h3>Status check report</h3>
<script type="text/javascript">
window.INSTANCE_HISTORY = {{ instance.recent_snapshots|jsonify }}
</script>
<script type="text/javascript" src="{{ STATIC_URL }}arachnys/js/d3.js"></script>
<script type="text/javascript" src="{% static 'arachnys/js/d3.js' %}"></script>
{% compress js %}
<script type="text/javascript" src="{{ STATIC_URL }}arachnys/js/rickshaw.js"></script>
<script type="text/javascript" src="{% static 'arachnys/js/rickshaw.js' %}"></script>
<script type="text/coffeescript">

$(document).ready ->
Expand Down Expand Up @@ -199,7 +199,7 @@ <h3>Status check report</h3>
$(function(){
$(':input.datepicker').datepicker({
dateFormat: 'yy-mm-dd',
buttonImage: '{{ STATIC_URL }}theme/img/calendar.gif',
buttonImage: "{% static 'theme/img/calendar.gif' %}",
buttonImageOnly: true,
showOn: 'button'
});
Expand Down
7 changes: 4 additions & 3 deletions cabot/templates/cabotapp/service_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% load extra %}
{% load static from staticfiles %}

{% block title %}{{ block.super }} - {{ service.name }}{% endblock title %}

Expand Down Expand Up @@ -180,9 +181,9 @@ <h3>Documentation</h3>
<script type="text/javascript">
window.SERVICE_HISTORY = {{ service.recent_snapshots|jsonify }}
</script>
<script type="text/javascript" src="{{ STATIC_URL }}arachnys/js/d3.js"></script>
<script type="text/javascript" src="{% static 'arachnys/js/d3.js' %}"></script>
{% compress js %}
<script type="text/javascript" src="{{ STATIC_URL }}arachnys/js/rickshaw.js"></script>
<script type="text/javascript" src="{% static 'arachnys/js/rickshaw.js' %}"></script>
<script type="text/coffeescript">

$(document).ready ->
Expand Down Expand Up @@ -245,7 +246,7 @@ <h3>Documentation</h3>
$(function(){
$(':input.datepicker').datepicker({
dateFormat: 'yy-mm-dd',
buttonImage: '{{ STATIC_URL }}theme/img/calendar.gif',
buttonImage: "{% static 'theme/img/calendar.gif' %}",
buttonImageOnly: true,
showOn: 'button'
});
Expand Down
3 changes: 2 additions & 1 deletion cabot/templates/cabotapp/statuscheckresult_detail.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends 'base.html' %}
{% load static from staticfiles %}

{% block content %}
<div class="row">
Expand Down Expand Up @@ -38,7 +39,7 @@ <h2>Check result: <a href="{% url "check" result.status_check.id %}">{{ result.s
}
</script>
{% compress js %}
<script type="text/javascript" src="{{ STATIC_URL }}arachnys/js/raphael.js"></script>
<script type="text/javascript" src="{% static 'arachnys/js/raphael.js' %}"></script>
<script type="text/coffeescript">
kvs = []
labels = []
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ anyjson==0.3.3
argparse==1.2.1
celery[redis]==3.1.23
dj-database-url==0.4.2
django-appconf==0.6
django-appconf==1.0.2
django-celery==3.1.17
django-compressor==1.5
django-compressor==2.1.1
django-filter==0.13
django-jsonify==0.3.0
django-mptt==0.6.0
Expand Down

0 comments on commit 9f61f9e

Please sign in to comment.