-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69cc922
commit 6673621
Showing
9 changed files
with
238 additions
and
6 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
Empty file.
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SimpleHistoryConfig(AppConfig): | ||
name = "unfold.contrib.simple_history" | ||
label = "unfold_simple_history" |
80 changes: 80 additions & 0 deletions
80
src/unfold/contrib/simple_history/templates/simple_history/_object_history_list.html
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,80 @@ | ||
{% load i18n %} | ||
{% load url from simple_history_compat %} | ||
{% load admin_urls %} | ||
{% load getattribute from getattributes %} | ||
|
||
<table id="change-history" class="border-gray-200 border-spacing-none border-separate mb-6 text-gray-700 w-full dark:text-gray-400 lg:border lg:rounded-md lg:shadow-sm lg:dark:border-gray-800"> | ||
<thead class="hidden lg:table-header-group"> | ||
<tr> | ||
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm"> | ||
{% trans 'Object' %} | ||
</th> | ||
|
||
{% for column in history_list_display %} | ||
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm"> | ||
{% trans column %} | ||
</th> | ||
{% endfor %} | ||
|
||
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm"> | ||
{% trans 'Date/time' %} | ||
</th> | ||
|
||
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm"> | ||
{% trans 'Comment' %} | ||
</th> | ||
|
||
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm"> | ||
{% trans 'Changed by' %} | ||
</th> | ||
|
||
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm"> | ||
{% trans 'Change reason' %} | ||
</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
{% for action in action_list %} | ||
<tr class="block border mb-3 rounded-md shadow-sm lg:table-row lg:border-none lg:mb-0 lg:shadow-none dark:border-gray-800"> | ||
<td class="align-middle flex border-t border-gray-200 font-normal px-3 py-2 text-left text-sm before:flex before:capitalize before:content-[attr(data-label)] before:items-center before:mr-auto before:text-gray-500 first:border-t-0 dark:before:text-gray-400 lg:before:hidden lg:first:border-t lg:py-3 lg:table-cell dark:border-gray-800" data-label="{% trans 'Object' %}"> | ||
<a href="{% url opts|admin_urlname:'simple_history' object.pk action.pk %}"> | ||
{{ action.history_object }} | ||
</a> | ||
</td> | ||
|
||
{% for column in history_list_display %} | ||
<td class="align-middle flex border-t border-gray-200 font-normal px-3 py-2 text-left text-sm before:flex before:capitalize before:content-[attr(data-label)] before:items-center before:mr-auto before:text-gray-500 first:border-t-0 dark:before:text-gray-400 lg:before:hidden lg:first:border-t lg:py-3 lg:table-cell dark:border-gray-800" data-label="{% trans column %}"> | ||
{{ action|getattribute:column }} | ||
</th> | ||
{% endfor %} | ||
|
||
<td class="align-middle flex border-t border-gray-200 font-normal px-3 py-2 text-left text-sm before:flex before:capitalize before:content-[attr(data-label)] before:items-center before:mr-auto before:text-gray-500 first:border-t-0 dark:before:text-gray-400 lg:before:hidden lg:first:border-t lg:py-3 lg:table-cell dark:border-gray-800" data-label="{% trans 'Date/time' %}"> | ||
{{ action.history_date }} | ||
</td> | ||
|
||
<td class="align-middle flex border-t border-gray-200 font-normal px-3 py-2 text-left text-sm before:flex before:capitalize before:content-[attr(data-label)] before:items-center before:mr-auto before:text-gray-500 first:border-t-0 dark:before:text-gray-400 lg:before:hidden lg:first:border-t lg:py-3 lg:table-cell dark:border-gray-800" data-label="{% trans 'Comment' %}"> | ||
{{ action.get_history_type_display }} | ||
</td> | ||
|
||
<td class="align-middle flex border-t border-gray-200 font-normal px-3 py-2 text-left text-sm before:flex before:capitalize before:content-[attr(data-label)] before:items-center before:mr-auto before:text-gray-500 first:border-t-0 dark:before:text-gray-400 lg:before:hidden lg:first:border-t lg:py-3 lg:table-cell dark:border-gray-800" data-label="{% trans 'Changed by' %}"> | ||
{% if action.history_user %} | ||
{% url admin_user_view action.history_user_id as admin_user_url %} | ||
|
||
{% if admin_user_url %} | ||
<a href="{{ admin_user_url }}">{{ action.history_user }}</a> | ||
{% else %} | ||
{{ action.history_user }} | ||
{% endif %} | ||
{% else %} | ||
{% trans "None" %} | ||
{% endif %} | ||
</td> | ||
|
||
<td class="align-middle flex border-t border-gray-200 font-normal px-3 py-2 text-left text-sm before:flex before:capitalize before:content-[attr(data-label)] before:items-center before:mr-auto before:text-gray-500 first:border-t-0 dark:before:text-gray-400 lg:before:hidden lg:first:border-t lg:py-3 lg:table-cell dark:border-gray-800" data-label="{% trans 'Change reason' %}"> | ||
{{ action.history_change_reason }} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> |
21 changes: 21 additions & 0 deletions
21
src/unfold/contrib/simple_history/templates/simple_history/object_history.html
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 @@ | ||
{% extends "admin/object_history.html" %} | ||
|
||
{% load admin_urls i18n %} | ||
{% load url from simple_history_compat %} | ||
{% load display_list from simple_history_admin_list %} | ||
|
||
{% block content %} | ||
{% if not revert_disabled %} | ||
<p class="px-3 py-3 rounded-md text-sm last:mb-8 er-amber-600/10 bg-blue-50 mb-8 text-blue-500 dark:bg-blue-500/20 dark:border-blue-500/10"> | ||
{% blocktrans %}Choose a date from the list below to revert to a previous version of this object.{% endblocktrans %} | ||
</p> | ||
{% endif %} | ||
|
||
{% if action_list %} | ||
{% display_list %} | ||
{% else %} | ||
<p class="mb-3 px-3 py-3 rounded-md text-sm last:mb-8 bg-amber-100 text-amber-600 dark:bg-amber-600/20 dark:border-amber-600/10"> | ||
{% trans "This object doesn't have a change history." %} | ||
</p> | ||
{% endif %} | ||
{% endblock %} |
55 changes: 55 additions & 0 deletions
55
src/unfold/contrib/simple_history/templates/simple_history/object_history_form.html
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,55 @@ | ||
{% extends "admin/change_form.html" %} | ||
|
||
{% load admin_urls i18n %} | ||
{% load url from simple_history_compat%} | ||
|
||
{% block breadcrumbs %} | ||
<div class="px-4 lg:px-12"> | ||
<div class="container mb-6 mx-auto -my-3 lg:mb-12"> | ||
<ul class="flex"> | ||
{% url 'admin:index' as link %} | ||
{% trans 'Home' as name %} | ||
{% include 'unfold/helpers/breadcrumb_item.html' with link=link name=name %} | ||
|
||
{% url 'admin:app_list' app_label=opts.app_label as link %} | ||
{% include 'unfold/helpers/breadcrumb_item.html' with link=link name=opts.app_config.verbose_name %} | ||
|
||
{% include 'unfold/helpers/breadcrumb_item.html' with link=changelist_url name=opts.verbose_name_plural|capfirst %} | ||
|
||
{% include 'unfold/helpers/breadcrumb_item.html' with link=change_url name=original|truncatewords:'18' %} | ||
|
||
{% url opts|admin_urlname:'change' object.pk|admin_urlquote as link %} | ||
{% trans 'History' as name %} | ||
{% include 'unfold/helpers/breadcrumb_item.html' with link="../" name=name %} | ||
|
||
{% if revert_disabled %} | ||
{% trans "View" as name %} | ||
{% include 'unfold/helpers/breadcrumb_item.html' with link="" name=name %} | ||
{% else %} | ||
{% trans "Revert" as name %} | ||
{% include 'unfold/helpers/breadcrumb_item.html' with link="" name=name %} | ||
{% endif %} | ||
</ul> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block submit_buttons_top %} | ||
{% include "simple_history/submit_line.html" %} | ||
{% endblock %} | ||
|
||
{% block submit_buttons_bottom %} | ||
{% include "simple_history/submit_line.html" %} | ||
{% endblock %} | ||
|
||
{% block form_top %} | ||
<p class="px-3 py-3 rounded-md text-sm last:mb-8 er-amber-600/10 bg-blue-50 mb-8 text-blue-500 dark:bg-blue-500/20 dark:border-blue-500/10"> | ||
{% if not revert_disabled %} | ||
{% blocktrans %}Press the 'Revert' button below to revert to this version of the object.{% endblocktrans %} | ||
{% endif %} | ||
|
||
{% if change_history %} | ||
{% blocktrans %}Press the 'Change History' button below to edit the history.{% endblocktrans %} | ||
{% endif %} | ||
</p> | ||
{% endblock %} |
25 changes: 25 additions & 0 deletions
25
src/unfold/contrib/simple_history/templates/simple_history/submit_line.html
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,25 @@ | ||
{% load i18n %} | ||
|
||
<div {% if not is_popup %}id="submit-row"{% endif %} class="relative z-20 {% if not is_popup %} mt-20 lg:mt-8{% endif %}"> | ||
<div class="{% if not is_popup %}bottom-0 fixed left-0 right-0 xl:left-72{% endif %}" :class="{'xl:left-0': !sidebarDesktopOpen}"> | ||
<div class="bg-white dark:bg-gray-900 {% if not is_popup %}border-t px-4 py-4 relative scrollable-top lg:px-12 dark:border-gray-800{% endif %}"> | ||
<div class="container flex flex-col-reverse gap-3 items-center mx-auto lg:flex-row-reverse"> | ||
{% if not revert_disabled %} | ||
<button type="submit" class="bg-primary-600 block border border-transparent font-medium px-3 py-2 rounded-md text-sm text-white w-full lg:w-auto" name="_save" {{ onclick_attrib }}> | ||
{% trans 'Revert' %} | ||
</button> | ||
{% endif %} | ||
|
||
{% if change_history %} | ||
<button type="submit" class="bg-primary-600 block border border-transparent font-medium px-3 py-2 rounded-md text-sm text-white w-full lg:w-auto" name="_change_history" {{ onclick_attrib }}> | ||
{% trans 'Change History' %} | ||
</button> | ||
{% endif %} | ||
|
||
<a href="{{ history_url }}" class="border font-medium hidden mr-auto px-3 py-2 rounded-md text-sm text-gray-500 transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-900"> | ||
{% trans 'Close' %} | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Large diffs are not rendered by default.
Oops, something went wrong.
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