mirror of
https://github.com/makeplane/plane.git
synced 2025-12-16 20:07:56 +01:00
feat: add rate limit field to APIToken model and update workspace user preferences
This commit is contained in:
29
apps/api/plane/db/migrations/0112_apitoken_rate_limit.py
Normal file
29
apps/api/plane/db/migrations/0112_apitoken_rate_limit.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Generated by Django 4.2.25 on 2025-11-27 12:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def migrate_workspace_user_preferences_is_pinned(apps, schema_editor):
|
||||
"""
|
||||
Set DRAFTS, YOUR_WORK, STICKIES default to pinned
|
||||
"""
|
||||
apps.get_model("db", "WorkspaceUserPreference").objects.filter(key__in=["drafts", "your_work", "stickies"]).update(is_pinned=True)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('db', '0111_notification_notif_receiver_status_idx_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='apitoken',
|
||||
name='rate_limit',
|
||||
field=models.CharField(default='60/min', max_length=255),
|
||||
),
|
||||
migrations.RunPython(
|
||||
migrate_workspace_user_preferences_is_pinned,
|
||||
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)
|
||||
expired_at = models.DateTimeField(blank=True, null=True)
|
||||
is_service = models.BooleanField(default=False)
|
||||
rate_limit = models.CharField(max_length=255, default="60/min")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "API Token"
|
||||
|
||||
Reference in New Issue
Block a user