From d190a85003e93430ffed25cf9a5bcff031061895 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Thu, 30 Jan 2025 21:51:37 +0530 Subject: [PATCH 1/3] chore: migration changes --- apiserver/plane/app/views/webhook/base.py | 2 +- apiserver/plane/bgtasks/webhook_task.py | 8 ++-- .../0091_issuecomment_edited_at_and_more.py | 37 +++++++++++++++++++ apiserver/plane/db/models/issue.py | 1 + apiserver/plane/db/models/recent_visit.py | 2 +- apiserver/plane/db/models/user.py | 4 +- apiserver/plane/db/models/webhook.py | 2 +- 7 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py diff --git a/apiserver/plane/app/views/webhook/base.py b/apiserver/plane/app/views/webhook/base.py index d62838faba3..d7ff5cf3abe 100644 --- a/apiserver/plane/app/views/webhook/base.py +++ b/apiserver/plane/app/views/webhook/base.py @@ -120,7 +120,7 @@ class WebhookLogsEndpoint(BaseAPIView): @allow_permission(allowed_roles=[ROLE.ADMIN], level="WORKSPACE") def get(self, request, slug, webhook_id): webhook_logs = WebhookLog.objects.filter( - workspace__slug=slug, webhook_id=webhook_id + workspace__slug=slug, webhook=webhook_id ) serializer = WebhookLogSerializer(webhook_logs, many=True) return Response(serializer.data, status=status.HTTP_200_OK) diff --git a/apiserver/plane/bgtasks/webhook_task.py b/apiserver/plane/bgtasks/webhook_task.py index d5d8b0043e9..141daf79629 100644 --- a/apiserver/plane/bgtasks/webhook_task.py +++ b/apiserver/plane/bgtasks/webhook_task.py @@ -136,7 +136,7 @@ def webhook_task(self, webhook, slug, event, event_data, action, current_site): # Log the webhook request WebhookLog.objects.create( workspace_id=str(webhook.workspace_id), - webhook_id=str(webhook.id), + webhook=str(webhook.id), event_type=str(event), request_method=str(action), request_headers=str(headers), @@ -153,7 +153,7 @@ def webhook_task(self, webhook, slug, event, event_data, action, current_site): # Log the failed webhook request WebhookLog.objects.create( workspace_id=str(webhook.workspace_id), - webhook_id=str(webhook.id), + webhook=str(webhook.id), event_type=str(event), request_method=str(action), request_headers=str(headers), @@ -304,7 +304,7 @@ def webhook_send_task( # Log the webhook request WebhookLog.objects.create( workspace_id=str(webhook.workspace_id), - webhook_id=str(webhook.id), + webhook=str(webhook.id), event_type=str(event), request_method=str(action), request_headers=str(headers), @@ -319,7 +319,7 @@ def webhook_send_task( # Log the failed webhook request WebhookLog.objects.create( workspace_id=str(webhook.workspace_id), - webhook_id=str(webhook.id), + webhook=str(webhook.id), event_type=str(event), request_method=str(action), request_headers=str(headers), diff --git a/apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py b/apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py new file mode 100644 index 00000000000..33d978140e0 --- /dev/null +++ b/apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 4.2.17 on 2025-01-30 16:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('db', '0090_rename_dashboard_deprecateddashboard_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='issuecomment', + name='edited_at', + field=models.DateTimeField(blank=True, null=True), + ), + migrations.AddField( + model_name='profile', + name='is_smooth_cursor_enabled', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='userrecentvisit', + name='entity_name', + field=models.CharField(max_length=30), + ), + migrations.AlterField( + model_name='webhooklog', + name='webhook', + field=models.UUIDField(), + ), + migrations.AlterUniqueTogether( + name='account', + unique_together={('user', 'provider', 'provider_account_id')}, + ), + ] diff --git a/apiserver/plane/db/models/issue.py b/apiserver/plane/db/models/issue.py index ca7347ad792..fe5e9937c74 100644 --- a/apiserver/plane/db/models/issue.py +++ b/apiserver/plane/db/models/issue.py @@ -467,6 +467,7 @@ class IssueComment(ProjectBaseModel): ) external_source = models.CharField(max_length=255, null=True, blank=True) external_id = models.CharField(max_length=255, blank=True, null=True) + edited_at = models.DateTimeField(null=True, blank=True) def save(self, *args, **kwargs): self.comment_stripped = ( diff --git a/apiserver/plane/db/models/recent_visit.py b/apiserver/plane/db/models/recent_visit.py index 14737eba5ad..42855081bd1 100644 --- a/apiserver/plane/db/models/recent_visit.py +++ b/apiserver/plane/db/models/recent_visit.py @@ -17,7 +17,7 @@ class EntityNameEnum(models.TextChoices): class UserRecentVisit(WorkspaceBaseModel): entity_identifier = models.UUIDField(null=True) - entity_name = models.CharField(max_length=30, choices=EntityNameEnum.choices) + entity_name = models.CharField(max_length=30) user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, diff --git a/apiserver/plane/db/models/user.py b/apiserver/plane/db/models/user.py index 8a34e4d7903..cc5ee7c562f 100644 --- a/apiserver/plane/db/models/user.py +++ b/apiserver/plane/db/models/user.py @@ -186,6 +186,8 @@ class Profile(TimeAuditModel): billing_address = models.JSONField(null=True) has_billing_address = models.BooleanField(default=False) company_name = models.CharField(max_length=255, blank=True) + + is_smooth_cursor_enabled = models.BooleanField(default=False) # mobile is_mobile_onboarded = models.BooleanField(default=False) mobile_onboarding_step = models.JSONField(default=get_mobile_default_onboarding) @@ -224,7 +226,7 @@ class Account(TimeAuditModel): metadata = models.JSONField(default=dict) class Meta: - unique_together = ["provider", "provider_account_id"] + unique_together = ["user", "provider", "provider_account_id"] verbose_name = "Account" verbose_name_plural = "Accounts" db_table = "accounts" diff --git a/apiserver/plane/db/models/webhook.py b/apiserver/plane/db/models/webhook.py index dc04e041998..bcaa80b5ab4 100644 --- a/apiserver/plane/db/models/webhook.py +++ b/apiserver/plane/db/models/webhook.py @@ -66,7 +66,7 @@ class WebhookLog(BaseModel): "db.Workspace", on_delete=models.CASCADE, related_name="webhook_logs" ) # Associated webhook - webhook = models.ForeignKey(Webhook, on_delete=models.CASCADE, related_name="logs") + webhook = models.UUIDField() # Basic request details event_type = models.CharField(max_length=255, blank=True, null=True) From e88e916c4433a03c6426f349f6fccd2f4a40f10a Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Fri, 31 Jan 2025 16:42:41 +0530 Subject: [PATCH 2/3] chore: renamed the display value --- apiserver/plane/db/models/webhook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiserver/plane/db/models/webhook.py b/apiserver/plane/db/models/webhook.py index bcaa80b5ab4..b1428523b49 100644 --- a/apiserver/plane/db/models/webhook.py +++ b/apiserver/plane/db/models/webhook.py @@ -89,4 +89,4 @@ class Meta: ordering = ("-created_at",) def __str__(self): - return f"{self.event_type} {str(self.webhook.url)}" + return f"{self.event_type} {str(self.webhook)}" From 142ceb7fdbc4d3bc2e66640fdb87fa49e9745a4d Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Fri, 31 Jan 2025 16:56:13 +0530 Subject: [PATCH 3/3] chore: reverted the accounts code --- .../db/migrations/0091_issuecomment_edited_at_and_more.py | 6 +----- apiserver/plane/db/models/user.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py b/apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py index 33d978140e0..c6fb825a7bf 100644 --- a/apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py +++ b/apiserver/plane/db/migrations/0091_issuecomment_edited_at_and_more.py @@ -29,9 +29,5 @@ class Migration(migrations.Migration): model_name='webhooklog', name='webhook', field=models.UUIDField(), - ), - migrations.AlterUniqueTogether( - name='account', - unique_together={('user', 'provider', 'provider_account_id')}, - ), + ) ] diff --git a/apiserver/plane/db/models/user.py b/apiserver/plane/db/models/user.py index cc5ee7c562f..a7ac5251e8d 100644 --- a/apiserver/plane/db/models/user.py +++ b/apiserver/plane/db/models/user.py @@ -226,7 +226,7 @@ class Account(TimeAuditModel): metadata = models.JSONField(default=dict) class Meta: - unique_together = ["user", "provider", "provider_account_id"] + unique_together = ["provider", "provider_account_id"] verbose_name = "Account" verbose_name_plural = "Accounts" db_table = "accounts"