Skip to content

Commit

Permalink
fix(history): add a get_absolute_url method to APISHistoryTableBase
Browse files Browse the repository at this point in the history
The historical models use `history_id` as id instead of the `id` of the
instance they refer to. We therefore override the `get_absolute_url`
method, so that it points to the historical record and not to the
instance it refers to.
  • Loading branch information
b1rger committed Apr 26, 2024
1 parent ab83ab9 commit dc8eec5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apis_core/history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def set_version_tag(self, tag: str, include_triples: bool = True):
triple.save()
self.save()

def get_absolute_url(self):
ct = ContentType.objects.get_for_model(self)
return reverse("apis_core:generic:detail", args=[ct, self.history_id])


class VersionMixin(models.Model):
history = APISHistoricalRecords(
Expand Down

0 comments on commit dc8eec5

Please sign in to comment.