Merge pull request #287 from makeplane/fix/state_ordering

fix: state ordering in group
This commit is contained in:
pablohashescobar 2023-02-21 23:52:21 +05:30 committed by GitHub
commit 33ed2f6c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,4 +38,13 @@ class State(ProjectBaseModel):
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
if self._state.adding:
# Get the maximum sequence value from the database
last_id = State.objects.filter(project=self.project).aggregate(
largest=models.Max("sequence")
)["largest"]
# if last_id is not None
if last_id is not None:
self.sequence = last_id + 15000
return super().save(*args, **kwargs)