Skip to content

Commit

Permalink
Update lockfile & fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
agoncharov-reef committed Sep 2, 2024
1 parent fa05a1e commit e3508bc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ jobs:
key: ${{ matrix.python-version }}-pdm-${{ hashFiles('pdm.lock') }}
restore-keys: ${{ matrix.python-version }}-pdm-
- name: Install dependencies
run: python -m pip install --upgrade 'nox==2024.3.2' 'pdm==2.13.2'
run: python -m pip install --upgrade 'nox==2024.3.2' 'pdm>=2.12,<3'
- name: Run unit tests
run: nox -vs test
15 changes: 9 additions & 6 deletions demo/demo/admin.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
from fingerprint.admin import UserFingerprintAdmin
from django.contrib import admin
from django.contrib.auth import get_user_model

from fingerprint.admin import UserFingerprintAdmin

admin.site.unregister(get_user_model())


@admin.register(get_user_model())
class UserAdmin(UserFingerprintAdmin):
list_display = (
'pk', 'email', 'date_joined',
'sessions',
'num_browser_fingerprints', 'browser_fingerprints',
'num_request_fingerprints', 'request_fingerprints',
"pk",
"email",
"date_joined",
"sessions",
"num_browser_fingerprints",
"browser_fingerprints",
"num_request_fingerprints",
"request_fingerprints",
)
2 changes: 1 addition & 1 deletion demo/demo/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from datetime import timedelta

from django.utils.timezone import now
from freezegun import freeze_time
from fingerprint.models import BrowserFingerprint, RequestFingerprint, UserSession
from freezegun import freeze_time


def test__request__anonymous(client, db):
Expand Down
46 changes: 23 additions & 23 deletions pdm.lock

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

12 changes: 6 additions & 6 deletions src/fingerprint/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import timedelta
from functools import wraps
from typing import Optional
from logging import getLogger
from typing import Optional

from django.conf import settings
from django.core.exceptions import BadRequest, DisallowedRedirect
Expand Down Expand Up @@ -43,14 +43,14 @@ def wrapper(request, *args, **kwargs):
with transaction.atomic():
fingerprint, created = RequestFingerprint.objects.get_or_create(
user_session=UserSession.objects.get_or_create(session_key=session_key)[0],
url=Url.from_value(request.build_absolute_uri()[:max_length['url']]),
url=Url.from_value(request.build_absolute_uri()[: max_length["url"]]),
created__gte=now() - debounce_period,
defaults=dict(
ip=get_client_ip(request)[0],
user_agent=request.META.get('HTTP_USER_AGENT', '')[:max_length['user_agent']],
accept=request.META.get('HTTP_ACCEPT', '')[:max_length['accept']],
content_encoding=request.META.get('HTTP_CONTENT_ENCODING', '')[:max_length['content_encoding']],
content_language=request.META.get('HTTP_CONTENT_LANGUAGE', '')[:max_length['content_language']],
user_agent=request.META.get("HTTP_USER_AGENT", "")[: max_length["user_agent"]],
accept=request.META.get("HTTP_ACCEPT", "")[: max_length["accept"]],
content_encoding=request.META.get("HTTP_CONTENT_ENCODING", "")[: max_length["content_encoding"]],
content_language=request.META.get("HTTP_CONTENT_LANGUAGE", "")[: max_length["content_language"]],
referer=request.META.get("HTTP_REFERER", "")[: max_length["referer"]],
cf_ipcountry=request.META.get("HTTP_CF_IPCOUNTRY", "")[: max_length["cf_ipcountry"]],
),
Expand Down

0 comments on commit e3508bc

Please sign in to comment.