Merge "Avoid sending error message twice in BatchAction"
This commit is contained in:
commit
2572595f1a
|
@ -19,7 +19,6 @@ from django.template import defaultfilters as filters
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
from horizon.utils import filters as utils_filters
|
||||
|
||||
|
@ -50,15 +49,7 @@ class DeleteDHCPAgent(tables.DeleteAction):
|
|||
|
||||
def delete(self, request, obj_id):
|
||||
network_id = self.table.kwargs['network_id']
|
||||
try:
|
||||
api.neutron.remove_network_from_dhcp_agent(request, obj_id,
|
||||
network_id)
|
||||
except Exception as e:
|
||||
LOG.info('Failed to delete agent: %s', e)
|
||||
msg = _('Failed to delete agent: %s') % e
|
||||
redirect = reverse('horizon:admin:networks:detail',
|
||||
args=[network_id])
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
api.neutron.remove_network_from_dhcp_agent(request, obj_id, network_id)
|
||||
|
||||
|
||||
class AddDHCPAgent(tables.LinkAction):
|
||||
|
|
|
@ -90,11 +90,7 @@ class DeleteVolumeType(tables.DeleteAction):
|
|||
policy_rules = (("volume", "volume_extension:types_manage"),)
|
||||
|
||||
def delete(self, request, obj_id):
|
||||
try:
|
||||
cinder.volume_type_delete(request, obj_id)
|
||||
except exceptions.BadRequest as e:
|
||||
redirect_url = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request, e, redirect=redirect_url)
|
||||
cinder.volume_type_delete(request, obj_id)
|
||||
|
||||
|
||||
class CreateVolumeTypeEncryption(tables.LinkAction):
|
||||
|
|
|
@ -19,14 +19,12 @@ from django.core.urlresolvers import reverse
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard import policy
|
||||
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -83,10 +81,10 @@ class DeleteAllowedAddressPair(tables.DeleteAction):
|
|||
except Exception as e:
|
||||
LOG.error('Failed to update port %(port_id)s: %(reason)s',
|
||||
{'port_id': port_id, 'reason': e})
|
||||
redirect = reverse("horizon:project:networks:ports:detail",
|
||||
args=(port_id,))
|
||||
exceptions.handle(request, _('Failed to update port %s') % port_id,
|
||||
redirect=redirect)
|
||||
# NOTE: No exception handling is required here because
|
||||
# BatchAction.handle() does it. What we need to do is
|
||||
# just to re-raise the exception.
|
||||
raise
|
||||
|
||||
|
||||
class AllowedAddressPairsTable(tables.DataTable):
|
||||
|
|
|
@ -21,7 +21,6 @@ from django.utils.translation import pgettext_lazy
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
@ -125,17 +124,15 @@ class DeletePort(policy.PolicyTargetMixin, tables.DeleteAction):
|
|||
policy_rules = (("network", "delete_port"),)
|
||||
|
||||
def delete(self, request, port_id):
|
||||
failure_url = "horizon:project:networks:detail"
|
||||
try:
|
||||
api.neutron.port_delete(request, port_id)
|
||||
except Exception as e:
|
||||
LOG.info('Failed to delete port %(id)s: %(exc)s',
|
||||
{'id': port_id, 'exc': e})
|
||||
msg = _('Failed to delete port %s') % port_id
|
||||
network_id = self.table.kwargs['network_id']
|
||||
redirect = reverse(failure_url,
|
||||
args=[network_id])
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
# NOTE: No exception handling is required here because
|
||||
# BatchAction.handle() does it. What we need to do is
|
||||
# just to re-raise the exception.
|
||||
raise
|
||||
|
||||
|
||||
class PortsTable(tables.DataTable):
|
||||
|
|
|
@ -19,7 +19,6 @@ from django.utils.translation import pgettext_lazy
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.project.networks.ports \
|
||||
|
@ -84,11 +83,10 @@ class RemoveInterface(policy.PolicyTargetMixin, tables.DeleteAction):
|
|||
except Exception as e:
|
||||
LOG.info('Failed to delete interface %(id)s: %(exc)s',
|
||||
{'id': obj_id, 'exc': e})
|
||||
msg = _('Failed to delete interface %s') % obj_id
|
||||
router_id = self.table.kwargs['router_id']
|
||||
redirect = reverse(self.failure_url,
|
||||
args=[router_id])
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
# NOTE: No exception handling is required here because
|
||||
# BatchAction.handle() does it. What we need to do is
|
||||
# just to re-raise the exception.
|
||||
raise
|
||||
|
||||
|
||||
DISPLAY_CHOICES = (
|
||||
|
|
Loading…
Reference in New Issue