Ejemplo n.º 1
0
    def cb_show_delete_dialog(self, event):
        """
        Shows detail dialog for the specified site
        """
        command = event.source

        if not command.status == COMMAND_SUCCESS:
            raise command.exception

        conf_name = "%s.%s" % (command.name, command.domain)
        if not command.result:
            raise SiteError("Unknown site %s" % conf_name)

        if len(command.result) > 1:
            raise SiteError("Several sites named %s found" % conf_name)

        dnshost = command.result[0]

        dialog = gtk.MessageDialog(
            self.get_presentation_agent().get_toplevel(),
            #gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
            "Are you sure you want to delete configuraiton '%s' ?" % conf_name)

        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            command = DeleteSite(dnshost.name, dnshost.domain)
            command.register_command_observer(self)
            enqueue_command(command)
            print "deleted site id %s" % conf_name
Ejemplo n.º 2
0
    def delete_selected_sites(self, selection):
        """
        Display delete dialog for each selected site id
        """
        for name, domain in selection:
            conf_name = "%s.%s" % (name, domain)

            # TODO: create a dedicated pac agent
            dialog = gtk.MessageDialog(
                self.get_presentation_agent().get_toplevel(),
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
                "Are you sure you want to delete configuraiton '%s' ?" % conf_name)

            response = dialog.run()
            dialog.destroy()

            if response == gtk.RESPONSE_YES:
                command = DeleteSite(name, domain)
                command.get_event_bus().subscribe(CommandExecEvent,
                                                  self.cb_reload_sites)
                command.get_event_bus().subscribe(
                    CommandExecEvent,
                    self._logs_control_agent.command_evt_callback)
                enqueue_command(command)
                print "deleted site id %s" % conf_name
Ejemplo n.º 3
0
 def edit_selected_sites(self, selection):
     """
     Display detail dialog in edit mode for each selected site id
     """
     for name, domain in selection:
         command = GetSiteByName(name, domain)
         command.get_event_bus().subscribe(
             CommandExecEvent, self.cb_show_detail_dialog_rw)
         enqueue_command(command)
Ejemplo n.º 4
0
    def reload_sites(self):
        """
        Reloads site list by submitting a lookup query
        """
        sca = self._sites_control_agent
        filter_name = sca.get_value('filter_name')
        filter_domain = sca.get_value('filter_domain')

        command = LookupHostByName(filter_name, filter_domain)
        command.get_event_bus().subscribe(CommandExecEvent,
                                          self.cb_set_sites)
        enqueue_command(command)
Ejemplo n.º 5
0
    def submit_sites(self, sites):
        """
        Submits sites changes coming from detail component to backend
        """
        for site in sites:
            if ISiteNew.providedBy(site):
                command = AddSite(site)
            else:
                command = UpdateSite(site)

            command.get_event_bus().subscribe(
                CommandExecEvent, self.cb_reload_sites)

            command.get_event_bus().subscribe(
                CommandExecEvent,
                self._logs_control_agent.command_evt_callback)

            enqueue_command(command)