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 <narayan3119@gmail.com>
This commit is contained in:
parent
dcd8d27eae
commit
1072509642
5 changed files with 74 additions and 0 deletions
57
apps/api/plane/db/migrations/0113_webhook_version.py
Normal file
57
apps/api/plane/db/migrations/0113_webhook_version.py
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
# Generated by Django 4.2.26 on 2025-12-15 10:29
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import plane.db.models.workspace
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_product_tour():
|
||||||
|
return {
|
||||||
|
"work_items": True,
|
||||||
|
"cycles": True,
|
||||||
|
"modules": True,
|
||||||
|
"intake": True,
|
||||||
|
"pages": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def populate_product_tour(apps, _schema_editor):
|
||||||
|
WorkspaceUserProperties = apps.get_model('db', 'WorkspaceUserProperties')
|
||||||
|
default_value = get_default_product_tour()
|
||||||
|
# Use bulk update for better performance
|
||||||
|
WorkspaceUserProperties.objects.all().update(product_tour=default_value)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('db', '0112_auto_20251124_0603'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='webhook',
|
||||||
|
name='version',
|
||||||
|
field=models.CharField(default='v1', max_length=50),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='profile',
|
||||||
|
name='is_navigation_tour_completed',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='workspaceuserproperties',
|
||||||
|
name='product_tour',
|
||||||
|
field=models.JSONField(default=plane.db.models.workspace.get_default_product_tour),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='apitoken',
|
||||||
|
name='allowed_rate_limit',
|
||||||
|
field=models.CharField(default='60/min', max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='profile',
|
||||||
|
name='is_subscribed_to_changelog',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.RunPython(populate_product_tour, reverse_code=migrations.RunPython.noop),
|
||||||
|
]
|
||||||
|
|
@ -32,6 +32,7 @@ class APIToken(BaseModel):
|
||||||
workspace = models.ForeignKey("db.Workspace", related_name="api_tokens", on_delete=models.CASCADE, null=True)
|
workspace = models.ForeignKey("db.Workspace", related_name="api_tokens", on_delete=models.CASCADE, null=True)
|
||||||
expired_at = models.DateTimeField(blank=True, null=True)
|
expired_at = models.DateTimeField(blank=True, null=True)
|
||||||
is_service = models.BooleanField(default=False)
|
is_service = models.BooleanField(default=False)
|
||||||
|
allowed_rate_limit = models.CharField(max_length=255, default="60/min")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "API Token"
|
verbose_name = "API Token"
|
||||||
|
|
|
||||||
|
|
@ -233,8 +233,12 @@ class Profile(TimeAuditModel):
|
||||||
goals = models.JSONField(default=dict)
|
goals = models.JSONField(default=dict)
|
||||||
background_color = models.CharField(max_length=255, default=get_random_color)
|
background_color = models.CharField(max_length=255, default=get_random_color)
|
||||||
|
|
||||||
|
# navigation tour
|
||||||
|
is_navigation_tour_completed = models.BooleanField(default=False)
|
||||||
|
|
||||||
# marketing
|
# marketing
|
||||||
has_marketing_email_consent = models.BooleanField(default=False)
|
has_marketing_email_consent = models.BooleanField(default=False)
|
||||||
|
is_subscribed_to_changelog = models.BooleanField(default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Profile"
|
verbose_name = "Profile"
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ class Webhook(BaseModel):
|
||||||
cycle = models.BooleanField(default=False)
|
cycle = models.BooleanField(default=False)
|
||||||
issue_comment = models.BooleanField(default=False)
|
issue_comment = models.BooleanField(default=False)
|
||||||
is_internal = models.BooleanField(default=False)
|
is_internal = models.BooleanField(default=False)
|
||||||
|
version = models.CharField(default="v1", max_length=50)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.workspace.slug} {self.url}"
|
return f"{self.workspace.slug} {self.url}"
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,16 @@ def slug_validator(value):
|
||||||
raise ValidationError("Slug is not valid")
|
raise ValidationError("Slug is not valid")
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_product_tour():
|
||||||
|
return {
|
||||||
|
"work_items": False,
|
||||||
|
"cycles": False,
|
||||||
|
"modules": False,
|
||||||
|
"intake": False,
|
||||||
|
"pages": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Workspace(BaseModel):
|
class Workspace(BaseModel):
|
||||||
TIMEZONE_CHOICES = tuple(zip(pytz.common_timezones, pytz.common_timezones))
|
TIMEZONE_CHOICES = tuple(zip(pytz.common_timezones, pytz.common_timezones))
|
||||||
|
|
||||||
|
|
@ -325,6 +335,7 @@ class WorkspaceUserProperties(BaseModel):
|
||||||
choices=NavigationControlPreference.choices,
|
choices=NavigationControlPreference.choices,
|
||||||
default=NavigationControlPreference.ACCORDION,
|
default=NavigationControlPreference.ACCORDION,
|
||||||
)
|
)
|
||||||
|
product_tour = models.JSONField(default=get_default_product_tour)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ["workspace", "user", "deleted_at"]
|
unique_together = ["workspace", "user", "deleted_at"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue