Beispiel #1
0
    def test_delete_authtoken(self):
        """Test delete authtoken."""
        save_authtoken(self.authtoken)
        self.assertEqual(self.authtoken, get_authtoken())

        delete_authtoken()
        self.assertIsNone(get_authtoken())
Beispiel #2
0
    def set_widgets(self):
        """Set all widgets."""
        self.text_test_connection_button = self.test_connection_button.text()
        self.ok_label.setVisible(False)
        self.save_button.setEnabled(False)

        self.test_connection_button.clicked.connect(self.login)
        self.save_button.clicked.connect(self.save_authtoken)
        self.clear_button.setText(tr('Clear'))

        self.clear_button.setEnabled(True)
        self.clear_button.clicked.connect(self.clear_information)
        self.url_input.setText(get_url_instance())

        # If login information exists
        if not self.auth_token:
            self.auth_token = get_authtoken()

        if self.auth_token:
            self.test_connection_button.setEnabled(False)
            self.username_input.setText(get_setting('username'))
            self.username_input.setReadOnly(True)
            self.password_input.setReadOnly(True)
            self.username_input.setStyleSheet(
                "QLineEdit { background-color: '#d9d9d9'; color: '#5b5b5b'; "
                "selection-background-color: '#969292'; }")
            self.password_input.setStyleSheet(
                "QLineEdit { background-color: '#d9d9d9'; color: '#5b5b5b'; "
                "selection-background-color: '#969292'; }")
            self.token_status.setText(tr('Auth token is saved.'))
        else:
            self.token_status.setText(tr('Auth token is empty.'))
    def __init__(self, request_url, geojson=False):
        self.request_url = request_url
        self.manager = QgsNetworkAccessManager.instance()
        self.reply = None
        self.url = QUrl(self.request_url)
        self.req = QNetworkRequest(self.url)
        self.results = QByteArray()
        self.auth_token = get_authtoken()

        # Paginated data
        self._pagination_exhausted = False
        self.geojson = geojson
        if geojson:
            self.combine_new_data = self.combine_new_geojson_data
Beispiel #4
0
    def initGui(self):
        """Create the menu entries and toolbar icons inside the QGIS GUI."""
        self._create_options_dialog()
        self._create_project_download_wizard()
        self._create_project_creation_wizard()
        self._create_project_update_wizard()
        self._create_help_dialog()
        self._create_about_dialog()
        for action in self.actions:
            self.iface.addPluginToVectorMenu(
                self.tr(u'&Cadasta'),
                action)

        self.project_update_wizard.setEnabled(False)
        if get_authtoken():
            self._enable_authenticated_menu()
        else:
            self._disable_authenticated_menu()
Beispiel #5
0
 def test_save_authtoken(self):
     """Test save authtoken."""
     save_authtoken(self.authtoken)
     self.assertEqual(self.authtoken, get_authtoken())