Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jazzband/django-user-sessions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.7.1
Choose a base ref
...
head repository: jazzband/django-user-sessions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 1,739 additions and 1,002 deletions.
  1. +0 −2 .bumpversion.cfg
  2. +0 −8 .codecov.yml
  3. +40 −0 .github/workflows/release.yml
  4. +61 −0 .github/workflows/test.yml
  5. +8 −1 .gitignore
  6. +20 −0 .pre-commit-config.yaml
  7. +0 −27 .travis.yml
  8. +46 −0 CODE_OF_CONDUCT.md
  9. +5 −0 CONTRIBUTING.rst
  10. +0 −17 CONTRIBUTORS.rst
  11. +8 −4 Makefile
  12. +24 −23 README.rst
  13. +15 −80 docs/conf.py
  14. +0 −1 docs/index.rst
  15. +3 −3 docs/installation.rst
  16. +0 −4 docs/reference.rst
  17. +13 −2 docs/release-notes.rst
  18. +25 −12 docs/usage.rst
  19. +7 −8 example/urls.py
  20. +71 −0 pyproject.toml
  21. +0 −32 requirements_dev.txt
  22. +0 −17 setup.cfg
  23. +0 −33 setup.py
  24. +9 −0 tests/Dockerfile
  25. +89 −0 tests/generate_mmdb.pl
  26. +9 −4 tests/settings.py
  27. +61 −0 tests/test_admin.py
  28. +51 −0 tests/test_client.py
  29. +42 −0 tests/test_commands.py
  30. +45 −0 tests/test_middleware.py
  31. +30 −0 tests/test_models.py
  32. +99 −0 tests/test_sessionstore.py
  33. +471 −0 tests/test_template_filters.py
  34. +51 −0 tests/test_views.py
  35. +0 −468 tests/tests.py
  36. +5 −5 tests/urls.py
  37. +1 −1 user_sessions/utils/tests.py → tests/utils.py
  38. +25 −21 tox.ini
  39. +12 −0 user_sessions/__init__.py
  40. +5 −4 user_sessions/admin.py
  41. +7 −0 user_sessions/apps.py
  42. +32 −78 user_sessions/backends/db.py
  43. +1 −1 user_sessions/locale/ar/LC_MESSAGES/django.po
  44. +1 −1 user_sessions/locale/de/LC_MESSAGES/django.po
  45. +1 −1 user_sessions/locale/he/LC_MESSAGES/django.po
  46. +1 −1 user_sessions/locale/it/LC_MESSAGES/django.po
  47. +1 −1 user_sessions/locale/nl/LC_MESSAGES/django.po
  48. +1 −1 user_sessions/locale/pl_PL/LC_MESSAGES/django.po
  49. BIN user_sessions/locale/ru/LC_MESSAGES/django.mo
  50. +199 −0 user_sessions/locale/ru/LC_MESSAGES/django.po
  51. +1 −1 user_sessions/locale/zh_CN/LC_MESSAGES/django.po
  52. +1 −1 user_sessions/management/commands/clearsessions.py
  53. +1 −1 user_sessions/management/commands/migratesessions.py
  54. +5 −54 user_sessions/middleware.py
  55. +5 −5 user_sessions/migrations/0001_initial.py
  56. +1 −2 user_sessions/migrations/0002_auto_20151208_1536.py
  57. +0 −2 user_sessions/migrations/0003_auto_20161205_1516.py
  58. +18 −0 user_sessions/migrations/0004_alter_session_expire_date.py
  59. +13 −32 user_sessions/models.py
  60. +82 −25 user_sessions/templatetags/user_sessions.py
  61. +8 −9 user_sessions/urls.py
  62. +9 −9 user_sessions/views.py
2 changes: 0 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[bumpversion]
current_version = 1.7.1
files = setup.py docs/conf.py
commit = True
tag = True
tag_name = {new_version}

8 changes: 0 additions & 8 deletions .codecov.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
if: github.repository == 'jazzband/django-user-sessions'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel
- name: Build package
run: |
python setup.py --version
python setup.py sdist --format=gztar bdist_wheel
twine check dist/*
- name: Upload packages to Jazzband
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: jazzband
password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
repository_url: https://jazzband.co/projects/django-user-sessions/upload
61 changes: 61 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test

on: [push, pull_request]

jobs:
build:
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12-dev']
django-version: ['3.2', '4.2', 'main']
exclude:
- python-version: '3.11'
django-version: '3.2'
- python-version: '3.12-dev'
django-version: '3.2'

- python-version: '3.11'
django-version: '4.0'
- python-version: '3.12-dev'
django-version: '4.0'

- python-version: '3.12-dev'
django-version: '4.1'

- python-version: '3.8'
django-version: 'main'
- python-version: '3.9'
django-version: 'main'
- python-version: '3.10'
django-version: 'main'

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions
- name: Tox tests
continue-on-error: ${{ endsWith(matrix.python-version, '-dev') || matrix.django-version == 'main' }}
run: |
tox -v
env:
DJANGO: ${{ matrix.django-version }}

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
name: Python ${{ matrix.python-version }}
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
/example/database.sqlite3
/example/GeoLiteCity.dat
/django_user_sessions.egg-info/
/tests/test_city.mmdb
/tests/test_country.mmdb

/htmlcov/

/.coverage

coverage.xml
/.tox/

/docs/_build/
/GeoLite2-City.mmdb

__pycache__
/venv/
/.eggs/
/build/
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# vim: set nospell:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-toml
- id: check-added-large-files
- id: debug-statements
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Code of Conduct

As contributors and maintainers of the Jazzband projects, and in the interest of
fostering an open and welcoming community, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.

We are committed to making participation in the Jazzband a harassment-free experience
for everyone, regardless of the level of experience, gender, gender identity and
expression, sexual orientation, disability, personal appearance, body size, race,
ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery
- Personal attacks
- Trolling or insulting/derogatory comments
- Public or private harassment
- Publishing other's private information, such as physical or electronic addresses,
without explicit permission
- Other unethical or unprofessional conduct

The Jazzband roadies have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are not
aligned to this Code of Conduct, or to ban temporarily or permanently any contributor
for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

By adopting this Code of Conduct, the roadies commit themselves to fairly and
consistently applying these principles to every aspect of managing the jazzband
projects. Roadies who do not follow or enforce the Code of Conduct may be permanently
removed from the Jazzband roadies.

This code of conduct applies both within project spaces and in public spaces when an
individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
contacting the roadies at `roadies@jazzband.co`. All complaints will be reviewed and
investigated and will result in a response that is deemed necessary and appropriate to
the circumstances. Roadies are obligated to maintain confidentiality with regard to the
reporter of an incident.

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version
1.3.0, available at [https://contributor-covenant.org/version/1/3/0/][version]

[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/3/0/
5 changes: 5 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. image:: https://jazzband.co/static/img/jazzband.svg
:target: https://jazzband.co/
:alt: Jazzband

This is a `Jazzband <https://jazzband.co>`_ project. By contributing you agree to abide by the `Contributor Code of Conduct <https://jazzband.co/about/conduct>`_ and follow the `guidelines <https://jazzband.co/about/guidelines>`_.
17 changes: 0 additions & 17 deletions CONTRIBUTORS.rst

This file was deleted.

12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
TARGET?=tests

.PHONY: flake8 example test coverage
.PHONY: ruff example test coverage

flake8:
flake8 user_sessions example tests
ruff:
ruff user_sessions example tests

example:
DJANGO_SETTINGS_MODULE=example.settings PYTHONPATH=. \
@@ -13,7 +13,11 @@ check:
DJANGO_SETTINGS_MODULE=example.settings PYTHONPATH=. \
python -Wd example/manage.py check

test:
generate-mmdb-fixtures:
docker --context=default buildx build -f tests/Dockerfile --tag test-mmdb-maker tests
docker run --rm --volume $$(pwd)/tests:/data test-mmdb-maker

test: generate-mmdb-fixtures
DJANGO_SETTINGS_MODULE=tests.settings PYTHONPATH=. \
django-admin.py test ${TARGET}

47 changes: 24 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
@@ -2,17 +2,21 @@
Django User Sessions
====================

.. image:: https://travis-ci.org/Bouke/django-user-sessions.svg?branch=master
:alt: Build Status
:target: https://travis-ci.org/Bouke/django-user-sessions
.. image:: https://jazzband.co/static/img/badge.svg
:target: https://jazzband.co/
:alt: Jazzband

.. image:: https://codecov.io/gh/Bouke/django-user-sessions/branch/master/graph/badge.svg
.. image:: https://github.com/jazzband/django-user-sessions/workflows/Test/badge.svg
:alt: GitHub Actions
:target: https://github.com/jazzband/django-user-sessions/actions

.. image:: https://codecov.io/gh/jazzband/django-user-sessions/branch/master/graph/badge.svg
:alt: Test Coverage
:target: https://codecov.io/gh/Bouke/django-user-sessions
:target: https://codecov.io/gh/jazzband/django-user-sessions

.. image:: https://badge.fury.io/py/django-user-sessions.svg
:alt: PyPI
:target: https://pypi.python.org/pypi/django-user-sessions
:target: https://pypi.org/project/django-user-sessions/

Django includes excellent built-in sessions, however all the data is hidden
away into base64 encoded data. This makes it very difficult to run a query on
@@ -26,12 +30,10 @@ forking the repository and sending some pull requests. The package is
translated into English, Dutch and other languages. Please contribute your own
language using Transifex_.

Also, have a look at the online `example app`_, hosted by Heroku_. It also
contains the package `django-two-factor-auth`_, but that application is not a
dependency for this package. Also have a look at the bundled example templates
and views to see how you can integrate the application into your project.
Also have a look at the bundled example templates and views to see how you
can integrate the application into your project.

Compatible with Django 2.2 and 3.0 on Python 3.5, 3.6, 3.7 and 3.8.
Compatible with Django 3.2 and 4.2 on Python 3.8 to 3.11.
Documentation is available at `readthedocs.org`_.


@@ -53,11 +55,11 @@ Or logout the user everywhere:
The user's IP address and user agent are also stored on the session. This
allows to show a list of active sessions to the user in the admin:

.. image:: http://i.imgur.com/YV9Nx3f.png
.. image:: https://i.imgur.com/YV9Nx3f.png

And also in a custom layout:

.. image:: http://i.imgur.com/d7kZtr9.png
.. image:: https://i.imgur.com/d7kZtr9.png


Installation
@@ -73,7 +75,7 @@ documentation on `installing GeoIP`_.
Getting help
============

For general questions regarding this package, please hop over to Stack
For general questions regarding this package, please hop over to Stack
Overflow. If you think there is an issue with this package; check if the
issue is already listed (either open or closed), and file an issue if
it's not.
@@ -129,7 +131,7 @@ The following actions are required to push a new version:

bumpversion [major|minor|patch]
git push && git push --tags
python setup.py sdist bdist_wheel
python -m build --wheel
twine upload dist/*


@@ -140,18 +142,17 @@ This project is licensed under the MIT license.

Credits
=======
This library was written by `Bouke Haarsma`_.
This library was written by `Bouke Haarsma`_ and contributors_.


.. _Transifex: https://www.transifex.com/projects/p/django-user-sessions/
.. _`readthedocs.org`: https://django-user-sessions.readthedocs.org/
.. _Transifex: https://explore.transifex.com/Bouke/django-user-sessions/
.. _`readthedocs.org`: https://django-user-sessions.readthedocs.io/
.. _`installation instructions`:
https://django-user-sessions.readthedocs.io/en/stable/installation.html
.. _`example app`: https://example-two-factor-auth.herokuapp.com
.. _Heroku: https://www.heroku.com
.. _`django-two-factor-auth`: https://github.com/Bouke/django-two-factor-auth
.. _installing GeoIP:
https://docs.djangoproject.com/en/2.0/ref/contrib/gis/geoip2/
.. _tox: https://testrun.org/tox/latest/
.. _tox: https://tox.wiki/en/latest/
.. _Bouke Haarsma:
https://twitter.com/BoukeHaarsma
https://github.com/Bouke
.. _contributors:
https://github.com/jazzband/django-user-sessions/graphs/contributors
Loading