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

Adjustments for Django 1.7. #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include README.rst
include CHANGES.rst
include LICENSE
include ez_setup.py
include djangologdb/media/js/*.js
include djangologdb/static/admin/js/*.js
include djangologdb/templates/admin/djangologdb/*.html
include djangologdb/templates/admin/djangologdb/logaggregate/*.html
include djangologdb/templates/admin/djangologdb/logentry/*.html
Expand Down
2 changes: 1 addition & 1 deletion djangologdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = (1, 1)
__version__ = (1, 2, 'dev0')
4 changes: 2 additions & 2 deletions djangologdb/management/commands/aggregate_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import datetime

from django.core.management.base import NoArgsCommand
from django.utils.hashcompat import md5_constructor
import hashlib
from django.db.models import F
from django.db import transaction

Expand Down Expand Up @@ -45,7 +45,7 @@ def handle_noargs(self, **options):
'name': log_entry.name,
'path': log_entry.path,
}
checksum = md5_constructor(str(entries))
checksum = hashlib.md5(str(entries))

entries.update({
'first_seen': log_entry.created,
Expand Down
1 change: 0 additions & 1 deletion djangologdb/media/js/excanvas.min.js

This file was deleted.

19 changes: 0 additions & 19 deletions djangologdb/media/js/jquery-1.3.2.min.js

This file was deleted.

1 change: 0 additions & 1 deletion djangologdb/media/js/jquery.flot-0.6.min.js

This file was deleted.

10 changes: 8 additions & 2 deletions djangologdb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from djangologdb import settings as djangologdb_settings
from djangologdb.utils import get_timestamp, JSONField, TupleField
import traceback

LOG_LEVELS = (
(logging.INFO, 'Info'),
Expand Down Expand Up @@ -136,7 +137,7 @@ def get_datasets(self, interval=None, aggregate=None, start_date=None, end_date=

class LogManager(models.Manager):

def get_query_set(self):
def get_queryset(self):
return LogQuerySet(self.model)

def get_datasets(self, *args, **kwargs):
Expand Down Expand Up @@ -189,9 +190,14 @@ def create_from_record(self, record):
except:
msg = u'(django-logdb: Message encoding error)'

if not record.exc_text:
exc_text = traceback.format_exc()
else:
exc_text = record.exc_text

log_entry = LogEntry.objects.create(
args=tuple(args),
exc_text=record.exc_text,
exc_text=exc_text,
filename=record.filename,
function_name=record.funcName,
level=record.levelno,
Expand Down
3 changes: 0 additions & 3 deletions djangologdb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,3 @@
logging.CRITICAL: '#e9a8ab',
}
)

MEDIA_ROOT = getattr(settings, 'LOGDB_MEDIA_ROOT', os.path.join(djangologdb.__path__[0], 'media'))
MEDIA_URL = getattr(settings, 'LOGDB_MEDIA_URL', '/admin/djangologdb/media/')
1 change: 1 addition & 0 deletions djangologdb/static/admin/js/excanvas.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions djangologdb/static/admin/js/jquery.flot.init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var jQuery = django.jQuery;
8 changes: 8 additions & 0 deletions djangologdb/static/admin/js/jquery.flot.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions djangologdb/static/admin/js/jquery.flot.time.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% extends "admin/change_list.html" %}
{% load i18n djangologdb_tags %}
{% load i18n staticfiles %}

{% block extrahead %}
{{ block.super }}

{% block djangologdb-jslibs %}
<!--[if IE]><script type="text/javascript" src="{% djangologdb_media_url %}js/excanvas.min.js"></script><![endif]-->
<script type="text/javascript" src="{% djangologdb_media_url %}js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{% djangologdb_media_url %}js/jquery.flot-0.6.min.js"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="{% static "admin/js/excanvas.min.js"%}"></script><![endif]-->
<script type="text/javascript" src="{% static "admin/js/jquery.flot.init.js" %}"></script>
<script type="text/javascript" src="{% static "admin/js/jquery.flot.min.js" %}"></script>
<script type="text/javascript" src="{% static "admin/js/jquery.flot.time.min.js" %}"></script>
{% endblock %}

{% block djangologdb-jsinit %}
Expand All @@ -20,7 +21,7 @@
shadowSize: 0
},
yaxis: { min: 0, tickDecimals: 0 },
xaxis: { tickDecimals: 0, mode: "time" }
xaxis: { tickDecimals: 0, mode: "time", timeformat: "%d.%m.%Y" }
};

var today = new Date();
Expand All @@ -35,17 +36,19 @@
interval_days: {{ djangologdb_settings.INTERVAL.days }},{% endifequal %}
aggregate: '{{ aggregate }}'
};

$.getJSON('../datasets/', params, function(datasets) {
var data = [];

$.each(datasets, function(key, val) {
data.push(datasets[key]);
});
$.ajax({
url: '../datasets/',
data: params,
success: function(datasets) {
var data = [];
$.each(datasets, function(key, val) {
data.push(datasets[key]);
});

$.plot($("#chart"), data, options);
$.plot($("#chart"), data, options);
}
});
})(jQuery.noConflict());
})(django.jQuery.noConflict());
</script>
{% endblock %}
{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{% extends "admin/change_form.html" %}
{% load i18n djangologdb_tags %}
{% load i18n staticfiles %}

{% block extrahead %}
{{ block.super }}

{% block djangologdb-jslibs %}
<!--[if IE]><script type="text/javascript" src="{% djangologdb_media_url %}js/excanvas.min.js"></script><![endif]-->
<script type="text/javascript" src="{% djangologdb_media_url %}js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{% djangologdb_media_url %}js/jquery.flot-0.6.min.js"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="{% static "admin/js/excanvas.min.js"%}"></script><![endif]-->
<script type="text/javascript" src="{% static "admin/js/jquery.flot.init.js" %}"></script>
<script type="text/javascript" src="{% static "admin/js/jquery.flot.min.js" %}"></script>
<script type="text/javascript" src="{% static "admin/js/jquery.flot.time.min.js" %}"></script>

{% endblock %}

{% block djangologdb-jsinit %}
Expand All @@ -20,7 +22,7 @@
shadowSize: 0
},
yaxis: { min: 0, tickDecimals: 0 },
xaxis: { tickDecimals: 0, mode: "time" }
xaxis: { tickDecimals: 0, mode: "time", timeformat: "%d.%m.%Y" }
};

var today = new Date();
Expand All @@ -37,15 +39,18 @@
id: {{ original.pk }}
};

$.getJSON('../../datasets/', params, function(datasets) {
var data = [];
$.ajax({
url: '../../datasets/',
data: params,
success: function(datasets) {
var data = [];
$.each(datasets, function(key, val) {
data.push(datasets[key]);
});

$.each(datasets, function(key, val) {
data.push(datasets[key]);
});

$.plot($("#chart"), data, options);
});
$.plot($("#chart"), data, options);
}
});
})(jQuery.noConflict());
</script>
{% endblock %}
Expand Down
Empty file.
15 changes: 0 additions & 15 deletions djangologdb/templatetags/djangologdb_tags.py

This file was deleted.

7 changes: 1 addition & 6 deletions djangologdb/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django.conf.urls.defaults import patterns
from django.conf.urls import patterns
from django.contrib import admin

from djangologdb import settings as djangologdb_settings
Expand All @@ -8,8 +8,3 @@
urlpatterns = patterns('',
(r'datasets/$', admin.site.admin_view(views.datasets)),
)

if settings.DEBUG:
urlpatterns += patterns('',
(r'media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': djangologdb_settings.MEDIA_ROOT}),
)
2 changes: 1 addition & 1 deletion djangologdb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.db import models
from django.core.serializers.json import DjangoJSONEncoder
from django.utils import simplejson as json
import json

def get_timestamp(date_time):
"""
Expand Down
4 changes: 2 additions & 2 deletions djangologdb/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime

from django.http import HttpResponseBadRequest, HttpResponse
from django.utils import simplejson
import json

from djangologdb.utils import get_datetime
from djangologdb.models import LogEntry
Expand Down Expand Up @@ -56,4 +56,4 @@ def datasets(request):
except:
return HttpResponseBadRequest()

return HttpResponse(simplejson.dumps(result), mimetype='text/json')
return HttpResponse(json.dumps(result), content_type='text/json')
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def read_file(name):
# 'Django>=1.1',
#],
include_package_data=True,
packages=['djangologdb'],
packages = find_packages(),
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: Django',
Expand Down