From d7f5211fc4870c8e95a04a7a39fbde3b24be3ada Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 8 Aug 2017 21:26:06 -0500 Subject: [PATCH] Add support for cloning an upgrade record until this is all ironed out, seems like it will often be helpful --- tailbone/static/js/tailbone.js | 3 ++ tailbone/templates/master/clone.mako | 24 ++++++++++++++ tailbone/templates/master/view.mako | 7 +++- .../templates/themes/better/master/view.mako | 16 --------- tailbone/views/master.py | 33 +++++++++++++++++++ tailbone/views/upgrades.py | 15 +++++++++ 6 files changed, 81 insertions(+), 17 deletions(-) create mode 100644 tailbone/templates/master/clone.mako diff --git a/tailbone/static/js/tailbone.js b/tailbone/static/js/tailbone.js index 63141400..d9022dbf 100644 --- a/tailbone/static/js/tailbone.js +++ b/tailbone/static/js/tailbone.js @@ -174,6 +174,9 @@ $(function() { $('button, a.button').button(); $('input[type=submit]').button(); $('input[type=reset]').button(); + $('a.button.autodisable').click(function() { + disable_button(this); + }); $('input[type="submit"].autodisable').click(function() { disable_button(this); }); diff --git a/tailbone/templates/master/clone.mako b/tailbone/templates/master/clone.mako new file mode 100644 index 00000000..c4ed4380 --- /dev/null +++ b/tailbone/templates/master/clone.mako @@ -0,0 +1,24 @@ +## -*- coding: utf-8; -*- +<%inherit file="/base.mako" /> + +<%def name="title()">Clone ${model_title}: ${instance_title} + +
+

You are about to clone the following ${model_title} as a new record:

+ +
+ ${form.render()|n} +
+ +
+

Are you sure about this?

+
+ +${h.form(request.current_route_url())} +${h.csrf_token(request)} +${h.hidden('clone', value='clone')} +
+ ${h.link_to("Whoops, nevermind...", form.cancel_url, class_='button autodisable')} + ${h.submit('submit', "Yes, please clone away", class_='autodisable')} +
+${h.end_form()} diff --git a/tailbone/templates/master/view.mako b/tailbone/templates/master/view.mako index 32f7884a..e50ebd71 100644 --- a/tailbone/templates/master/view.mako +++ b/tailbone/templates/master/view.mako @@ -27,8 +27,10 @@ <%def name="context_menu_items()"> -
  • ${h.link_to("Back to {}".format(model_title_plural), index_url)}
  • ${h.link_to("Permalink for this {}".format(model_title), action_url('view', instance))}
  • + % if master.has_versions and request.rattail_config.versioning_enabled() and request.has_perm('{}.versions'.format(permission_prefix)): +
  • ${h.link_to("Version History", action_url('versions', instance))}
  • + % endif % if master.editable and instance_editable and request.has_perm('{}.edit'.format(permission_prefix)):
  • ${h.link_to("Edit this {}".format(model_title), action_url('edit', instance))}
  • % endif @@ -38,6 +40,9 @@ % if master.creatable and request.has_perm('{}.create'.format(permission_prefix)):
  • ${h.link_to("Create a new {}".format(model_title), url('{}.create'.format(route_prefix)))}
  • % endif + % if master.cloneable and request.has_perm('{}.clone'.format(permission_prefix)): +
  • ${h.link_to("Clone this as new {}".format(model_title), url('{}.clone'.format(route_prefix), uuid=instance.uuid))}
  • + % endif