Exemplo n.º 1
0
def delete_profile(builder):
    """called when the user presses the - button"""
    logger.info("delete provider clicked")
    meta = metadata_of_selected(builder)

    if not meta:
        logger.info("nothing selected")
        return

    window = builder.get_object('eduvpn-window')

    dialog = Gtk.MessageDialog(
        window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION,
        Gtk.ButtonsType.YES_NO,
        "Are you sure you want to remove '{}'?".format(meta.display_name))
    dialog.format_secondary_text("This action can't be undone.")
    response = dialog.run()
    if response == Gtk.ResponseType.YES:
        logger.info("deleting provider config")
        try:
            delete_provider(meta.uuid)
            notify("eduVPN provider deleted",
                   "Deleted '{}'".format(meta.display_name))
        except Exception as e:
            error_helper(window, "can't delete profile", str(e))
            dialog.destroy()
            raise
        GLib.idle_add(lambda: update_providers(builder))
    elif response == Gtk.ResponseType.NO:
        logger.info("not deleting provider config")
    dialog.destroy()
Exemplo n.º 2
0
def delete_profile(builder, lets_connect):  # type: (Gtk.builder, bool) -> None
    """called when the user presses the - button"""
    logger.info("delete provider clicked")
    meta = metadata_of_selected(builder)

    if not meta:
        logger.info("nothing selected")
        return

    window = builder.get_object('eduvpn-window')

    dialog = Gtk.MessageDialog(
        window, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING,
        Gtk.ButtonsType.YES_NO,
        "Are you sure you want to remove '{}'?".format(meta.display_name))
    dialog.format_secondary_text("This action can't be undone.")
    response = dialog.run()
    if response == Gtk.ResponseType.YES:
        logger.info("deleting provider config")
        try:
            delete_provider(meta.uuid)
            notification = init_notify(lets_connect)
            notify(notification, "eduVPN provider deleted",
                   "Deleted '{}'".format(meta.display_name))
        except Exception as e:
            error_helper(window, "can't delete profile", str(e))
            dialog.hide()
            raise
        GLib.idle_add(
            lambda: refresh_start(builder, lets_connect=lets_connect))
    elif response == Gtk.ResponseType.NO:
        logger.info("not deleting provider config")
    dialog.hide()
Exemplo n.º 3
0
def reauth(meta, verifier, builder):
    """called when the authorization is expired"""
    logger.info("looks like authorization is expired or removed")
    window = builder.get_object('eduvpn-window')
    dialog = Gtk.MessageDialog(window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION,
                               Gtk.ButtonsType.YES_NO,
                               "Authorization for {}is expired or removed.".format(meta.display_name))
    dialog.format_secondary_text("Do you want to re-authorize?")
    response = dialog.run()
    if response == Gtk.ResponseType.YES:
        browser_step(builder, meta, verifier)
        delete_provider(meta.uuid)
    elif response == Gtk.ResponseType.NO:
        pass
    dialog.destroy()
 def test_store_provider(self):
     self.meta.uuid = None
     uuid = store_provider(meta=self.meta, config_dict=mock_config_dict)
     update_config_provider(self.meta, config_dict=mock_config_dict)
     delete_provider(uuid)
Exemplo n.º 5
0
 def test_store_provider(self):
     uuid = store_provider(meta=self.meta)
     update_config_provider(self.meta)
     delete_provider(uuid)