-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Django / Python support (5.0, 3.12) (#27)
Released as v2.0
- Loading branch information
1 parent
f5b2a27
commit dcb9599
Showing
12 changed files
with
79 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "django-user-visit" | ||
version = "2.0.dev0" | ||
version = "2.0" | ||
description = "Django app used to track user visits." | ||
license = "MIT" | ||
authors = ["YunoJuno <[email protected]>"] | ||
|
@@ -20,7 +20,6 @@ classifiers = [ | |
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
43 changes: 43 additions & 0 deletions
43
user_visit/management/commands/update_user_visit_user_agent_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from __future__ import annotations | ||
|
||
import argparse | ||
from typing import Any | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.utils.translation import gettext as _, gettext_lazy as _lazy | ||
|
||
from user_visit.models import UserVisit | ||
|
||
|
||
class Command(BaseCommand): | ||
help = _lazy( # noqa: A003 | ||
"Sync browser, device and OS data missing from UserVisit" | ||
) | ||
|
||
def add_arguments(self, parser: argparse.ArgumentParser) -> None: | ||
parser.add_argument( | ||
"-f", | ||
"--force", | ||
action="store_true", | ||
default=False, | ||
help=_( | ||
"Use the --force option to update all UserVisit " | ||
"objects (defaults to backfilling empty records only)." | ||
), | ||
) | ||
|
||
def handle(self, *args: Any, **options: Any) -> None: | ||
visits = UserVisit.objects.all() | ||
if not options["force"]: | ||
visits = visits.filter(ua_string="") | ||
updated = 0 | ||
for v in visits.iterator(): | ||
user_agent = v.user_agent | ||
v.device = user_agent.get_device() | ||
v.os = user_agent.get_os() | ||
v.browser = user_agent.get_browser() | ||
v.save(update_fields=["device", "os", "browser"]) | ||
self.stdout.write(f"Updated UserVisit #{v.pk}") | ||
updated += 1 | ||
self.stdout.write("---") | ||
self.stdout.write(f"Updated {updated} UserVisit objects.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters