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

Multiple issues fixed

- Fixed issue #55
- Fixed display of units in transactions tab
- Fixed an error when an account was not a member of a community
parent fb3fb282
No related branches found
No related tags found
No related merge requests found
......@@ -79,19 +79,23 @@ class Person(object):
raise PersonNotFoundError(self.pubkey, community.name())
def membership(self, community):
search = community.request(bma.blockchain.Membership,
{'search': self.pubkey})
block_number = 0
for ms in search['memberships']:
if ms['blockNumber'] >= block_number:
if 'type' in ms:
if ms['type'] is 'IN':
try:
search = community.request(bma.blockchain.Membership,
{'search': self.pubkey})
block_number = 0
for ms in search['memberships']:
if ms['blockNumber'] >= block_number:
if 'type' in ms:
if ms['type'] is 'IN':
membership_data = ms
else:
membership_data = ms
else:
membership_data = ms
if membership_data is None:
raise MembershipNotFoundError(self.pubkey(), community.name())
if membership_data is None:
raise MembershipNotFoundError(self.pubkey, community.name())
except ValueError as e:
if '400' in str(e):
raise MembershipNotFoundError(self.pubkey, community.name())
membership = Membership(PROTOCOL_VERSION, community.currency, self.pubkey,
membership_data['blockNumber'],
......
......@@ -3,7 +3,7 @@ Created on 24 dec. 2014
@author: inso
'''
from PyQt5.QtWidgets import QDialog, QMessageBox
from PyQt5.QtWidgets import QDialog, QMessageBox, QDialogButtonBox
from ..tools.exceptions import NoPeerAvailable
from ..gen_resources.certification_uic import Ui_CertificationDialog
......@@ -20,11 +20,11 @@ class CertificationDialog(QDialog, Ui_CertificationDialog):
'''
super().__init__()
self.setupUi(self)
self.certifier = certifier
self.account = certifier
self.password_asker = password_asker
self.community = self.certifier.communities[0]
self.community = self.account.communities[0]
for community in self.certifier.communities:
for community in self.account.communities:
self.combo_community.addItem(community.currency)
for contact in certifier.contacts:
......@@ -33,7 +33,7 @@ class CertificationDialog(QDialog, Ui_CertificationDialog):
def accept(self):
if self.radio_contact.isChecked():
index = self.combo_contact.currentIndex()
pubkey = self.certifier.contacts[index].pubkey
pubkey = self.account.contacts[index].pubkey
else:
pubkey = self.edit_pubkey.text()
......@@ -42,7 +42,7 @@ class CertificationDialog(QDialog, Ui_CertificationDialog):
return
try:
self.certifier.certify(password, self.community, pubkey)
self.account.certify(password, self.community, pubkey)
QMessageBox.information(self, "Certification",
"Success certifying {0} from {1}".format(pubkey,
self.community.currency))
......@@ -65,7 +65,11 @@ class CertificationDialog(QDialog, Ui_CertificationDialog):
super().accept()
def change_current_community(self, index):
self.community = self.certifier.communities[index]
self.community = self.account.communities[index]
if self.account.pubkey in self.community.members_pubkeys():
self.button_box.button(QDialogButtonBox.Ok).setEnabled(True)
else:
self.button_box.button(QDialogButtonBox.Ok).setEnabled(False)
def recipient_mode_changed(self, pubkey_toggled):
self.edit_pubkey.setEnabled(pubkey_toggled)
......
......@@ -21,7 +21,7 @@ from ..models.txhistory import HistoryTableModel, TxFilterProxyModel
from .informations_tab import InformationsTabWidget
from ..models.wallets import WalletsListModel
from ..models.wallet import WalletListModel
from ..tools.exceptions import NoPeerAvailable
from ..tools.exceptions import NoPeerAvailable, MembershipNotFoundError
from ..core.wallet import Wallet
from ..core.person import Person
from ..core.transfer import Transfer
......@@ -93,23 +93,26 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self.watcher_thread.start()
person = Person.lookup(self.app.current_account.pubkey, self.community)
join_block = person.membership(self.community).block_number
join_date = self.community.get_block(join_block).mediantime
parameters = self.community.get_parameters()
expiration_date = join_date + parameters['sigValidity']
current_time = time.time()
sig_validity = self.community.get_parameters()['sigValidity']
warning_expiration_time = int(sig_validity / 3)
will_expire_soon = (current_time > expiration_date - warning_expiration_time)
if will_expire_soon:
days = QDateTime().currentDateTime().daysTo(QDateTime.fromTime_t(expiration_date))
QMessageBox.warning(
self,
"Membership expiration",
"Warning : Membership expiration in {0} days".format(days),
QMessageBox.Ok
)
try:
join_block = person.membership(self.community).block_number
join_date = self.community.get_block(join_block).mediantime
parameters = self.community.get_parameters()
expiration_date = join_date + parameters['sigValidity']
current_time = time.time()
sig_validity = self.community.get_parameters()['sigValidity']
warning_expiration_time = int(sig_validity / 3)
will_expire_soon = (current_time > expiration_date - warning_expiration_time)
if will_expire_soon:
days = QDateTime().currentDateTime().daysTo(QDateTime.fromTime_t(expiration_date))
QMessageBox.warning(
self,
"Membership expiration",
"Warning : Membership expiration in {0} days".format(days),
QMessageBox.Ok
)
except MembershipNotFoundError as e:
pass
def refresh(self):
if self.app.current_account is None:
......
......@@ -79,14 +79,13 @@ class TxFilterProxyModel(QSortFilterProxyModel):
if source_data is not "":
amount_ref = self.account.units_to_diff_ref(source_data,
self.community)
ref_name = self.account.diff_ref_name(self.community.short_currency)
if type(amount_ref) is int:
formatter = "{0} {1}"
formatter = "{0}"
else:
formatter = "{0:.2f} {1}"
formatter = "{0:.2f}"
return formatter.format(amount_ref, ref_name)
return formatter.format(amount_ref)
if role == Qt.FontRole:
font = QFont()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment