diff --git a/src/sakia/data/processors/nodes.py b/src/sakia/data/processors/nodes.py index 70c4066a271facd565b3af75bf8a64820f53a6d4..75233351a3c73459d9261454944e1084388cf95b 100644 --- a/src/sakia/data/processors/nodes.py +++ b/src/sakia/data/processors/nodes.py @@ -16,10 +16,10 @@ class NodesProcessor: def initialize_root_nodes(self, currency): if not self.nodes(currency): - for pubkey in ROOT_SERVERS[currency]: + for pubkey in ROOT_SERVERS[currency]["nodes"]: node = Node(currency=currency, pubkey=pubkey, - endpoints=ROOT_SERVERS[currency][pubkey], + endpoints=ROOT_SERVERS[currency]["nodes"][pubkey], peer_blockstamp=BlockUID.empty(), state=Node.ONLINE) self._repo.insert(node) diff --git a/src/sakia/gui/dialogs/connection_cfg/view.py b/src/sakia/gui/dialogs/connection_cfg/view.py index ea3a26940960550663de7788f0a0bb176c1f38c7..a75d56cd79801231b6e07a16b6a8a9df6147eae8 100644 --- a/src/sakia/gui/dialogs/connection_cfg/view.py +++ b/src/sakia/gui/dialogs/connection_cfg/view.py @@ -6,6 +6,7 @@ from math import ceil, log from sakia.gui.widgets import toast from sakia.helpers import timestamp_to_dhms from sakia.gui.widgets.dialogs import QAsyncMessageBox +from sakia.constants import ROOT_SERVERS class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): @@ -109,7 +110,7 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): """ Hide unecessary buttons and display correct title """ - self.setWindowTitle(self.tr("New connection to {0} network").format(currency)) + self.setWindowTitle(self.tr("New connection to {0} network").format(ROOT_SERVERS[currency]["display"])) def action_show_pubkey(self): salt = self.edit_salt.text() diff --git a/src/sakia/gui/dialogs/transfer/model.py b/src/sakia/gui/dialogs/transfer/model.py index c9856536725a26adacac4ca48e250724a0434b4d..517846f50aaa52cfbfa324c88987137ab6edd01e 100644 --- a/src/sakia/gui/dialogs/transfer/model.py +++ b/src/sakia/gui/dialogs/transfer/model.py @@ -71,7 +71,7 @@ class TransferModel(QObject): """ Get the value of the current referential """ - localized = self.app.current_ref.instance(amount, self.connection.currency, self.app).diff_localized(True, True) + localized = self.app.current_ref.instance(amount, self.connection.currency, self.app).diff_localized(False, True) return localized def cancel_previous(self): diff --git a/src/sakia/gui/main_window/controller.py b/src/sakia/gui/main_window/controller.py index fd3b3f0214ccdfa59553095279336d99c7c82d30..2681c3f83c7cdd0060f93534589ff19a06c4b41c 100644 --- a/src/sakia/gui/main_window/controller.py +++ b/src/sakia/gui/main_window/controller.py @@ -4,7 +4,7 @@ from PyQt5.QtCore import QEvent, pyqtSlot, QObject from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QMessageBox, QApplication -from sakia.gui.sub.password_input import PasswordInputController +from sakia.constants import ROOT_SERVERS from .model import MainWindowModel from .status_bar.controller import StatusBarController from .toolbar.controller import ToolbarController @@ -76,12 +76,6 @@ class MainWindowController(QObject): navigation=navigation, toolbar=toolbar ) - currencies = app.db.connections_repo.get_currencies() - if currencies: - currency = currencies[0] - else: - currency = "" - #app.version_requested.connect(main_window.latest_version_requested) #app.account_imported.connect(main_window.import_account_accepted) #app.account_changed.connect(main_window.change_account) @@ -89,7 +83,7 @@ class MainWindowController(QObject): main_window.view.showMaximized() else: main_window.view.show() - main_window.refresh(currency) + main_window.refresh(app.currency) return main_window @pyqtSlot(str) @@ -124,7 +118,8 @@ class MainWindowController(QObject): """ self.status_bar.refresh() self.toolbar.enable_actions(len(self.navigation.model.navigation[0]['children']) > 0) - self.view.setWindowTitle(self.tr("sakia {0} - {currency}").format(__version__, currency=currency)) + display_name = ROOT_SERVERS[currency]["display"] + self.view.setWindowTitle(self.tr("sakia {0} - {1}").format(__version__, display_name)) def eventFilter(self, target, event): """ diff --git a/src/sakia/gui/navigation/informations/controller.py b/src/sakia/gui/navigation/informations/controller.py index ffbc1b0e0318f0937af8f2855c9007a9cf9691be..a65bb4347ffb52df832508276714cb7872914bcd 100644 --- a/src/sakia/gui/navigation/informations/controller.py +++ b/src/sakia/gui/navigation/informations/controller.py @@ -2,9 +2,8 @@ import logging from PyQt5.QtCore import QObject from sakia.errors import NoPeerAvailable - +from sakia.constants import ROOT_SERVERS from duniterpy.api import errors -from sakia.decorators import asyncify from .model import InformationsModel from .view import InformationsView @@ -75,7 +74,7 @@ class InformationsController(QObject): self.view.set_text_referentials(referentials) params = self.model.parameters() if params: - self.view.set_money_text(params, self.model.short_currency()) + self.view.set_money_text(params, ROOT_SERVERS[self.model.connection.currency]["display"]) self.view.set_wot_text(params) self.refresh_localized_data() diff --git a/src/sakia/gui/navigation/informations/model.py b/src/sakia/gui/navigation/informations/model.py index 8eca0642e5e22080d359eef78f604ddf1b0c96ed..a8f2993e18a617ee2927c5669d10f1925c3d0548 100644 --- a/src/sakia/gui/navigation/informations/model.py +++ b/src/sakia/gui/navigation/informations/model.py @@ -3,8 +3,7 @@ import math from PyQt5.QtCore import QLocale, QDateTime, pyqtSignal, QObject from sakia.errors import NoPeerAvailable -from sakia.helpers import timestamp_to_dhms -from sakia.money.currency import shortened +from sakia.constants import ROOT_SERVERS from sakia.money import Referentials from duniterpy.api import errors @@ -43,6 +42,7 @@ class InformationsModel(QObject): logging.debug('community parameters error : ' + str(e)) return None + localized_data['currency'] = ROOT_SERVERS[self.connection.currency]["display"] localized_data['growth'] = params.c localized_data['days_per_dividend'] = QLocale().toString(params.dt / 86400, 'f', 2) @@ -165,13 +165,6 @@ class InformationsModel(QObject): refs_instances.append(ref_class(0, self.connection.currency, self.app, None)) return refs_instances - def short_currency(self): - """ - Get community currency - :return: the community in short currency format - """ - return shortened(self.connection.currency) - def notifications(self): return self.app.parameters.notifications diff --git a/src/sakia/gui/navigation/informations/view.py b/src/sakia/gui/navigation/informations/view.py index 549a6767ca2429cc086913bf551212f0e71ff2ba..07ee0ff78daddf276e6970dfa2f34f09f927c83e 100644 --- a/src/sakia/gui/navigation/informations/view.py +++ b/src/sakia/gui/navigation/informations/view.py @@ -81,7 +81,7 @@ class InformationsView(QWidget, Ui_InformationsWidget): <p><span style="font-weight:600;">{monetary_mass_label}</span> : {monetary_mass}</p> <p><span style="font-weight:600;">{balance_label}</span> : {balance}</p> </body> -</html>""".format(currency=data['units'], +</html>""".format(currency=data['currency'], nb_members=data['members_count'], members_label=self.tr("members"), monetary_mass_label=self.tr("Monetary mass"), diff --git a/src/sakia/money/quant_zerosum.py b/src/sakia/money/quant_zerosum.py index b5ec19f6a914988f5339a9ba934e4d1bff720029..23e781b88eb6a4f322b2e3bf8ffd63c92fff3ef3 100644 --- a/src/sakia/money/quant_zerosum.py +++ b/src/sakia/money/quant_zerosum.py @@ -38,7 +38,7 @@ class QuantitativeZSum(BaseReferential): @property def units(self): - return QCoreApplication.translate("QuantitativeZSum", QuantitativeZSum._UNITS_STR_).format(shortened(self.currency)) + return QCoreApplication.translate("QuantitativeZSum", QuantitativeZSum._UNITS_STR_).format("units") @property def formula(self): @@ -50,7 +50,7 @@ class QuantitativeZSum(BaseReferential): @property def diff_units(self): - return QCoreApplication.translate("Quantitative", Quantitative._UNITS_STR_).format(shortened(self.currency)) + return QCoreApplication.translate("Quantitative", Quantitative._UNITS_STR_).format("units") def value(self): """ diff --git a/src/sakia/money/quantitative.py b/src/sakia/money/quantitative.py index eb2e122d36fc9bcc0d567e3f5cbaf1d92966186a..b20793dcd1f1ca6ac316a7bdf2c4684e23f5b23e 100644 --- a/src/sakia/money/quantitative.py +++ b/src/sakia/money/quantitative.py @@ -28,7 +28,7 @@ class Quantitative(BaseReferential): @property def units(self): - return QCoreApplication.translate("Quantitative", Quantitative._UNITS_STR_).format(shortened(self.currency)) + return QCoreApplication.translate("Quantitative", Quantitative._UNITS_STR_).format("units") @property def formula(self): diff --git a/src/sakia/money/relative.py b/src/sakia/money/relative.py index f8afe4f35adf55bbffa76fec3d39a724395e1727..2443a5bf7eb88433b2f9e81a27cfafa3b534b46f 100644 --- a/src/sakia/money/relative.py +++ b/src/sakia/money/relative.py @@ -50,7 +50,7 @@ class Relative(BaseReferential): @property def units(self): - return QCoreApplication.translate("Relative", Relative._UNITS_STR_).format(shortened(self.currency)) + return QCoreApplication.translate("Relative", Relative._UNITS_STR_).format("") @property def formula(self): diff --git a/src/sakia/money/relative_zerosum.py b/src/sakia/money/relative_zerosum.py index d320c8c3ee3a388b2fef9ac024629793022afd2a..67fb55df30622c93328640a505624497450bdf53 100644 --- a/src/sakia/money/relative_zerosum.py +++ b/src/sakia/money/relative_zerosum.py @@ -37,7 +37,7 @@ class RelativeZSum(BaseReferential): @property def units(self): - return QCoreApplication.translate("RelativeZSum", RelativeZSum._UNITS_STR_).format(shortened(self.currency)) + return QCoreApplication.translate("RelativeZSum", RelativeZSum._UNITS_STR_).format("") @property def formula(self): @@ -49,7 +49,7 @@ class RelativeZSum(BaseReferential): @property def diff_units(self): - return QCoreApplication.translate("Relative", Relative._UNITS_STR_).format(shortened(self.currency)) + return QCoreApplication.translate("Relative", Relative._UNITS_STR_).format(shortened("")) @staticmethod def base_str(base): diff --git a/src/sakia/root_servers.yml b/src/sakia/root_servers.yml index 39b0defea76569f450dc6116f96a2565f368da72..018c9dca86c76785c22ed7506021950508277be6 100644 --- a/src/sakia/root_servers.yml +++ b/src/sakia/root_servers.yml @@ -1,8 +1,17 @@ fakenet: - HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk: - - "BASIC_MERKLED_API fakenet.cgeek.fr 10900" + display: fakenet + nodes: + HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk: + - "BASIC_MERKLED_API fakenet.cgeek.fr 10900" gtest: + display: ğtest + nodes: C4orqutdb3Nveur3xN5L2TduT1j8d2EZkJsWLmWuD2Sv: - "BASIC_MERKLED_API gtest.duniter.org 10900" - "BASIC_MERKLED_API cgeek.fr 10900" - "BASIC_MERKLED_API gtest.duniter.fr 10900" +g1: + display: ğ1 + nodes: + 858SvdsS7Aog3U8QRg2TaygEFN8M8Hru48P17KosDFbg: + - "BASIC_MERKLED_API g1.duniter.org 80"