-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add a view for listing reversion version information
This commit adds a view to list versions overall or versions specific to an instance. It also links to that view from the generic detail view of the entities.
- Loading branch information
Showing
4 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends basetemplate %} | ||
|
||
{% block content %} | ||
<ul> | ||
{% for version in object_list %} | ||
<li>{{version.revision.date_created }} - {{ version.revision.user }}: {{ version.revision.get_comment }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.views.generic.list import ListView | ||
from django.contrib.contenttypes.models import ContentType | ||
from reversion.models import Revision, Version | ||
|
||
|
||
class Versions(ListView): | ||
paginate_by = 100 | ||
model = Version | ||
instance = None | ||
|
||
def dispatch(self, request, *args, **kwargs): | ||
if content_type := kwargs.get("content_type"): | ||
contenttype = ContentType.objects.get_for_id(content_type) | ||
if object_id := kwargs.get("object_id"): | ||
self.instance = contenttype.model_class().objects.get(pk=object_id) | ||
return super().dispatch(request, *args, **kwargs) | ||
|
||
def get_queryset(self): | ||
if self.instance: | ||
return Version.objects.get_for_object(self.instance) | ||
return Version.objects.all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters