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

Commit before merging

parent ef583b01
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ from ucoinpy.api import bma ...@@ -9,6 +9,7 @@ from ucoinpy.api import bma
from ucoinpy.api.bma import ConnectionHandler from ucoinpy.api.bma import ConnectionHandler
from ucoinpy.documents.peer import Peer from ucoinpy.documents.peer import Peer
from ucoinpy.documents.certification import SelfCertification, Certification from ucoinpy.documents.certification import SelfCertification, Certification
from ucoinpy.documents.membership import Membership
from ucoinpy.key import SigningKey from ucoinpy.key import SigningKey
from ..tools.exceptions import PersonNotFoundError from ..tools.exceptions import PersonNotFoundError
...@@ -177,11 +178,21 @@ class Account(object): ...@@ -177,11 +178,21 @@ class Account(object):
'self_': selfcert.signed_raw(), 'self_': selfcert.signed_raw(),
'other': []}) 'other': []})
def send_membership_in(self, community): def send_membership(self, password, community, type):
return community.send_membership(self, "IN") self_ = Person.lookup(self.pubkey, community)
selfcert = self_.selfcert(community)
def send_membership_out(self, community): block = community.get_block()
return community.send_membership(self, "OUT") block_hash = hashlib.sha1(block.signed_raw().encode("ascii")).hexdigest().upper()
membership = Membership(PROTOCOL_VERSION, community.currency,
selfcert.pubkey, block.number,
block_hash, type, selfcert.uid,
selfcert.timestamp, None)
key = SigningKey(self.salt, password)
membership.sign(key)
logging.debug("Membership : {0}".format(membership.signed_raw()))
community.post(bma.blockchain.Membership, {},
{'membership': membership.signed_raw()})
def jsonify_contacts(self): def jsonify_contacts(self):
data = [] data = []
......
...@@ -5,8 +5,8 @@ Created on 2 févr. 2014 ...@@ -5,8 +5,8 @@ Created on 2 févr. 2014
''' '''
import logging import logging
from PyQt5.QtCore import Qt, QSignalMapper from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QErrorMessage, QAction, QMenu from PyQt5.QtWidgets import QWidget, QMessageBox, QAction, QMenu, QInputDialog, QLineEdit
from ..models.members import MembersListModel from ..models.members import MembersListModel
from ..gen_resources.community_tab_uic import Ui_CommunityTabWidget from ..gen_resources.community_tab_uic import Ui_CommunityTabWidget
from .add_contact import AddContactDialog from .add_contact import AddContactDialog
...@@ -89,11 +89,39 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): ...@@ -89,11 +89,39 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
dialog.exec_() dialog.exec_()
def send_membership_demand(self): def send_membership_demand(self):
result = self.account.send_membership_in(self.community) password = ""
if (result): message = "Please enter your password"
QErrorMessage(self).showMessage(result)
while not self.account.check_password(password):
password = QInputDialog.getText(self, "Account password",
message,
QLineEdit.Password)
message = "Error, wrong password. Please enter your password"
if password[1] is True:
password = password[0]
else:
return
try:
self.account.send_membership(password, self.community, 'IN')
except ValueError as e:
QMessageBox.critical(self, "Join demand error",
e.message)
def send_membership_leaving(self): def send_membership_leaving(self):
result = self.account.send_membership_out(self.community) password = ""
if (result): message = "Please enter your password"
QErrorMessage(self).showMessage(result)
while not self.account.check_password(password):
password = QInputDialog.getText(self, "Account password",
message,
QLineEdit.Password)
message = "Error, wrong password. Please enter your password"
if password[1] is True:
password = password[0]
else:
return
try:
self.account.send_membership(password, self.community, 'OUT')
except ValueError as e:
QMessageBox.critical(self, "Leaving demand error",
e.message)
...@@ -167,11 +167,13 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): ...@@ -167,11 +167,13 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
Would you like to publish the key ?".format(self.account.pubkey)) Would you like to publish the key ?".format(self.account.pubkey))
if reply == QMessageBox.Yes: if reply == QMessageBox.Yes:
password = "" password = ""
message = "Please enter your password"
while not self.account.check_password(password): while not self.account.check_password(password):
password = QInputDialog.getText(self, "Account password", password = QInputDialog.getText(self, "Account password",
"Wrong password.\nPlease enter your password", message,
QLineEdit.Password) QLineEdit.Password)
message = "Error, wrong password. Please enter your password"
if password[1] is True: if password[1] is True:
password = password[0] password = password[0]
else: else:
......
...@@ -39,8 +39,6 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): ...@@ -39,8 +39,6 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
for contact in sender.contacts: for contact in sender.contacts:
self.combo_contact.addItem(contact.name) self.combo_contact.addItem(contact.name)
self.edit_message.setEnabled(False)
def accept(self): def accept(self):
message = self.edit_message.text() message = self.edit_message.text()
......
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