Ejemplo n.º 1
0
def delete(request, uuid):
    """Handle deleting connections, showing a confirmation dialog first.

    On GET, display a confirmation page.
    On POST, delete the connection.
    """
    if request.method == 'POST':
        try:
            name = network.delete_connection(uuid)
            messages.success(request, _('Connection %s deleted.') % name)
        except network.ConnectionNotFound:
            messages.error(request, _('Failed to delete connection: '
                                      'Connection not found.'))

        return redirect(reverse_lazy('networks:index'))

    try:
        connection = network.get_connection(uuid)
        name = connection.get_id()
    except network.ConnectionNotFound:
        messages.error(request, _('Failed to delete connection: '
                                  'Connection not found.'))
        return redirect(reverse_lazy('networks:index'))

    return TemplateResponse(request, 'connections_delete.html',
                            {'title': _('Delete Connection'),
                             'subsubmenu': subsubmenu,
                             'name': name})
Ejemplo n.º 2
0
def delete(request, uuid):
    """Handle deleting connections, showing a confirmation dialog first.

    On GET, display a confirmation page.
    On POST, delete the connection.
    """
    if request.method == 'POST':
        try:
            name = network.delete_connection(uuid)
            messages.success(request, _('Connection {name} deleted.')
                             .format(name=name))
        except network.ConnectionNotFound:
            messages.error(request, _('Failed to delete connection: '
                                      'Connection not found.'))

        return redirect(reverse_lazy('networks:index'))

    try:
        connection = network.get_connection(uuid)
        name = connection.get_id()
    except network.ConnectionNotFound:
        messages.error(request, _('Failed to delete connection: '
                                  'Connection not found.'))
        return redirect(reverse_lazy('networks:index'))

    return TemplateResponse(request, 'connections_delete.html',
                            {'title': _('Delete Connection'),
                             'subsubmenu': subsubmenu,
                             'name': name})
Ejemplo n.º 3
0
def delete(request, uuid):
    """Handle deleting connections, showing a confirmation dialog first.

    On GET, display a confirmation page.
    On POST, delete the connection.
    """
    if request.method == "POST":
        try:
            name = network.delete_connection(uuid)
            messages.success(request, _("Connection %s deleted.") % name)
        except network.ConnectionNotFound:
            messages.error(request, _("Failed to delete connection: " "Connection not found."))

        return redirect(reverse_lazy("networks:index"))

    try:
        connection = network.get_connection(uuid)
        name = connection.get_id()
    except network.ConnectionNotFound:
        messages.error(request, _("Failed to delete connection: " "Connection not found."))
        return redirect(reverse_lazy("networks:index"))

    return TemplateResponse(
        request, "connections_delete.html", {"title": _("Delete Connection"), "subsubmenu": subsubmenu, "name": name}
    )
Ejemplo n.º 4
0
 def tearDown(cls):
     network.delete_connection(cls.ethernet_uuid)
     network.delete_connection(cls.wifi_uuid)
     network.delete_connection(cls.pppoe_uuid)
Ejemplo n.º 5
0
 def post(self, request, interface):
     """Delete the server."""
     connection = network.get_connection_by_interface_name(interface)
     network.delete_connection(connection.get_uuid())
     messages.success(request, _('Server deleted.'))
     return redirect('wireguard:index')
Ejemplo n.º 6
0
 def tearDown(cls):
     network.delete_connection(cls.ethernet_uuid)
     network.delete_connection(cls.wifi_uuid)
     network.delete_connection(cls.pppoe_uuid)