Skip to content

Commit

Permalink
add visits tracking for workspace invitation page
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Dec 18, 2024
1 parent 6573a92 commit 8b0add2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions workspaces/migrations/0007_workspaceinvite_visits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.3 on 2024-12-18 16:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('workspaces', '0006_workspace_description'),
]

operations = [
migrations.AddField(
model_name='workspaceinvite',
name='visits',
field=models.IntegerField(default=0),
),
]
4 changes: 3 additions & 1 deletion workspaces/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ class Status(models.IntegerChoices):
choices=WorkspaceRole.choices, default=WorkspaceRole.MEMBER
)

visits = models.IntegerField(default=0)

created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Expand Down Expand Up @@ -637,7 +639,7 @@ def accept(
self.auto_accepted = auto_accepted

self.full_clean()
self.save()
self.save(update_fields=["status", "updated_by", "auto_accepted"])

return membership, created

Expand Down
3 changes: 3 additions & 0 deletions workspaces/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gooey_gui as gui
from django.contrib.humanize.templatetags.humanize import naturaltime
from django.core.exceptions import ValidationError
from django.db.models import F
from django.utils.translation import ngettext

from app_users.models import AppUser
Expand Down Expand Up @@ -33,6 +34,8 @@ def invitation_page(
set_current_workspace(session, int(invite.workspace_id))
raise gui.RedirectException(get_route_path(members_route))

WorkspaceInvite.objects.filter(id=invite.id).update(visits=F("visits") + 1)

with (
gui.div(
className="position-absolute top-0 start-0 bottom-0 bg-black min-vw-100 min-vh-100",
Expand Down

0 comments on commit 8b0add2

Please sign in to comment.