Skip to content

Commit 1072509

Browse files
migration: added webhook version, navigation related fields and allowed_rate_limit for APIToken (#8339)
* migration: added version field in webhook * chore: add max_length * chore: added product tour fields * chore: updated the migration file * chore: removed the duplicated migration file * chore: added allowed_rate_limit for api_tokens * chore: changed key feature tour to product tour * chore: added is_subscribed_to_changelog field --------- Co-authored-by: NarayanBavisetti <[email protected]>
1 parent dcd8d27 commit 1072509

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Generated by Django 4.2.26 on 2025-12-15 10:29
2+
3+
from django.db import migrations, models
4+
import plane.db.models.workspace
5+
6+
7+
def get_default_product_tour():
8+
return {
9+
"work_items": True,
10+
"cycles": True,
11+
"modules": True,
12+
"intake": True,
13+
"pages": True,
14+
}
15+
16+
17+
def populate_product_tour(apps, _schema_editor):
18+
WorkspaceUserProperties = apps.get_model('db', 'WorkspaceUserProperties')
19+
default_value = get_default_product_tour()
20+
# Use bulk update for better performance
21+
WorkspaceUserProperties.objects.all().update(product_tour=default_value)
22+
23+
24+
class Migration(migrations.Migration):
25+
26+
dependencies = [
27+
('db', '0112_auto_20251124_0603'),
28+
]
29+
30+
operations = [
31+
migrations.AddField(
32+
model_name='webhook',
33+
name='version',
34+
field=models.CharField(default='v1', max_length=50),
35+
),
36+
migrations.AddField(
37+
model_name='profile',
38+
name='is_navigation_tour_completed',
39+
field=models.BooleanField(default=False),
40+
),
41+
migrations.AddField(
42+
model_name='workspaceuserproperties',
43+
name='product_tour',
44+
field=models.JSONField(default=plane.db.models.workspace.get_default_product_tour),
45+
),
46+
migrations.AddField(
47+
model_name='apitoken',
48+
name='allowed_rate_limit',
49+
field=models.CharField(default='60/min', max_length=255),
50+
),
51+
migrations.AddField(
52+
model_name='profile',
53+
name='is_subscribed_to_changelog',
54+
field=models.BooleanField(default=False),
55+
),
56+
migrations.RunPython(populate_product_tour, reverse_code=migrations.RunPython.noop),
57+
]

apps/api/plane/db/models/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class APIToken(BaseModel):
3232
workspace = models.ForeignKey("db.Workspace", related_name="api_tokens", on_delete=models.CASCADE, null=True)
3333
expired_at = models.DateTimeField(blank=True, null=True)
3434
is_service = models.BooleanField(default=False)
35+
allowed_rate_limit = models.CharField(max_length=255, default="60/min")
3536

3637
class Meta:
3738
verbose_name = "API Token"

apps/api/plane/db/models/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,12 @@ class Profile(TimeAuditModel):
233233
goals = models.JSONField(default=dict)
234234
background_color = models.CharField(max_length=255, default=get_random_color)
235235

236+
# navigation tour
237+
is_navigation_tour_completed = models.BooleanField(default=False)
238+
236239
# marketing
237240
has_marketing_email_consent = models.BooleanField(default=False)
241+
is_subscribed_to_changelog = models.BooleanField(default=False)
238242

239243
class Meta:
240244
verbose_name = "Profile"

apps/api/plane/db/models/webhook.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Webhook(BaseModel):
3838
cycle = models.BooleanField(default=False)
3939
issue_comment = models.BooleanField(default=False)
4040
is_internal = models.BooleanField(default=False)
41+
version = models.CharField(default="v1", max_length=50)
4142

4243
def __str__(self):
4344
return f"{self.workspace.slug} {self.url}"

apps/api/plane/db/models/workspace.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ def slug_validator(value):
112112
raise ValidationError("Slug is not valid")
113113

114114

115+
def get_default_product_tour():
116+
return {
117+
"work_items": False,
118+
"cycles": False,
119+
"modules": False,
120+
"intake": False,
121+
"pages": False,
122+
}
123+
124+
115125
class Workspace(BaseModel):
116126
TIMEZONE_CHOICES = tuple(zip(pytz.common_timezones, pytz.common_timezones))
117127

@@ -325,6 +335,7 @@ class NavigationControlPreference(models.TextChoices):
325335
choices=NavigationControlPreference.choices,
326336
default=NavigationControlPreference.ACCORDION,
327337
)
338+
product_tour = models.JSONField(default=get_default_product_tour)
328339

329340
class Meta:
330341
unique_together = ["workspace", "user", "deleted_at"]

0 commit comments

Comments
 (0)