Skip to content
Snippets Groups Projects
Commit ebc009d2 authored by inso's avatar inso
Browse files

Add licence text everywhere (#388)

parent c67b2160
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ from sakia.decorators import asyncify ...@@ -7,6 +7,7 @@ from sakia.decorators import asyncify
from sakia.gui.sub.search_user.controller import SearchUserController from sakia.gui.sub.search_user.controller import SearchUserController
from sakia.gui.sub.user_information.controller import UserInformationController from sakia.gui.sub.user_information.controller import UserInformationController
from sakia.gui.sub.password_input import PasswordInputController from sakia.gui.sub.password_input import PasswordInputController
from sakia.gui.widgets import dialogs
from .model import CertificationModel from .model import CertificationModel
from .view import CertificationView from .view import CertificationView
import attr import attr
...@@ -103,11 +104,33 @@ class CertificationController(QObject): ...@@ -103,11 +104,33 @@ class CertificationController(QObject):
""" """
Validate the dialog Validate the dialog
""" """
if not self.user_information.model.identity.member:
result = await dialogs.QAsyncMessageBox.question(self.view, "Certifying a non-member",
"""
Did you ensure that :<br>
<br/>
1°) <b>You know the person declaring owning this pubkey
well enough and to personally verify that it is the correct key you are going to certify.</b><br/>
2°) To physically meet her to ensure that it is the person you know who owns this pubkey.<br/>
3°) Or did you ensure by contacting her using multiple communications means,
like forum + mail + videoconferencing + phone (to recognize voice)<br/>
Because if one can hack 1 mail account or 1 forum account, it will be way more difficult to hack multiple
communication means and imitate the voice of the person.<br/>
<br/>
The 2°) is however preferable to the 3°)... whereas <b>1°) is mandatory in any case.</b><br/>
<br/>
<b>Reminder</b> : Certifying is not only uniquely ensuring that you met the person, its ensuring the {0} community
that you know her well enough and that you will know how to find a double account done by a person certified by you
using cross checking which will help to reveal the problem if needs to be.</br>""")
if result == dialogs.QMessageBox.No:
return
self.view.button_box.setDisabled(True) self.view.button_box.setDisabled(True)
secret_key, password = self.password_input.get_salt_password() secret_key, password = self.password_input.get_salt_password()
QApplication.setOverrideCursor(Qt.WaitCursor) QApplication.setOverrideCursor(Qt.WaitCursor)
result = await self.model.certify_identity(secret_key, password, self.user_information.model.identity) result = await self.model.certify_identity(secret_key, password, self.user_information.model.identity)
#
if result[0]: if result[0]:
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
await self.view.show_success(self.model.notification()) await self.view.show_success(self.model.notification())
...@@ -129,6 +152,7 @@ class CertificationController(QObject): ...@@ -129,6 +152,7 @@ class CertificationController(QObject):
if self.model.could_certify(): if self.model.could_certify():
if written < stock or stock == 0: if written < stock or stock == 0:
if self.password_input.valid():
if not self.user_information.model.identity: if not self.user_information.model.identity:
self.view.set_button_box(CertificationView.ButtonBoxState.SELECT_IDENTITY) self.view.set_button_box(CertificationView.ButtonBoxState.SELECT_IDENTITY)
elif days+hours+minutes > 0: elif days+hours+minutes > 0:
...@@ -138,7 +162,7 @@ class CertificationController(QObject): ...@@ -138,7 +162,7 @@ class CertificationController(QObject):
remaining_localized = self.tr("{hours}h {min}min").format(hours=hours, min=minutes) remaining_localized = self.tr("{hours}h {min}min").format(hours=hours, min=minutes)
self.view.set_button_box(CertificationView.ButtonBoxState.REMAINING_TIME_BEFORE_VALIDATION, self.view.set_button_box(CertificationView.ButtonBoxState.REMAINING_TIME_BEFORE_VALIDATION,
remaining=remaining_localized) remaining=remaining_localized)
elif self.password_input.valid(): else:
self.view.set_button_box(CertificationView.ButtonBoxState.OK) self.view.set_button_box(CertificationView.ButtonBoxState.OK)
else: else:
self.view.set_button_box(CertificationView.ButtonBoxState.WRONG_PASSWORD) self.view.set_button_box(CertificationView.ButtonBoxState.WRONG_PASSWORD)
......
...@@ -10,7 +10,7 @@ from .view import InformationsView ...@@ -10,7 +10,7 @@ from .view import InformationsView
from sakia.decorators import asyncify from sakia.decorators import asyncify
from sakia.gui.sub.password_input import PasswordInputController from sakia.gui.sub.password_input import PasswordInputController
from sakia.gui.widgets import toast from sakia.gui.widgets import toast
from sakia.gui.widgets.dialogs import QAsyncMessageBox from sakia.gui.widgets.dialogs import QAsyncMessageBox, QMessageBox
class InformationsController(QObject): class InformationsController(QObject):
...@@ -107,6 +107,12 @@ class InformationsController(QObject): ...@@ -107,6 +107,12 @@ class InformationsController(QObject):
async def send_join_demand(self, checked=False): async def send_join_demand(self, checked=False):
if not self.model.connection: if not self.model.connection:
return return
if not self.model.get_identity_data()["membership_state"]:
result = await self.view.licence_dialog(self.model.connection.currency,
self.model.parameters())
if result == QMessageBox.No:
return
secret_key, password = await PasswordInputController.open_dialog(self, self.model.connection) secret_key, password = await PasswordInputController.open_dialog(self, self.model.connection)
if not password or not secret_key: if not password or not secret_key:
return return
......
from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QWidget, QMessageBox
from PyQt5.QtCore import QEvent, QLocale, pyqtSignal from PyQt5.QtCore import QEvent, QLocale, pyqtSignal
from .informations_uic import Ui_InformationsWidget from .informations_uic import Ui_InformationsWidget
from enum import Enum from enum import Enum
from sakia.helpers import timestamp_to_dhms from sakia.helpers import timestamp_to_dhms
from sakia.constants import ROOT_SERVERS
from sakia.gui.widgets.dialogs import dialog_async_exec
class InformationsView(QWidget, Ui_InformationsWidget): class InformationsView(QWidget, Ui_InformationsWidget):
...@@ -330,6 +332,83 @@ class InformationsView(QWidget, Ui_InformationsWidget): ...@@ -330,6 +332,83 @@ class InformationsView(QWidget, Ui_InformationsWidget):
) )
) )
async def licence_dialog(self, currency, params):
dt_dhms = timestamp_to_dhms(params.dt)
if dt_dhms[0] > 0:
dt_as_str = self.tr("{:} day(s) {:} hour(s)").format(*dt_dhms)
else:
dt_as_str = self.tr("{:} hour(s)").format(dt_dhms[1])
if dt_dhms[2] > 0 or dt_dhms[3] > 0:
dt_dhms += ", {:} minute(s) and {:} second(s)".format(*dt_dhms[1:])
dt_reeval_dhms = timestamp_to_dhms(params.dt_reeval)
dt_reeval_as_str = self.tr("{:} day(s) {:} hour(s)").format(*dt_reeval_dhms)
message_box = QMessageBox(self)
message_box.setText("Do you recognize the terms of the following licence :")
message_box.setInformativeText("""
{:} is being produced by a Universal Dividend (UD) for any human member, which is :<br/>
<br/>
<table cellpadding="5">
<tr><td align="right"><b>{:2.0%} / {:} days</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:} {:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
</table>
<br/>
<br/>
The parameters of the Web of Trust of {:} are :<br/>
<table cellpadding="5">
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></td><td>{:}</td></tr>
</table>
<br/>
<br/>
<b>By asking to join as member, you recognize that this is your unique account,
and that you will only certify persons that you know well enough.</b>
""".format(
ROOT_SERVERS[currency]["display"],
params.c,
QLocale().toString(params.dt / 86400, 'f', 2),
self.tr('Fundamental growth (c)'),
params.ud0,
self.tr('Initial Universal Dividend UD(0) in'),
ROOT_SERVERS[currency]["display"],
dt_as_str,
self.tr('Time period between two UD'),
dt_reeval_as_str,
self.tr('Time period between two UD reevaluation'),
ROOT_SERVERS[currency]["display"],
QLocale().toString(params.sig_period / 86400, 'f', 2),
self.tr('Minimum delay between 2 certifications (in days)'),
QLocale().toString(params.sig_validity / 86400, 'f', 2),
self.tr('Maximum age of a valid signature (in days)'),
params.sig_qty,
self.tr('Minimum quantity of signatures to be part of the WoT'),
params.sig_stock,
self.tr('Maximum quantity of active certifications made by member.'),
params.sig_window,
self.tr('Maximum delay a certification can wait before being expired for non-writing.'),
params.xpercent,
self.tr('Minimum percent of sentries to reach to match the distance rule'),
params.ms_validity / 86400,
self.tr('Maximum age of a valid membership (in days)'),
params.step_max,
self.tr('Maximum distance between each WoT member and a newcomer'),
)
)
message_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No )
message_box.setDefaultButton(QMessageBox.No)
return await dialog_async_exec(message_box)
def changeEvent(self, event): def changeEvent(self, event):
""" """
Intercepte LanguageChange event to translate UI Intercepte LanguageChange event to translate UI
......
...@@ -33,8 +33,40 @@ QGroupBox::title { ...@@ -33,8 +33,40 @@ QGroupBox::title {
<property name="title"> <property name="title">
<string>User</string> <string>User</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item row="0" column="1"> <item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>362</width>
<height>212</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="5" column="0">
<widget class="QLabel" name="label_path">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_properties">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_icon"> <widget class="QLabel" name="label_icon">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
...@@ -52,24 +84,14 @@ QGroupBox::title { ...@@ -52,24 +84,14 @@ QGroupBox::title {
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="../../../../res/icons/icons.qrc">:/icons/member_icon</pixmap> <pixmap resource="../../../../../res/icons/icons.qrc">:/icons/member_icon</pixmap>
</property> </property>
<property name="scaledContents"> <property name="scaledContents">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" colspan="2"> <item row="1" column="1">
<widget class="QLabel" name="label_properties">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_uid"> <widget class="QLabel" name="label_uid">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
...@@ -82,11 +104,8 @@ QGroupBox::title { ...@@ -82,11 +104,8 @@ QGroupBox::title {
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="2"> </layout>
<widget class="QLabel" name="label_path"> </widget>
<property name="text">
<string/>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
...@@ -95,8 +114,9 @@ QGroupBox::title { ...@@ -95,8 +114,9 @@ QGroupBox::title {
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../../../../res/icons/icons.qrc"/> <include location="../../../../../res/icons/icons.qrc"/>
<include location="../../../../res/icons/icons.qrc"/> <include location="../../../../../res/icons/icons.qrc"/>
<include location="../../../../../res/icons/icons.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment