feat: default state for project (#264)

This commit is contained in:
pablohashescobar 2023-02-14 01:12:32 +05:30 committed by GitHub
parent c6f0990605
commit 97ffdc8124
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 22 deletions

View file

@ -83,9 +83,14 @@ class Issue(ProjectBaseModel):
try:
from plane.db.models import State
self.state, created = State.objects.get_or_create(
project=self.project, name="Backlog"
)
default_state = State.objects.filter(
project=self.project, default=True
).first()
# if there is no default state assign any random state
if default_state is None:
self.state = State.objects.filter(project=self.project).first()
else:
self.state = default_state
except ImportError:
pass
else:

View file

@ -23,6 +23,7 @@ class State(ProjectBaseModel):
default="backlog",
max_length=20,
)
default = models.BooleanField(default=False)
def __str__(self):
"""Return name of the state"""