diff --git a/c2cgeoform/templates/widgets/_actions.pt b/c2cgeoform/templates/widgets/_actions.pt new file mode 100644 index 00000000..bae8984f --- /dev/null +++ b/c2cgeoform/templates/widgets/_actions.pt @@ -0,0 +1,41 @@ + + + + ${action.label()} + + + ${action.label()} + + + diff --git a/c2cgeoform/templates/widgets/form.pt b/c2cgeoform/templates/widgets/form.pt index 5bb2e48d..613eb2cf 100644 --- a/c2cgeoform/templates/widgets/form.pt +++ b/c2cgeoform/templates/widgets/form.pt @@ -70,21 +70,7 @@
- - - - ${action.label()} - - - ${action.label()} - +
@@ -141,25 +127,5 @@ $(function () { $('#${field.formid} button[type=submit]').click(function (e) { $(window).off('beforeunload') }); - - $('a.c2cgeoform-action-ajax').on('click', function(e) { - var execute = function() { - $.ajax({ - url: $(this).data('url'), - type: $(this).data('method'), - success: function(data) { - window.location = data.redirect; - } - }); - }.bind(this); - - if ($(this).data('confirmation')) { - if (window.confirm($(this).data('confirmation'))) { - execute(); - } - } else { - execute(); - } - }); }); diff --git a/c2cgeoform/templates/widgets/readonly/form.pt b/c2cgeoform/templates/widgets/readonly/form.pt index 35fe46ac..701bef15 100644 --- a/c2cgeoform/templates/widgets/readonly/form.pt +++ b/c2cgeoform/templates/widgets/readonly/form.pt @@ -39,6 +39,12 @@ + + diff --git a/c2cgeoform/views/abstract_views.py b/c2cgeoform/views/abstract_views.py index a9b77448..6c85bf6b 100644 --- a/c2cgeoform/views/abstract_views.py +++ b/c2cgeoform/views/abstract_views.py @@ -370,7 +370,7 @@ def _grid_item_actions(self, item): 'c2cgeoform_item', id=getattr(item, self._id_field))} - def _item_actions(self, item): + def _item_actions(self, item, readonly=False): actions = [] if inspect(item).persistent and self._model_config().get('duplicate', False): @@ -382,7 +382,7 @@ def _item_actions(self, item): 'c2cgeoform_item_duplicate', id=getattr(item, self._id_field)))) - if inspect(item).persistent: + if inspect(item).persistent and not readonly: actions.append(ItemAction( name='delete', label=_('Delete'), @@ -405,7 +405,7 @@ def edit(self, schema=None, readonly=False): dict_.update(self._request.GET) kwargs = { "request": self._request, - "actions": self._item_actions(obj), + "actions": self._item_actions(obj, readonly=readonly), "readonly": readonly, "obj": obj, }