Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from nikhila05/sample_app
Browse files Browse the repository at this point in the history
updated to django 2.0
  • Loading branch information
nikhila05 authored Mar 5, 2018
2 parents b84f968 + c83e6de commit a32ad8b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 21 deletions.
3 changes: 1 addition & 2 deletions django_web_profiler/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def process_response(self, request, response):
if settings.DEBUG:
toolbar = self.__class__.debug_toolbars.pop(
threading.current_thread().ident, None)

if not toolbar:
return response

Expand Down Expand Up @@ -228,5 +227,5 @@ def process_response(self, request, response):
except:
request_details['system_cpu_time'] = 0
request.statistics = request_details

logger1.debug(statistics)
return response
4 changes: 1 addition & 3 deletions django_web_profiler/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from django.core.urlresolvers import reverse
from django.db import models
from django.template.defaultfilters import date as date_filter


class ProfileLog(models.Model):
Expand Down Expand Up @@ -35,7 +33,7 @@ class ProfileLogRecord(models.Model):
"""Captures statistics for individual requests."""
timestamp = models.DateTimeField(auto_now_add=True)
profile_log = models.ForeignKey(
ProfileLog, blank=True, null=True, related_name='profile_log')
ProfileLog, blank=True, null=True, related_name='profile_log', on_delete=models.CASCADE)

request_path = models.CharField(max_length=255)
ip_address = models.CharField(max_length=255)
Expand Down
3 changes: 1 addition & 2 deletions django_web_profiler/templatetags/profile_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
register = template.Library()


@register.assignment_tag(takes_context=True)
@register.simple_tag(takes_context=True)
def get_page(context, page, no_pages):
if page <= 3:
start_page = 1
Expand All @@ -20,4 +20,3 @@ def get_page(context, page, no_pages):

pages = range(start_page, end_page + 1)
return pages

4 changes: 3 additions & 1 deletion django_web_profiler/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.conf.urls import url
from .views import (index, records_list, device_records_list)

app_name = 'django_web_profiler'

urlpatterns = [
# url(r'^home/$','home'),
url(r'^$', index, name="index"),
url(r'^records/list/(?P<record_id>[-\w]+)/$', records_list, name='records_list'),

url(r'^device-records-list/$', device_records_list, name='device_records_list'),

]
]
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
# built documents.
#
# The short X.Y version.
version = '0.0.1'
version = '0.1.4'
# The full version, including alpha/beta/rc tags.
release = '0.0.1'
release = '0.1.4'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion sandbox/requirementx.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==1.11.2
django-compressor==2.1.1
django-debug-toolbar==1.8
django-web-profiler==0.1.2
django-web-profiler==0.1.3
requests==2.17.3
29 changes: 21 additions & 8 deletions sandbox/testingapp/tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from django_web_profiler.models import ProfileLog
from django_web_profiler.models import ProfileLogRecord
from django.core.management import call_command
from django.test import Client


# Create your tests here.
Expand All @@ -12,7 +13,6 @@ def setUp(self):
for i in range(0, 20):
User.objects.create(username='test_' + str(i), email='test_' + str(i))


def test_index(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
Expand All @@ -22,7 +22,6 @@ def test_index(self):
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'profiler_base.html')


def test_logs(self):
response = self.client.get('/profiler/device-records-list/')
self.assertEqual(response.status_code, 200)
Expand All @@ -34,11 +33,25 @@ def test_management_command(self):

call_command('logging_urls', *args, **opts)


# def test_log_detail(self):
# self.log = ProfileLog.objects.first()
# print (self.log)
# url = reverse('django_web_profiler:records_list', kwargs={'record_id': self.log.id})
# response = self.client.get(url)
# self.assertEqual(response.status_code, 200)
# self.assertTemplateUsed(response, 'log_detail.html')
# if self.log:
# url = reverse('django_web_profiler:records_list', kwargs={'record_id': self.log.id})
# response = self.client.get(url)
# self.assertEqual(response.status_code, 200)
# self.assertTemplateUsed(response, 'log_detail.html')


class TestAppViews(TestCase):
client = Client()

def test_ip_graph(self):
response = self.client.get('/ip/graph/')
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'ip_graph.html')

def test_path_graph(self):
response = self.client.get('/path/graph/')
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'path_graph.html')
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setup(
name='django-web-profiler',
version='0.1.2',
version='0.1.4',
packages=find_packages(exclude=['tests', 'tests.*']),
include_package_data=True,
description="a django profiling tool which logs, stores debug toolbar statistics and also a set of URL's statistics using a management command.",
Expand All @@ -45,6 +45,6 @@
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
install_requires=[
"Django>=1.6.0,<1.11",
"Django",
],
)

0 comments on commit a32ad8b

Please sign in to comment.