Skip to content

Commit

Permalink
Add new fields to UserVisit
Browse files Browse the repository at this point in the history
  • Loading branch information
mboboc committed Oct 30, 2023
1 parent d78ded9 commit c4b1a36
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.6 on 2023-10-30 10:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("user_visit", "0003_uservisit_context"),
]

operations = [
migrations.AddField(
model_name="uservisit",
name="browser",
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AddField(
model_name="uservisit",
name="device",
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AddField(
model_name="uservisit",
name="os",
field=models.CharField(blank=True, max_length=200, null=True),
),
]
18 changes: 18 additions & 0 deletions user_visit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def build(self, request: HttpRequest, timestamp: datetime.datetime) -> UserVisit
context=REQUEST_CONTEXT_EXTRACTOR(request),
)
uv.hash = uv.md5().hexdigest()
uv.browser = uv.user_agent.get_browser()
uv.device = uv.user_agent.get_device()
uv.os = uv.user_agent.get_os()
return uv


Expand Down Expand Up @@ -82,6 +85,21 @@ class UserVisit(models.Model):
help_text=_lazy("Client User-Agent HTTP header"),
blank=True,
)
browser = models.CharField(
max_length=200,
blank=True,
null=True,
)
device = models.CharField(
max_length=200,
blank=True,
null=True,
)
os = models.CharField(
max_length=200,
blank=True,
null=True,
)
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
hash = models.CharField(
max_length=32,
Expand Down

0 comments on commit c4b1a36

Please sign in to comment.