Skip to content

Commit d207480

Browse files
committed
2 parents 0413214 + 6454059 commit d207480

File tree

17 files changed

+187
-60
lines changed

17 files changed

+187
-60
lines changed

.flake8

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[flake8]
2+
select = ANN,B,B9,BLK,C,D,DAR,E,F,I,S,W
3+
ignore = E203,E501,W503,D100,D415,D104,B008,B902
4+
max-line-length = 200
5+
max-complexity = 40
6+
application-import-names = tests
7+
import-order-style = google
8+
docstring-convention = google
9+
per-file-ignores = tests/*:S101,E402
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
2+
3+
on: push
4+
5+
jobs:
6+
tests:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
include:
12+
- django-version: "2.2.0"
13+
python-version: "3.8"
14+
- django-version: "3.2.0"
15+
python-version: "3.8"
16+
- django-version: "4.0.0"
17+
python-version: "3.8"
18+
- django-version: "2.2.0"
19+
python-version: "3.10"
20+
- django-version: "3.2.0"
21+
python-version: "3.10"
22+
- django-version: "4.0.0"
23+
python-version: "3.10"
24+
steps:
25+
- uses: actions/checkout@v2
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Upgrade pip version
32+
run: |
33+
python -m pip install -U pip
34+
35+
- name: Install test requirements/linters
36+
run: pip install -r tests/requirements.txt
37+
38+
- name: Upgrade django version
39+
run: |
40+
python -m pip install "Django~=${{ matrix.django-version }}"
41+
42+
- name: Run pre-commit
43+
run: pre-commit run --all-files
44+
45+
46+
build-n-publish:
47+
needs: tests
48+
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Set up Python ${{ matrix.python-version }}
53+
uses: actions/setup-python@v2
54+
- name: Install pypa/build
55+
run: >-
56+
python -m
57+
pip install
58+
build
59+
--user
60+
- name: Build a binary wheel and a source tarball
61+
run: >-
62+
python -m
63+
build
64+
--sdist
65+
--wheel
66+
--outdir dist/
67+
- name: Publish distribution 📦 to Test PyPI
68+
uses: pypa/gh-action-pypi-publish@master
69+
continue-on-error: true
70+
with:
71+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
72+
repository_url: https://test.pypi.org/legacy/
73+
- name: Publish distribution 📦 to PyPI
74+
if: startsWith(github.ref, 'refs/tags')
75+
uses: pypa/gh-action-pypi-publish@master
76+
with:
77+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ coverage.xml
4141
.mr.developer.cfg
4242
.project
4343
.pydevproject
44+
.pytest_cache
4445

4546
# Rope
4647
.ropeproject

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
repos:
2+
# github will run `pre-commit run --hook-stage manual -a` and then manually black and flake8
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.1.0
5+
hooks:
6+
- id: check-yaml
7+
stages: [commit, push, manual]
8+
- id: check-json
9+
stages: [commit, push, manual]
10+
- id: end-of-file-fixer
11+
stages: [commit, push, manual]
12+
- id: trailing-whitespace
13+
stages: [commit, push, manual]
14+
- repo: local
15+
hooks:
16+
- id: isort
17+
name: isort
18+
entry: isort --profile black
19+
language: system
20+
types: [python]
21+
stages: [commit, push, manual]
22+
- id: black
23+
name: black
24+
entry: black
25+
language: system
26+
types: [python]
27+
stages: [commit, push, manual]
28+
- id: flake8
29+
name: flake8
30+
entry: flake8
31+
language: system
32+
types: [python]
33+
stages: [commit, push, manual]
34+
- id: tests
35+
name: pytest
36+
entry: pytest
37+
pass_filenames: false
38+
language: system
39+
types: [python]
40+
stages: [commit, push, manual]

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

CHANGES

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
3.0.2
2+
* Just CI auto deploy fixes
3+
4+
3.0.0
5+
* Compatible with Debug toolbar 3.x
6+
* Compatible with Django 4.0 (Requires python 3.8+)
7+
* Remove python 3.6 and 3.7
8+
* Add Python 3.8 3.9 3.10
9+
* Remove travis switch to github actions
10+
111
2.0.0
212
* Remove python 2.x
313
* Compatible with Debug toolbar 2.x
@@ -6,4 +16,4 @@
616
Added duplicate detection and query hash
717

818
0.1.0
9-
* Initial release
19+
* Initial release

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1616
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1717
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19-
THE SOFTWARE.
19+
THE SOFTWARE.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ A Django Debug Toolbar panel for Elasticsearch
88
About
99
------------
1010

11-
Breaking changes:
11+
Breaking changes:
12+
* django-elasticsearch-debug-toolbar 3.x is compatible with Django Debug Toolbar 3.x (elasticsearch <8.0.0)
1213
* django-elasticsearch-debug-toolbar 2.x is compatible with Django Debug Toolbar 2.x
1314
* django-elasticsearch-debug-toolbar 1.x is compatible with Django Debug Toolbar 1.x
1415

@@ -31,7 +32,7 @@ or install the development version from source::
3132

3233
pip install git+git@github.com:Benoss/django-elasticsearch-debug-toolbar.git
3334

34-
* Then add ``elastic_panel`` to your ``INSTALLED_APPS`` so that we can find the templates in the panel.
35+
* Then add ``elastic_panel`` to your ``INSTALLED_APPS`` so that we can find the templates in the panel.
3536
* Also, add ``'elastic_panel.panel.ElasticDebugPanel'`` to your ``DEBUG_TOOLBAR_PANELS``.
3637

3738
Usage
@@ -48,4 +49,3 @@ Uses the `MIT` license.
4849

4950
* Django Debug Toolbar: https://github.com/django-debug-toolbar/django-debug-toolbar
5051
* MIT: http://opensource.org/licenses/MIT
51-

elastic_panel/panel.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from django.conf import settings
2-
from django.template.loader import render_to_string
3-
from django.utils.translation import ugettext_lazy as _
4-
from debug_toolbar.panels import Panel
5-
from debug_toolbar.utils import ThreadCollector, get_stack, tidy_stacktrace, render_stacktrace, \
6-
get_module_path, hidden_paths
71
import hashlib
82
import json
3+
import traceback
94

5+
from debug_toolbar.panels import Panel
6+
from debug_toolbar.utils import ThreadCollector, get_stack, tidy_stacktrace, render_stacktrace, \
7+
get_module_path, hidden_paths
8+
from django.templatetags.static import static
9+
from django.utils.translation import gettext_lazy as _
1010
from elasticsearch.connection.base import Connection
1111

1212
# Patching og the orginal elasticsearch log_request
@@ -66,20 +66,26 @@ class ElasticDebugPanel(Panel):
6666
nb_duplicates = 0
6767
nb_queries = 0
6868

69+
@property
6970
def nav_title(self):
7071
return _("Elastic Queries")
7172

73+
@property
7274
def nav_subtitle(self):
7375
default_str = "{} queries {:.2f}ms".format(self.nb_queries, self.total_time)
7476
if self.nb_duplicates > 0:
7577
default_str += " {} DUPE".format(self.nb_duplicates)
7678
return default_str
7779

78-
def url(self):
79-
return ""
80-
80+
@property
8181
def title(self):
82-
return self.nav_title()
82+
return self.nav_title
83+
84+
@property
85+
def scripts(self):
86+
scripts = super().scripts
87+
scripts.append(static("elastic_panel/js/elastic_panel.js"))
88+
return scripts
8389

8490
def process_request(self, request):
8591
collector.clear_collection()

elastic_panel/static/elastic_panel/js/elastic_panel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var showHandler = function(e) {
1616
toggle(this.nextElementSibling)
1717
}
1818

19-
arrow = this.children[0]
19+
var arrow = this.children[0];
2020
arrow.textContent = arrow.textContent == uarr ? darr : uarr
2121

2222
toggle(this.parentNode.nextElementSibling)
@@ -29,8 +29,8 @@ for (var e of document.querySelectorAll('a.elasticShowTemplate')) {
2929
}
3030

3131
var textHandler = function(e) {
32-
selection = window.getSelection();
33-
range = document.createRange();
32+
var selection = window.getSelection();
33+
var range = document.createRange();
3434
range.selectNodeContents(this.parentNode.nextElementSibling.querySelector('code'));
3535
selection.removeAllRanges();
3636
selection.addRange(range);

0 commit comments

Comments
 (0)