From 8b0add24ecdb599ffe92783fd4c0659ac9df2120 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:43:23 +0530 Subject: [PATCH 1/7] add visits tracking for workspace invitation page --- .../migrations/0007_workspaceinvite_visits.py | 18 ++++++++++++++++++ workspaces/models.py | 4 +++- workspaces/views.py | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 workspaces/migrations/0007_workspaceinvite_visits.py diff --git a/workspaces/migrations/0007_workspaceinvite_visits.py b/workspaces/migrations/0007_workspaceinvite_visits.py new file mode 100644 index 000000000..48240e330 --- /dev/null +++ b/workspaces/migrations/0007_workspaceinvite_visits.py @@ -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), + ), + ] diff --git a/workspaces/models.py b/workspaces/models.py index 11375509e..8e73f621d 100644 --- a/workspaces/models.py +++ b/workspaces/models.py @@ -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) @@ -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 diff --git a/workspaces/views.py b/workspaces/views.py index a2e426e6a..87622321f 100644 --- a/workspaces/views.py +++ b/workspaces/views.py @@ -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 @@ -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", From 42c9f04f6695e498f85a8af2b52045795edbd043 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:47:12 +0530 Subject: [PATCH 2/7] show visits on workspace invite admin --- workspaces/admin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/workspaces/admin.py b/workspaces/admin.py index 31524638f..9c850b9bb 100644 --- a/workspaces/admin.py +++ b/workspaces/admin.py @@ -22,13 +22,20 @@ class WorkspaceInviteAdmin(admin.ModelAdmin): "email", "status", "has_expired", + "visits", "created_by", "updated_by", "created_at", "updated_at", ] list_filter = ["created_at", "status"] - readonly_fields = ["auto_accepted", "has_expired", "created_at", "updated_at"] + readonly_fields = [ + "visits", + "auto_accepted", + "has_expired", + "created_at", + "updated_at", + ] autocomplete_fields = ["workspace", "created_by", "updated_by"] From a8fd842d3015690268c8cbb6891a461c6bc71d8f Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:16:26 +0530 Subject: [PATCH 3/7] rename visits -> clicks --- ...rkspaceinvite_visits.py => 0007_workspaceinvite_clicks.py} | 4 ++-- workspaces/models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename workspaces/migrations/{0007_workspaceinvite_visits.py => 0007_workspaceinvite_clicks.py} (81%) diff --git a/workspaces/migrations/0007_workspaceinvite_visits.py b/workspaces/migrations/0007_workspaceinvite_clicks.py similarity index 81% rename from workspaces/migrations/0007_workspaceinvite_visits.py rename to workspaces/migrations/0007_workspaceinvite_clicks.py index 48240e330..6cc131d6f 100644 --- a/workspaces/migrations/0007_workspaceinvite_visits.py +++ b/workspaces/migrations/0007_workspaceinvite_clicks.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.3 on 2024-12-18 16:12 +# Generated by Django 5.1.3 on 2024-12-23 08:46 from django.db import migrations, models @@ -12,7 +12,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name='workspaceinvite', - name='visits', + name='clicks', field=models.IntegerField(default=0), ), ] diff --git a/workspaces/models.py b/workspaces/models.py index 8e73f621d..95c7fd937 100644 --- a/workspaces/models.py +++ b/workspaces/models.py @@ -524,7 +524,7 @@ class Status(models.IntegerChoices): choices=WorkspaceRole.choices, default=WorkspaceRole.MEMBER ) - visits = models.IntegerField(default=0) + clicks = models.IntegerField(default=0) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) From 98b5f36c7551470769e76269a28e80f5f5890f20 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:54:55 +0530 Subject: [PATCH 4/7] rename visits -> clicks in admin --- workspaces/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspaces/admin.py b/workspaces/admin.py index 9c850b9bb..d78dbde20 100644 --- a/workspaces/admin.py +++ b/workspaces/admin.py @@ -22,7 +22,7 @@ class WorkspaceInviteAdmin(admin.ModelAdmin): "email", "status", "has_expired", - "visits", + "clicks", "created_by", "updated_by", "created_at", @@ -30,7 +30,7 @@ class WorkspaceInviteAdmin(admin.ModelAdmin): ] list_filter = ["created_at", "status"] readonly_fields = [ - "visits", + "clicks", "auto_accepted", "has_expired", "created_at", From fe4b194b29d12fbbf570b6d98335275cd4b9335f Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Tue, 24 Dec 2024 21:29:47 +0530 Subject: [PATCH 5/7] visits -> clicks in views.py --- workspaces/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/views.py b/workspaces/views.py index 87622321f..581dae680 100644 --- a/workspaces/views.py +++ b/workspaces/views.py @@ -34,7 +34,7 @@ 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) + WorkspaceInvite.objects.filter(id=invite.id).update(clicks=F("clicks") + 1) with ( gui.div( From cff715c2d236011498eec8c92969063eecde8d09 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:42:31 +0530 Subject: [PATCH 6/7] add "clicks" to WorkspaceInviteInline admin --- workspaces/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/admin.py b/workspaces/admin.py index d78dbde20..eea1735e7 100644 --- a/workspaces/admin.py +++ b/workspaces/admin.py @@ -43,7 +43,7 @@ class WorkspaceInviteInline(admin.TabularInline): model = models.WorkspaceInvite extra = 0 autocomplete_fields = WorkspaceInviteAdmin.autocomplete_fields - readonly_fields = ["auto_accepted", "created_at", "updated_at"] + readonly_fields = ["auto_accepted", "clicks", "created_at", "updated_at"] ordering = ["status", "-created_at"] From 6bd86e87dc5e31de36145bd20049815921976ee4 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:07:01 +0530 Subject: [PATCH 7/7] add updated_at to update_fields in WorkspaceInvite.accept --- workspaces/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/models.py b/workspaces/models.py index 95c7fd937..7cb294458 100644 --- a/workspaces/models.py +++ b/workspaces/models.py @@ -639,7 +639,7 @@ def accept( self.auto_accepted = auto_accepted self.full_clean() - self.save(update_fields=["status", "updated_by", "auto_accepted"]) + self.save(update_fields=["status", "updated_by", "auto_accepted", "updated_at"]) return membership, created