diff --git a/src/sakia/data/graphs/base_graph.py b/src/sakia/data/graphs/base_graph.py index 81b7a93a8fc978361462659831f7f82281c27dc6..05d64ac49946e4ef92dfe04456cc54df3a7a70b0 100644 --- a/src/sakia/data/graphs/base_graph.py +++ b/src/sakia/data/graphs/base_graph.py @@ -1,12 +1,21 @@ import logging import time import networkx -from PyQt5.QtCore import QLocale, QDateTime, QObject +from PyQt5.QtCore import QLocale, QDateTime, QObject, QT_TRANSLATE_NOOP from sakia.errors import NoPeerAvailable from .constants import EdgeStatus, NodeStatus from sakia.constants import MAX_CONFIRMATIONS +def sentry_display(identity): + sentry_text = "" + sentry_symbol = "" + if identity.sentry: + sentry_symbol = "✴ " + sentry_text = QT_TRANSLATE_NOOP("BaseGraph", "(sentry)") + " " + return sentry_symbol, sentry_text + + class BaseGraph(QObject): def __init__(self, app, blockchain_service, identities_service, nx_graph): """ @@ -92,29 +101,12 @@ class BaseGraph(QObject): return "{0} %".format(QLocale().toString(float(confirmation), 'f', 0)) return None - def is_sentry(self, nb_certs, nb_members): - """ - Check if it is a sentry or not - :param int nb_certs: the number of certs - :param int nb_members: the number of members - :return: True if a sentry - """ - Y = { - 10: 2, - 100: 4, - 1000: 6, - 10000: 12, - 100000: 20 - } - for k in reversed(sorted(Y.keys())): - if nb_members >= k: - return nb_certs >= Y[k] - return False - def add_certifier_node(self, certifier, identity, certification, node_status): + sentry_symbol, sentry_text = sentry_display(certifier) + name_text = certifier.uid if certifier.uid else certifier.pubkey[:12] metadata = { - 'text': certifier.uid if certifier.uid else certifier.pubkey[:12], - 'tooltip': certifier.pubkey, + 'text': sentry_symbol + name_text, + 'tooltip': sentry_text + certifier.pubkey, 'identity': certifier, 'status': node_status } @@ -135,9 +127,11 @@ class BaseGraph(QObject): self.nx_graph.add_edge(certifier.pubkey, identity.pubkey, attr_dict=arc) def add_certified_node(self, identity, certified, certification, node_status): + sentry_symbol, sentry_text = sentry_display(certified) + name_text = certified.uid if certified.uid else certified.pubkey[:12] metadata = { - 'text': certified.uid if certified.uid else certified.pubkey[:12], - 'tooltip': certified.pubkey, + 'text': sentry_symbol + name_text, + 'tooltip': sentry_text + certified.pubkey, 'identity': certified, 'status': node_status } @@ -237,9 +231,11 @@ class BaseGraph(QObject): :param list edges: Optional, default=None, List of edges (certified by identity) :param list connected: Optional, default=None, Public key list of the connected nodes around the identity """ + sentry_symbol, sentry_text = sentry_display(identity) + name_text = identity.uid metadata = { - 'text': identity.uid, - 'tooltip': identity.pubkey, + 'text': sentry_symbol + name_text, + 'tooltip': sentry_text + identity.pubkey, 'status': status, 'identity': identity } diff --git a/src/sakia/gui/dialogs/connection_cfg/congratulation.ui b/src/sakia/gui/dialogs/connection_cfg/congratulation.ui new file mode 100644 index 0000000000000000000000000000000000000000..fb71eb2c33c8f039df923c08c5908e313158d1d8 --- /dev/null +++ b/src/sakia/gui/dialogs/connection_cfg/congratulation.ui @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CongratulationPopup</class> + <widget class="QDialog" name="CongratulationPopup"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>350</width> + <height>198</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>350</width> + <height>16777215</height> + </size> + </property> + <property name="windowTitle"> + <string>Congratulation</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>label</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignJustify|Qt::AlignTop</set> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + <property name="textInteractionFlags"> + <set>Qt::TextBrowserInteraction</set> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Ok</set> + </property> + <property name="centerButtons"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>CongratulationPopup</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/sakia/gui/dialogs/connection_cfg/view.py b/src/sakia/gui/dialogs/connection_cfg/view.py index a158d1322e9bd33bb378e4d43ad7d6a9e2ae0d75..60bfa346a196f112a3cef831be16ffe96dde9a2d 100644 --- a/src/sakia/gui/dialogs/connection_cfg/view.py +++ b/src/sakia/gui/dialogs/connection_cfg/view.py @@ -1,11 +1,12 @@ from PyQt5.QtWidgets import QDialog from PyQt5.QtCore import pyqtSignal, Qt from .connection_cfg_uic import Ui_ConnectionConfigurationDialog +from .congratulation_uic import Ui_CongratulationPopup from duniterpy.key import SigningKey, ScryptParams 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.gui.widgets.dialogs import dialog_async_exec, QAsyncMessageBox from sakia.constants import ROOT_SERVERS @@ -153,13 +154,23 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): hours=hours, min=minutes) - await QAsyncMessageBox.information(self, self.tr("Registration"), self.tr(""" -<b>Congratulations !</b><br> + dialog = QDialog(self) + about_dialog = Ui_CongratulationPopup() + about_dialog.setupUi(dialog) + dialog.setWindowTitle("Registration") + about_dialog.label.setText(self.tr(""" +<p><b>Congratulations !</b><br> <br> You just published your identity to the network.<br> -For your identity to be registered, you will need <b>{certs} certifications</b> from members.<br> -Once you got the required certifications, you will be able to validate your registration +For your identity to be registered, you will need<br> +<b>{certs} certifications</b> from members.<br> +Once you got the required certifications, <br> +you will be able to validate your registration<br> by <b>publishing your membership request !</b><br> -Please notice that your identity document <b>will expire in {expiration_time_str}.</b> If you failed -to get {certs} certifications before this time, the process will have to be restarted from scratch. +Please notice that your identity document <br> +<b>will expire in {expiration_time_str}.</b><br> +If you failed to get {certs} certifications before this time, <br> +the process will have to be restarted from scratch.</p> """.format(certs=blockchain_parameters.sig_qty, expiration_time_str=expiration_time_str))) + + await dialog_async_exec(dialog) diff --git a/src/sakia/gui/navigation/identities/table_model.py b/src/sakia/gui/navigation/identities/table_model.py index 0b6651f814132bac1668f12e9a01a7b838702d47..37cbae948976738205de3bc2ee3d534767a86584 100644 --- a/src/sakia/gui/navigation/identities/table_model.py +++ b/src/sakia/gui/navigation/identities/table_model.py @@ -150,8 +150,10 @@ class IdentitiesTableModel(QAbstractTableModel): expiration_date = self.identities_service.expiration_date(identity) sigdate_ts = identity.timestamp sigdate_block = identity.blockstamp + name = "✴ " if identity.sentry else "" + name += identity.uid - return identity.uid, identity.pubkey, join_date, expiration_date, sigdate_ts, sigdate_block, identity + return name, identity.pubkey, join_date, expiration_date, sigdate_ts, sigdate_block, identity def refresh_identities(self, identities): """ diff --git a/tests/helpers.py b/tests/helpers.py index f4d7108029f58264aa61143c22687520dabc612b..74b83d37e6d0a9598bb2625bf58bc0b5690fdb7a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QApplication, QMessageBox +from PyQt5.QtWidgets import QApplication, QMessageBox, QDialog from PyQt5.QtCore import Qt from PyQt5.QtTest import QTest @@ -6,5 +6,7 @@ from PyQt5.QtTest import QTest def click_on_top_message_box(): topWidgets = QApplication.topLevelWidgets() for w in topWidgets: - if type(w) is QMessageBox: + if isinstance(w, QMessageBox): + QTest.keyClick(w, Qt.Key_Enter) + elif isinstance(w, QDialog) and w.windowTitle() == "Registration": QTest.keyClick(w, Qt.Key_Enter)