forked from github/plane
chore: sort order and issue props for global views (#2283)
This commit is contained in:
parent
7b453dd6b5
commit
7404fe71b1
@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2023-09-27 11:18
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import plane.db.models.workspace
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('db', '0047_auto_20230926_1029'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='globalview',
|
||||||
|
name='sort_order',
|
||||||
|
field=models.FloatField(default=65535),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='workspacemember',
|
||||||
|
name='issue_props',
|
||||||
|
field=models.JSONField(default=plane.db.models.workspace.get_issue_props),
|
||||||
|
),
|
||||||
|
]
|
@ -17,6 +17,7 @@ class GlobalView(BaseModel):
|
|||||||
default=1, choices=((0, "Private"), (1, "Public"))
|
default=1, choices=((0, "Private"), (1, "Public"))
|
||||||
)
|
)
|
||||||
query_data = models.JSONField(default=dict)
|
query_data = models.JSONField(default=dict)
|
||||||
|
sort_order = models.FloatField(default=65535)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Global View"
|
verbose_name = "Global View"
|
||||||
@ -24,6 +25,16 @@ class GlobalView(BaseModel):
|
|||||||
db_table = "global_views"
|
db_table = "global_views"
|
||||||
ordering = ("-created_at",)
|
ordering = ("-created_at",)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self._state.adding:
|
||||||
|
largest_sort_order = GlobalView.objects.filter(
|
||||||
|
project=self.project
|
||||||
|
).aggregate(largest=models.Max("sort_order"))["largest"]
|
||||||
|
if largest_sort_order is not None:
|
||||||
|
self.sort_order = largest_sort_order + 10000
|
||||||
|
|
||||||
|
super(GlobalView, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Return name of the View"""
|
"""Return name of the View"""
|
||||||
return f"{self.name} <{self.workspace.name}>"
|
return f"{self.name} <{self.workspace.name}>"
|
||||||
|
@ -29,7 +29,7 @@ def get_default_props():
|
|||||||
},
|
},
|
||||||
"display_filters": {
|
"display_filters": {
|
||||||
"group_by": None,
|
"group_by": None,
|
||||||
"order_by": '-created_at',
|
"order_by": "-created_at",
|
||||||
"type": None,
|
"type": None,
|
||||||
"sub_issue": True,
|
"sub_issue": True,
|
||||||
"show_empty_groups": True,
|
"show_empty_groups": True,
|
||||||
@ -54,6 +54,15 @@ def get_default_props():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_issue_props():
|
||||||
|
return {
|
||||||
|
"subscribed": True,
|
||||||
|
"assigned": True,
|
||||||
|
"created": True,
|
||||||
|
"all_issues": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Workspace(BaseModel):
|
class Workspace(BaseModel):
|
||||||
name = models.CharField(max_length=80, verbose_name="Workspace Name")
|
name = models.CharField(max_length=80, verbose_name="Workspace Name")
|
||||||
logo = models.URLField(verbose_name="Logo", blank=True, null=True)
|
logo = models.URLField(verbose_name="Logo", blank=True, null=True)
|
||||||
@ -89,6 +98,7 @@ class WorkspaceMember(BaseModel):
|
|||||||
company_role = models.TextField(null=True, blank=True)
|
company_role = models.TextField(null=True, blank=True)
|
||||||
view_props = models.JSONField(default=get_default_props)
|
view_props = models.JSONField(default=get_default_props)
|
||||||
default_props = models.JSONField(default=get_default_props)
|
default_props = models.JSONField(default=get_default_props)
|
||||||
|
issue_props = models.JSONField(default=get_issue_props)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ["workspace", "member"]
|
unique_together = ["workspace", "member"]
|
||||||
|
Loading…
Reference in New Issue
Block a user