From 1de7c48554711731425f60eee02e6557eeda7aa7 Mon Sep 17 00:00:00 2001 From: Sonu Kumar Date: Thu, 7 Jan 2021 10:53:24 +0530 Subject: [PATCH 1/6] updated doc to include version. --- docs/source/conf.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7b82e07..3207e2e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,20 +14,21 @@ # import os import sys -sys.path.insert(0, os.path.abspath('../error_tracker')) +import datetime +sys.path.insert(0, os.path.abspath('../error_tracker')) +import error_tracker # -- Project information ----------------------------------------------------- project = u'error-tracker' -copyright = u'2019, Sonu Kumar' -author = u'Sonu Kumar' +copyright = str(datetime.datetime.now().year) + u', Sonu Kumar' +author = error_tracker.__author__ # The short X.Y version version = u'' # The full version, including alpha/beta/rc tags -release = u'1.0' - +release = error_tracker.__version__ # -- General configuration --------------------------------------------------- @@ -74,7 +75,6 @@ # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' - # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -109,7 +109,6 @@ # Output file base name for HTML help builder. htmlhelp_basename = 'error-tracker-doc' - # -- Options for LaTeX output ------------------------------------------------ latex_elements = { @@ -138,7 +137,6 @@ u'Sonu Kumar', 'manual'), ] - # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples @@ -148,7 +146,6 @@ [author], 1) ] - # -- Options for Texinfo output ---------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples @@ -160,10 +157,9 @@ 'Miscellaneous'), ] - # -- Extension configuration ------------------------------------------------- # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} \ No newline at end of file +intersphinx_mapping = {'https://docs.python.org/': None} From 79a26919a5a0a3ad81d83369e471420134de6b1f Mon Sep 17 00:00:00 2001 From: Sonu Kumar Date: Thu, 7 Jan 2021 12:20:02 +0530 Subject: [PATCH 2/6] ../../ --- docs/source/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 3207e2e..84b38f6 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,9 +16,8 @@ import sys import datetime -sys.path.insert(0, os.path.abspath('../error_tracker')) +sys.path.insert(0, os.path.abspath('../../error_tracker')) import error_tracker - # -- Project information ----------------------------------------------------- project = u'error-tracker' From 6d30b574d9365c39180f6c1dfe1d8b121eaeeedb Mon Sep 17 00:00:00 2001 From: Sonu Kumar Date: Thu, 7 Jan 2021 12:34:18 +0530 Subject: [PATCH 3/6] pring sys path --- docs/source/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 84b38f6..21923df 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,7 +17,9 @@ import datetime sys.path.insert(0, os.path.abspath('../../error_tracker')) +print (sys.path) import error_tracker + # -- Project information ----------------------------------------------------- project = u'error-tracker' From 1a48b39b655b503ea985e4ad3b6c1b757103d1a7 Mon Sep 17 00:00:00 2001 From: Sonu Kumar Date: Thu, 7 Jan 2021 12:41:54 +0530 Subject: [PATCH 4/6] do not raise exception --- docs/source/conf.py | 1 + error_tracker/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 21923df..a2ed0bd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,6 +17,7 @@ import datetime sys.path.insert(0, os.path.abspath('../../error_tracker')) +sys.path.insert(0, os.path.abspath('../..')) print (sys.path) import error_tracker diff --git a/error_tracker/__init__.py b/error_tracker/__init__.py index 373de3f..bc3b36f 100644 --- a/error_tracker/__init__.py +++ b/error_tracker/__init__.py @@ -31,7 +31,7 @@ djangoInstalled = True except ImportError as e: - raise e + pass if djangoInstalled: from error_tracker.django import * From af0fa388da618bdfe5413f3475eb161abf852f80 Mon Sep 17 00:00:00 2001 From: Sonu Kumar Date: Thu, 7 Jan 2021 12:44:16 +0530 Subject: [PATCH 5/6] removed unused code --- docs/source/conf.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index a2ed0bd..874f539 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,9 +16,7 @@ import sys import datetime -sys.path.insert(0, os.path.abspath('../../error_tracker')) sys.path.insert(0, os.path.abspath('../..')) -print (sys.path) import error_tracker # -- Project information ----------------------------------------------------- From d819f97d6cc55f34299fee408f0a842bd18033bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAnio=20Eduardo=20de=20Morais=20Aquino?= <8471126+jeduardo211@users.noreply.github.com> Date: Thu, 26 May 2022 06:11:19 -0300 Subject: [PATCH 6/6] Add support for Django 4 (#24) * Use path instead of url to support Django 4 The old way of defining urls in DJango is no longer supported in Django 4.0. This commit replaces the regular expression based paths by the more modern path method, and also adds app_name in the urls file to allow usage with URL namespaces. * Increase version Altered major version because old versions of Django cannot be supported anymore. --- error_tracker/__init__.py | 2 +- .../django/templates/error_tracker/base.html | 2 +- .../error_tracker/partials/partial_table.html | 4 ++-- error_tracker/django/urls.py | 9 +++++---- error_tracker/django/views.py | 9 +++++---- setup.py | 2 ++ tests/DjangoTest/DjangoTest/drf_urls.py | 16 ++++++++-------- tests/DjangoTest/DjangoTest/urls.py | 12 ++++++------ 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/error_tracker/__init__.py b/error_tracker/__init__.py index bc3b36f..db3bdd4 100644 --- a/error_tracker/__init__.py +++ b/error_tracker/__init__.py @@ -6,7 +6,7 @@ # :license: BSD-3-Clause # -__version__ = '2.1.0' +__version__ = '3.0.0' __author__ = 'Sonu Kumar' __email__ = 'sonunitw12@gmail.com' diff --git a/error_tracker/django/templates/error_tracker/base.html b/error_tracker/django/templates/error_tracker/base.html index b8186e5..c8c9d99 100755 --- a/error_tracker/django/templates/error_tracker/base.html +++ b/error_tracker/django/templates/error_tracker/base.html @@ -38,7 +38,7 @@
{% block header_block %}

- {% trans 'Errors Seen' %} + {% trans 'Errors Seen' %}

{% endblock %} {% block content_block %} diff --git a/error_tracker/django/templates/error_tracker/partials/partial_table.html b/error_tracker/django/templates/error_tracker/partials/partial_table.html index 720c29a..3388f9b 100644 --- a/error_tracker/django/templates/error_tracker/partials/partial_table.html +++ b/error_tracker/django/templates/error_tracker/partials/partial_table.html @@ -4,7 +4,7 @@ {{ error.host }} {{ error.method }} - + {{ error.path|truncatechars:30 }} @@ -12,7 +12,7 @@ {{ error.last_seen }} {{ error.count }} - {%trans 'Delete' %} diff --git a/error_tracker/django/urls.py b/error_tracker/django/urls.py index 85bc7be..e1b3047 100755 --- a/error_tracker/django/urls.py +++ b/error_tracker/django/urls.py @@ -6,11 +6,12 @@ # :license: BSD-3-Clause # -from django.conf.urls import url +from django.urls import path from .views import detail, view_list, delete_exception +app_name = 'error_tracker' urlpatterns = [ - url(r'^$', view_list, name="view_errors"), - url(r'^(?P[\w-]+)/delete$', delete_exception, name='delete_error'), - url(r'^(?P[\w-]+)$', detail, name='view_error'), + path('', view_list, name="view_errors"), + path('/delete', delete_exception, name='delete_error'), + path('', detail, name='view_error'), ] diff --git a/error_tracker/django/views.py b/error_tracker/django/views.py index e83076a..df35a27 100644 --- a/error_tracker/django/views.py +++ b/error_tracker/django/views.py @@ -42,13 +42,14 @@ def view_list(request): error = False errors = model.get_exceptions_per_page(**query) - next_url = reverse('view_errors') + "?page=" + str(errors.next_num) \ + next_url = reverse('error_tracker:view_errors') + "?page=" + str(errors.next_num) \ if errors.has_next else None - prev_url = reverse('view_errors') + "?page=" + str(errors.prev_num) \ + prev_url = reverse('error_tracker:view_errors') + "?page=" + str(errors.prev_num) \ if errors.has_prev else None - if request.is_ajax() or request.GET.get('ajax_partial'): + is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest' + if is_ajax or request.GET.get('ajax_partial'): table = render_to_string('error_tracker/partials/partial_table.html', { 'errors': errors, }) @@ -75,7 +76,7 @@ def delete_exception(request, rhash): :return: redirect back to home page """ model.delete_entity(rhash) - return redirect(reverse('view_errors')) + return redirect(reverse('error_tracker:view_errors')) @require_GET diff --git a/setup.py b/setup.py index 4b290ab..42744ab 100755 --- a/setup.py +++ b/setup.py @@ -69,6 +69,8 @@ def grep(attrname): 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Topic :: Software Development :: Libraries :: Python Modules', ] ) diff --git a/tests/DjangoTest/DjangoTest/drf_urls.py b/tests/DjangoTest/DjangoTest/drf_urls.py index 939c976..2542732 100644 --- a/tests/DjangoTest/DjangoTest/drf_urls.py +++ b/tests/DjangoTest/DjangoTest/drf_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url, include +from django.urls import path, include from django.contrib import admin from rest_framework import routers from error_tracker.django import urls @@ -9,11 +9,11 @@ router.register(r'users', UserViewSet) urlpatterns = [ - url('admin/', admin.site.urls), - url("dev/", include(urls)), - url(r'^$', views.index), - url(r'^value-error$', views.value_error), - url(r'^post-view$', views.post_view), - url(r'^', include(router.urls)), - url(r'^api-auth/', include('rest_framework.urls')) + path('admin/', admin.site.urls), + path('dev/', include(urls)), + path('', views.index), + path('value-error', views.value_error), + path('post-view', views.post_view), + path('', include(router.urls)), + path('api-auth/', include('rest_framework.urls')) ] diff --git a/tests/DjangoTest/DjangoTest/urls.py b/tests/DjangoTest/DjangoTest/urls.py index e22991c..b85bf2a 100644 --- a/tests/DjangoTest/DjangoTest/urls.py +++ b/tests/DjangoTest/DjangoTest/urls.py @@ -13,15 +13,15 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.conf.urls import url, include +from django.urls import path, include from django.contrib import admin from error_tracker.django import urls from core import views urlpatterns = [ - url('admin/', admin.site.urls), - url("dev/", include(urls)), - url(r'^$', views.index), - url(r'^value-error$', views.value_error), - url(r'^post-view$', views.post_view), + path('admin/', admin.site.urls), + path('dev/', include(urls)), + path('', views.index), + path('value-error', views.value_error), + path('post-view', views.post_view), ]