Skip to content

Commit

Permalink
Merge pull request #134 from molgen/fix-first-publication
Browse files Browse the repository at this point in the history
publications: Fix sort_order bug for very first publication
  • Loading branch information
donald authored May 30, 2025
2 parents bf9f773 + 29f6842 commit e672978
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mpicms/publications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
class LatestFirstOrderable(Orderable):
def save(self, *args, **kwargs):
if self.pk is None:
self.sort_order = self.__class__.objects.aggregate(models.Min('sort_order'))['sort_order__min'] - 1
min = self.__class__.objects.aggregate(models.Min('sort_order'))['sort_order__min']
self.sort_order = min - 1 if min is not None else 0
super(Orderable, self).save(*args, **kwargs)

class Meta:
Expand Down

0 comments on commit e672978

Please sign in to comment.