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
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