From 965dac9f431ec133bfd1d24556ca073f99845b94 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 14 Jul 2017 22:08:48 -0500 Subject: [PATCH] Refactor (coalesce) all batch-related templates --- tailbone/templates/batch/create.mako | 12 +-- tailbone/templates/batch/crud.mako | 82 ----------------- tailbone/templates/batch/edit.mako | 80 ++++++++++++++++- tailbone/templates/batch/handheld/index.mako | 2 +- .../templates/{newbatch => batch}/index.mako | 0 tailbone/templates/batch/row.view.mako | 10 --- tailbone/templates/batch/rows.mako | 22 ----- tailbone/templates/batch/view.mako | 86 ++++++++++++++---- .../mobile/batch/inventory/view.mako | 2 +- .../mobile/batch/inventory/view_row.mako | 2 +- .../mobile/{newbatch => batch}/view.mako | 0 .../mobile/{newbatch => batch}/view_row.mako | 0 tailbone/templates/newbatch/create.mako | 3 - tailbone/templates/newbatch/edit.mako | 73 --------------- tailbone/templates/newbatch/view.mako | 88 ------------------- tailbone/templates/ordering/create.mako | 2 +- tailbone/templates/ordering/view.mako | 2 +- .../templates/purchases/batches/create.mako | 2 +- .../templates/purchases/batches/index.mako | 2 +- .../templates/purchases/batches/view.mako | 4 +- .../templates/vendors/catalogs/create.mako | 8 +- tailbone/views/batch/core.py | 4 +- 22 files changed, 164 insertions(+), 322 deletions(-) delete mode 100644 tailbone/templates/batch/crud.mako rename tailbone/templates/{newbatch => batch}/index.mako (100%) delete mode 100644 tailbone/templates/batch/row.view.mako delete mode 100644 tailbone/templates/batch/rows.mako rename tailbone/templates/mobile/{newbatch => batch}/view.mako (100%) rename tailbone/templates/mobile/{newbatch => batch}/view_row.mako (100%) delete mode 100644 tailbone/templates/newbatch/create.mako delete mode 100644 tailbone/templates/newbatch/edit.mako delete mode 100644 tailbone/templates/newbatch/view.mako diff --git a/tailbone/templates/batch/create.mako b/tailbone/templates/batch/create.mako index bb7c5cfe..fe2b3d07 100644 --- a/tailbone/templates/batch/create.mako +++ b/tailbone/templates/batch/create.mako @@ -1,12 +1,4 @@ -## -*- coding: utf-8 -*- -<%inherit file="/crud.mako" /> - -<%def name="title()">New ${batch_display} - -<%def name="context_menu_items()"> - % if request.has_perm('{0}.view'.format(permission_prefix)): -
  • ${h.link_to("Back to {0}".format(batch_display_plural), url(route_prefix))}
  • - % endif - +## -*- coding: utf-8; -*- +<%inherit file="/master/create.mako" /> ${parent.body()} diff --git a/tailbone/templates/batch/crud.mako b/tailbone/templates/batch/crud.mako deleted file mode 100644 index ecc61021..00000000 --- a/tailbone/templates/batch/crud.mako +++ /dev/null @@ -1,82 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="/crud.mako" /> - -<%def name="title()">${"View" if form.readonly else "Edit"} ${batch_display} - -<%def name="head_tags()"> - - - - -<%def name="context_menu_items()"> -
  • ${h.link_to("Back to {0}".format(batch_display_plural), url(route_prefix))}
  • - % if not batch.executed: - % if form.updating: -
  • ${h.link_to("View this {0}".format(batch_display), url('{0}.view'.format(route_prefix), uuid=batch.uuid))}
  • - % endif - % if form.readonly and request.has_perm('{0}.edit'.format(permission_prefix)): -
  • ${h.link_to("Edit this {0}".format(batch_display), url('{0}.edit'.format(route_prefix), uuid=batch.uuid))}
  • - % endif - % endif - % if request.has_perm('{0}.delete'.format(permission_prefix)): -
  • ${h.link_to("Delete this {0}".format(batch_display), url('{0}.delete'.format(route_prefix), uuid=batch.uuid))}
  • - % endif - - -
    - - - - ${form.render(form_id='batch-form', buttons=capture(buttons))|n} - -
    - -<%def name="buttons()"> -
    - % if not form.readonly and batch.refreshable: - ${h.submit('save-refresh', "Save & Refresh Data")} - % endif - % if not batch.executed and request.has_perm('{0}.execute'.format(permission_prefix)): - ## ${h.link_to(execute_title, url('{0}.execute'.format(route_prefix), uuid=batch.uuid))} - - % endif -
    - - -
    diff --git a/tailbone/templates/batch/edit.mako b/tailbone/templates/batch/edit.mako index d6922b7c..d96d74ac 100644 --- a/tailbone/templates/batch/edit.mako +++ b/tailbone/templates/batch/edit.mako @@ -1,3 +1,77 @@ -## -*- coding: utf-8 -*- -<%inherit file="/batch/crud.mako" /> -${parent.body()} +## -*- coding: utf-8; -*- +<%inherit file="/master/edit.mako" /> + +<%def name="extra_javascript()"> + ${parent.extra_javascript()} + ${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))} + ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))} + + + +<%def name="extra_styles()"> + ${parent.extra_styles()} + + + +<%def name="buttons()"> +
    + % if master.refreshable: + ${h.submit('save-refresh', "Save & Refresh Data")} + % endif + % if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)): + + % endif +
    + + +<%def name="grid_tools()"> + % if not batch.executed: +

    ${h.link_to("Delete all rows matching current search", url('{}.delete_rows'.format(route_prefix), uuid=batch.uuid))}

    + % endif + + + + +
    +## TODO: clean this up or fix etc..? +## % if master.edit_with_rows: +## ${form.render(buttons=capture(buttons))|n} +## % else: + ${form.render()|n} +## % endif +
    + +% if master.edit_with_rows: + ${rows_grid.render_complete(allow_save_defaults=False, tools=capture(self.grid_tools))|n} +% endif + + diff --git a/tailbone/templates/batch/handheld/index.mako b/tailbone/templates/batch/handheld/index.mako index af4e0eae..fd4f87c7 100644 --- a/tailbone/templates/batch/handheld/index.mako +++ b/tailbone/templates/batch/handheld/index.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/newbatch/index.mako" /> +<%inherit file="/batch/index.mako" /> <%def name="extra_javascript()"> ${parent.extra_javascript()} diff --git a/tailbone/templates/newbatch/index.mako b/tailbone/templates/batch/index.mako similarity index 100% rename from tailbone/templates/newbatch/index.mako rename to tailbone/templates/batch/index.mako diff --git a/tailbone/templates/batch/row.view.mako b/tailbone/templates/batch/row.view.mako deleted file mode 100644 index 7fc33199..00000000 --- a/tailbone/templates/batch/row.view.mako +++ /dev/null @@ -1,10 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="/crud.mako" /> - -<%def name="title()">${batch_display} Row - -<%def name="context_menu_items()"> -
  • ${h.link_to("Back to {0}".format(batch_display), url('{0}.view'.format(route_prefix), uuid=row.batch_uuid))}
  • - - -${parent.body()} diff --git a/tailbone/templates/batch/rows.mako b/tailbone/templates/batch/rows.mako deleted file mode 100644 index 616fc694..00000000 --- a/tailbone/templates/batch/rows.mako +++ /dev/null @@ -1,22 +0,0 @@ -## -*- coding: utf-8 -*- -
    - - - - - - - - -
    - ${search.render()} -
    - ## TODO: Fix this check for edit mode. - % if not batch.executed and request.referrer.endswith('/edit'): -

    ${h.link_to("Delete all rows matching current search", url('{0}.rows.bulk_delete'.format(route_prefix), uuid=batch.uuid))}

    - % endif -
    - - ${grid} - -
    diff --git a/tailbone/templates/batch/view.mako b/tailbone/templates/batch/view.mako index 74cb10d3..e4f7f46b 100644 --- a/tailbone/templates/batch/view.mako +++ b/tailbone/templates/batch/view.mako @@ -1,34 +1,88 @@ -## -*- coding: utf-8 -*- -<%inherit file="/batch/crud.mako" /> +## -*- coding: utf-8; -*- +<%inherit file="/master/view.mako" /> -<%def name="head_tags()"> - ${parent.head_tags()} +<%def name="extra_javascript()"> + ${parent.extra_javascript()} + ${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))} + ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))} +<%def name="extra_styles()"> + ${parent.extra_styles()} + + + <%def name="context_menu_items()"> ${parent.context_menu_items()} - % if request.has_perm('{0}.csv'.format(permission_prefix)): -
  • ${h.link_to("Download this {0} as CSV".format(batch_display), url('{0}.csv'.format(route_prefix), uuid=batch.uuid))}
  • + % if master.rows_downloadable and request.has_perm('{}.csv'.format(permission_prefix)): +
  • ${h.link_to("Download row data as CSV", url('{}.csv'.format(route_prefix), uuid=batch.uuid))}
  • + % endif + % if master.cloneable and request.has_perm('{}.clone'.format(permission_prefix)): +
  • ${h.link_to("Clone as new batch", url('{}.clone'.format(route_prefix), uuid=batch.uuid))}
  • % endif <%def name="buttons()">
    - % if not form.readonly and batch.refreshable: - ${h.submit('save-refresh', "Save & Refresh Data")} - % endif - % if not batch.executed and request.has_perm('{0}.execute'.format(permission_prefix)): - - % endif + ${self.leading_buttons()} + ${refresh_button()} + ${execute_button()}
    -${parent.body()} +<%def name="leading_buttons()"> + +<%def name="refresh_button()"> + % if master.viewing and master.batch_refreshable(batch) and request.has_perm('{}.refresh'.format(permission_prefix)): + + % endif + + +<%def name="execute_button()"> + % if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)): + + % endif + + + + +
    + ${form.render(form_id='batch-form', buttons=capture(buttons))|n} +
    + +${rows_grid|n} + +% if not batch.executed: + +% endif diff --git a/tailbone/templates/mobile/batch/inventory/view.mako b/tailbone/templates/mobile/batch/inventory/view.mako index 782fb421..2c8f785c 100644 --- a/tailbone/templates/mobile/batch/inventory/view.mako +++ b/tailbone/templates/mobile/batch/inventory/view.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/mobile/newbatch/view.mako" /> +<%inherit file="/mobile/batch/view.mako" /> <%def name="title()">${h.link_to("Inventory", url('mobile.batch.inventory'))} » ${batch.id_str} diff --git a/tailbone/templates/mobile/batch/inventory/view_row.mako b/tailbone/templates/mobile/batch/inventory/view_row.mako index 50870075..5ef6165a 100644 --- a/tailbone/templates/mobile/batch/inventory/view_row.mako +++ b/tailbone/templates/mobile/batch/inventory/view_row.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/mobile/newbatch/view_row.mako" /> +<%inherit file="/mobile/batch/view_row.mako" /> <%namespace file="/mobile/keypad.mako" import="keypad" /> ## TODO: this is broken for actual page (header) title diff --git a/tailbone/templates/mobile/newbatch/view.mako b/tailbone/templates/mobile/batch/view.mako similarity index 100% rename from tailbone/templates/mobile/newbatch/view.mako rename to tailbone/templates/mobile/batch/view.mako diff --git a/tailbone/templates/mobile/newbatch/view_row.mako b/tailbone/templates/mobile/batch/view_row.mako similarity index 100% rename from tailbone/templates/mobile/newbatch/view_row.mako rename to tailbone/templates/mobile/batch/view_row.mako diff --git a/tailbone/templates/newbatch/create.mako b/tailbone/templates/newbatch/create.mako deleted file mode 100644 index 5d2a2e53..00000000 --- a/tailbone/templates/newbatch/create.mako +++ /dev/null @@ -1,3 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="/master/create.mako" /> -${parent.body()} diff --git a/tailbone/templates/newbatch/edit.mako b/tailbone/templates/newbatch/edit.mako deleted file mode 100644 index b4aa2b65..00000000 --- a/tailbone/templates/newbatch/edit.mako +++ /dev/null @@ -1,73 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="/master/edit.mako" /> - -<%def name="head_tags()"> - ${parent.head_tags()} - ${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))} - ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))} - - - - -<%def name="buttons()"> -
    - % if master.refreshable: - ${h.submit('save-refresh', "Save & Refresh Data")} - % endif - % if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)): - - % endif -
    - - -<%def name="grid_tools()"> - % if not batch.executed: -

    ${h.link_to("Delete all rows matching current search", url('{}.delete_rows'.format(route_prefix), uuid=batch.uuid))}

    - % endif - - - - -
    -## TODO: clean this up or fix etc..? -## % if master.edit_with_rows: -## ${form.render(buttons=capture(buttons))|n} -## % else: - ${form.render()|n} -## % endif -
    - -% if master.edit_with_rows: - ${rows_grid.render_complete(allow_save_defaults=False, tools=capture(self.grid_tools))|n} -% endif - - diff --git a/tailbone/templates/newbatch/view.mako b/tailbone/templates/newbatch/view.mako deleted file mode 100644 index e4f7f46b..00000000 --- a/tailbone/templates/newbatch/view.mako +++ /dev/null @@ -1,88 +0,0 @@ -## -*- coding: utf-8; -*- -<%inherit file="/master/view.mako" /> - -<%def name="extra_javascript()"> - ${parent.extra_javascript()} - ${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))} - ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))} - - - -<%def name="extra_styles()"> - ${parent.extra_styles()} - - - -<%def name="context_menu_items()"> - ${parent.context_menu_items()} - % if master.rows_downloadable and request.has_perm('{}.csv'.format(permission_prefix)): -
  • ${h.link_to("Download row data as CSV", url('{}.csv'.format(route_prefix), uuid=batch.uuid))}
  • - % endif - % if master.cloneable and request.has_perm('{}.clone'.format(permission_prefix)): -
  • ${h.link_to("Clone as new batch", url('{}.clone'.format(route_prefix), uuid=batch.uuid))}
  • - % endif - - -<%def name="buttons()"> -
    - ${self.leading_buttons()} - ${refresh_button()} - ${execute_button()} -
    - - -<%def name="leading_buttons()"> - -<%def name="refresh_button()"> - % if master.viewing and master.batch_refreshable(batch) and request.has_perm('{}.refresh'.format(permission_prefix)): - - % endif - - -<%def name="execute_button()"> - % if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)): - - % endif - - - - -
    - ${form.render(form_id='batch-form', buttons=capture(buttons))|n} -
    - -${rows_grid|n} - -% if not batch.executed: - -% endif diff --git a/tailbone/templates/ordering/create.mako b/tailbone/templates/ordering/create.mako index 76c09a7a..4a8c5d7d 100644 --- a/tailbone/templates/ordering/create.mako +++ b/tailbone/templates/ordering/create.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/newbatch/create.mako" /> +<%inherit file="/batch/create.mako" /> <%def name="extra_javascript()"> ${parent.extra_javascript()} diff --git a/tailbone/templates/ordering/view.mako b/tailbone/templates/ordering/view.mako index 584d4a41..04c7526d 100644 --- a/tailbone/templates/ordering/view.mako +++ b/tailbone/templates/ordering/view.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/newbatch/view.mako" /> +<%inherit file="/batch/view.mako" /> <%def name="extra_javascript()"> ${parent.extra_javascript()} diff --git a/tailbone/templates/purchases/batches/create.mako b/tailbone/templates/purchases/batches/create.mako index b98ce7d5..3a165f01 100644 --- a/tailbone/templates/purchases/batches/create.mako +++ b/tailbone/templates/purchases/batches/create.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/newbatch/create.mako" /> +<%inherit file="/batch/create.mako" /> <%def name="extra_javascript()"> ${parent.extra_javascript()} diff --git a/tailbone/templates/purchases/batches/index.mako b/tailbone/templates/purchases/batches/index.mako index 52617583..4290f93b 100644 --- a/tailbone/templates/purchases/batches/index.mako +++ b/tailbone/templates/purchases/batches/index.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/master/index.mako" /> +<%inherit file="/batch/index.mako" /> <%def name="context_menu_items()"> ${parent.context_menu_items()} diff --git a/tailbone/templates/purchases/batches/view.mako b/tailbone/templates/purchases/batches/view.mako index 25be1af0..f7870fb1 100644 --- a/tailbone/templates/purchases/batches/view.mako +++ b/tailbone/templates/purchases/batches/view.mako @@ -1,5 +1,5 @@ -## -*- coding: utf-8 -*- -<%inherit file="/newbatch/view.mako" /> +## -*- coding: utf-8; -*- +<%inherit file="/batch/view.mako" /> <%def name="extra_javascript()"> ${parent.extra_javascript()} diff --git a/tailbone/templates/vendors/catalogs/create.mako b/tailbone/templates/vendors/catalogs/create.mako index 8565a547..ccb7d21a 100644 --- a/tailbone/templates/vendors/catalogs/create.mako +++ b/tailbone/templates/vendors/catalogs/create.mako @@ -1,8 +1,8 @@ -## -*- coding: utf-8 -*- -<%inherit file="/newbatch/create.mako" /> +## -*- coding: utf-8; -*- +<%inherit file="/batch/create.mako" /> -<%def name="head_tags()"> - ${parent.head_tags()} +<%def name="extra_javascript()"> + ${parent.extra_javascript()}