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

Check membership lors d'ajout de communautés : Ok.

parent fac788ac
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="pgpkeyList"/>
<widget class="QComboBox" name="gpgKeysList"/>
</item>
</layout>
</item>
......@@ -149,5 +149,6 @@
</connections>
<slots>
<slot>openAddCommunityDialog()</slot>
<slot>keyChanged(int)</slot>
</slots>
</ui>
......@@ -29,7 +29,6 @@ class AddAccountDialog(QDialog, Ui_AddAccountDialog):
self.dialog = AddCommunityDialog(self)
self.mainWindow = mainWindow
self.buttonBox.accepted.connect(self.mainWindow.actionAddAccount)
self.setData()
......@@ -38,15 +37,23 @@ class AddAccountDialog(QDialog, Ui_AddAccountDialog):
gpg = gnupg.GPG()
availableKeys = gpg.list_keys(True)
for key in availableKeys:
self.pgpkeyList.addItem(key['uids'][0])
self.gpgKeysList.addItem(key['uids'][0])
self.account = Account(self.pgpkeyList.currentText(), "", Communities())
self.account = Account(availableKeys[0]['keyid'], "", Communities())
self.gpgKeysList.setEnabled()
self.gpgKeysList.currentIndexChanged[int].connect(self.keyChanged)
def openAddCommunityDialog(self):
self.dialog.setAccount(self.account)
self.dialog.exec_()
def actionAddCommunity(self):
self.gpgKeysList.setDisabled()
self.gpgKeysList.disconnect()
self.communitiesList.setModel(CommunitiesListModel(self.account))
def keyChanged(self, keyIndex):
gpg = gnupg.GPG()
availableKeys = gpg.list_keys(True)
self.account.gpgKey = availableKeys[keyIndex]['keyid']
......@@ -50,4 +50,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.walletContent.setModel(WalletListModel(self.core.currentAccount.wallets.walletsList[0]))
for community in self.core.currentAccount.communities.communitiesList:
self.communitiesTab.addPage(CommunityTabWidget(community), community.name())
#TODO: self.transactionsReceived.setModel()
#TODO: self.transactionsSent.setModel()
......@@ -13,11 +13,11 @@ class Account(object):
classdocs
'''
def __init__(self, pgpKey, name, communities):
def __init__(self, gpgKey, name, communities):
'''
Constructor
'''
self.pgpKey = pgpKey
self.gpgKey = gpgKey
self.name = name
self.communities = communities
self.wallets = Wallets()
......@@ -34,8 +34,10 @@ class Account(object):
def keyFingerprint(self):
gpg = gnupg.GPG()
availableKeys = gpg.list_keys()
print(self.gpgKey)
for k in availableKeys:
if k['keyid'] == self.pgpKey:
print(k)
if k['keyid'] == self.gpgKey:
return k['fingerprint']
return ""
......
......@@ -26,8 +26,9 @@ class Communities(object):
community = Community(mainNode)
self.members = community.ucoinRequest(lambda:ucoin.hdc.amendments.view.Members(community.currentAmendmentId()).get)
#TODO: Check membership
print(accountFingerprint)
for member in self.members:
print(member)
if member['value'] == accountFingerprint:
self.communitiesList.append(community)
return community
......
......@@ -43,8 +43,9 @@ class Community(object):
def currentAmendmentId(self):
currentAmendment = self.ucoinRequest(lambda:ucoin.hdc.amendments.Current().get)
currentAmendmentHash = hashlib.sha1(json.dumps(currentAmendment).encode('utf-8')).hexdigest()
currentAmendmentHash = hashlib.sha1(currentAmendment['raw'].encode('utf-8')).hexdigest().upper()
amendmentId = str(currentAmendment["number"]) + "-" + currentAmendmentHash
#TODO: Distinct debug logging and info logging for a -d parameter
print("Amendment : " + amendmentId)
return amendmentId
......
......@@ -10,11 +10,12 @@ class Transaction(object):
'''
def __init__(self, value, sender, receiver, currency):
def __init__(self, senderFingerprint, increment):
'''
Constructor
'''
self.value = value
self.sender = sender
self.receiver = receiver
self.currency = currency
self.senderFingerprint = senderFingerprint
self.increment = increment
def transactionID(self):
return self.senderFingerprint + "-" + self.increment
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