Add initial versioning support with SQLAlchemy-Continuum.
This commit is contained in:
parent
41dd2ef17b
commit
def466935b
43 changed files with 717 additions and 26 deletions
|
@ -8,6 +8,9 @@
|
|||
% elif form.updating:
|
||||
<li>${h.link_to("View this Brand", url('brand.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('brand.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('brand.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/brands/versions/index.mako
Normal file
3
tailbone/templates/brands/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/brands/versions/view.mako
Normal file
3
tailbone/templates/brands/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
|
@ -8,6 +8,9 @@
|
|||
% elif form.updating:
|
||||
<li>${h.link_to("View this Category", url('category.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('category.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('category.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/categories/versions/index.mako
Normal file
3
tailbone/templates/categories/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/categories/versions/view.mako
Normal file
3
tailbone/templates/categories/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
|
@ -8,6 +8,9 @@
|
|||
% elif form.updating:
|
||||
<li>${h.link_to("View this Department", url('department.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('department.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('department.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/departments/versions/index.mako
Normal file
3
tailbone/templates/departments/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/departments/versions/view.mako
Normal file
3
tailbone/templates/departments/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
|
@ -11,6 +11,9 @@
|
|||
<li>${h.link_to("Edit Printer Settings", url('label_profile.printer_settings', uuid=profile.uuid))}</li>
|
||||
% endif
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('labelprofile.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('labelprofile.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/labels/profiles/versions/index.mako
Normal file
3
tailbone/templates/labels/profiles/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/labels/profiles/versions/view.mako
Normal file
3
tailbone/templates/labels/profiles/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
|
@ -8,6 +8,9 @@
|
|||
% elif form.updating:
|
||||
<li>${h.link_to("View this Product", url('product.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('product.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('product.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/products/versions/index.mako
Normal file
3
tailbone/templates/products/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/products/versions/view.mako
Normal file
3
tailbone/templates/products/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
|
@ -14,6 +14,9 @@
|
|||
<li>${h.link_to("View this Role", url('role.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
<li>${h.link_to("Delete this Role", url('role.delete', uuid=form.fieldset.model.uuid), class_='delete')}</li>
|
||||
% if not form.creating and request.has_perm('role.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('role.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/roles/versions/index.mako
Normal file
3
tailbone/templates/roles/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/roles/versions/view.mako
Normal file
3
tailbone/templates/roles/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
|
@ -8,6 +8,9 @@
|
|||
% elif form.updating:
|
||||
<li>${h.link_to("View this Subdepartment", url('subdepartment.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('subdepartment.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('subdepartment.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/subdepartments/versions/index.mako
Normal file
3
tailbone/templates/subdepartments/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/subdepartments/versions/view.mako
Normal file
3
tailbone/templates/subdepartments/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
|
@ -8,6 +8,9 @@
|
|||
% elif form.updating:
|
||||
<li>${h.link_to("View this User", url('user.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('user.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('user.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/users/versions/index.mako
Normal file
3
tailbone/templates/users/versions/index.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/users/versions/view.mako
Normal file
3
tailbone/templates/users/versions/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/vendors/crud.mako
vendored
3
tailbone/templates/vendors/crud.mako
vendored
|
@ -8,6 +8,9 @@
|
|||
% elif form.updating:
|
||||
<li>${h.link_to("View this Vendor", url('vendor.read', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
% if not form.creating and request.has_perm('vendor.versions.view'):
|
||||
<li>${h.link_to("View Change History ({0})".format(version_count), url('vendor.versions', uuid=form.fieldset.model.uuid))}</li>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
|
3
tailbone/templates/vendors/versions/index.mako
vendored
Normal file
3
tailbone/templates/vendors/versions/index.mako
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/index.mako" />
|
||||
${parent.body()}
|
3
tailbone/templates/vendors/versions/view.mako
vendored
Normal file
3
tailbone/templates/vendors/versions/view.mako
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/versions/view.mako" />
|
||||
${parent.body()}
|
15
tailbone/templates/versions/index.mako
Normal file
15
tailbone/templates/versions/index.mako
Normal file
|
@ -0,0 +1,15 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/grid.mako" />
|
||||
|
||||
<%def name="title()">${model_title} Change History</%def>
|
||||
|
||||
<%def name="context_menu_items()">
|
||||
<li>${h.link_to("Back to all {0}".format(model_title_plural), url(route_model_list))}</li>
|
||||
<li>${h.link_to("Back to current {0}".format(model_title), url(route_model_view, uuid=model_instance.uuid))}</li>
|
||||
</%def>
|
||||
|
||||
<%def name="form()">
|
||||
<h2>Changes for ${model_title}: ${model_instance}</h2>
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
103
tailbone/templates/versions/view.mako
Normal file
103
tailbone/templates/versions/view.mako
Normal file
|
@ -0,0 +1,103 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/base.mako" />
|
||||
|
||||
<%def name="title()">${model_title} Version Details</%def>
|
||||
|
||||
<%def name="head_tags()">
|
||||
<style type="text/css">
|
||||
td.oldvalue {
|
||||
background-color: #fcc;
|
||||
}
|
||||
td.newvalue {
|
||||
background-color: #cfc;
|
||||
}
|
||||
</style>
|
||||
</%def>
|
||||
|
||||
<%def name="context_menu_items()">
|
||||
<li>${h.link_to("Back to all {0}".format(model_title_plural), url(route_model_list))}</li>
|
||||
<li>${h.link_to("Back to current {0}".format(model_title), url(route_model_view, uuid=model_instance.uuid))}</li>
|
||||
<li>${h.link_to("Back to Version History", url('{0}.versions'.format(route_prefix), uuid=model_instance.uuid))}</li>
|
||||
</%def>
|
||||
|
||||
<div class="form-wrapper">
|
||||
|
||||
<ul class="context-menu">
|
||||
${self.context_menu_items()}
|
||||
</ul>
|
||||
|
||||
<div class="form">
|
||||
|
||||
<div>
|
||||
% if previous_transaction or next_transaction:
|
||||
% if previous_transaction:
|
||||
${h.link_to("<< older version", url('{0}.version'.format(route_prefix), uuid=model_instance.uuid, transaction_id=previous_transaction.id))}
|
||||
% else:
|
||||
<span>(oldest version)</span>
|
||||
% endif
|
||||
|
|
||||
% if next_transaction:
|
||||
${h.link_to("newer version >>", url('{0}.version'.format(route_prefix), uuid=model_instance.uuid, transaction_id=next_transaction.id))}
|
||||
% else:
|
||||
<span>(newest version)</span>
|
||||
% endif
|
||||
% else:
|
||||
<span>(only version)</span>
|
||||
% endif
|
||||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
|
||||
<div class="field-wrapper">
|
||||
<label>When:</label>
|
||||
<div class="field">${h.pretty_datetime(request.rattail_config, transaction.issued_at)}</div>
|
||||
</div>
|
||||
<div class="field-wrapper">
|
||||
<label>Who:</label>
|
||||
<div class="field">${transaction.user or "(unknown / system)"}</div>
|
||||
</div>
|
||||
<div class="field-wrapper">
|
||||
<label>Where:</label>
|
||||
<div class="field">${transaction.remote_addr}</div>
|
||||
</div>
|
||||
|
||||
% for ver in versions:
|
||||
|
||||
<div class="field-wrapper">
|
||||
<label>What:</label>
|
||||
<div class="field" style="font-weight: bold;">${ver.version_parent.__class__.__name__}: ${ver.version_parent}</div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper">
|
||||
<label>Changes:</label>
|
||||
<div class="field">
|
||||
<div class="grid">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Field</th>
|
||||
<th>Old Value</th>
|
||||
<th>New Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
% for key in sorted(ver.changeset):
|
||||
<tr>
|
||||
<td>${key}</td>
|
||||
<td class="oldvalue">${ver.changeset[key][0]}</td>
|
||||
<td class="newvalue">${ver.changeset[key][1]}</td>
|
||||
</tr>
|
||||
% endfor
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
% endfor
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue