Skip to content
Snippets Groups Projects
Commit 96db7af6 authored by Vincent Texier's avatar Vincent Texier
Browse files

Display path to account member in member window (unstable)

parent 2a24a453
No related branches found
No related tags found
No related merge requests found
...@@ -259,3 +259,6 @@ class Account(object): ...@@ -259,3 +259,6 @@ class Account(object):
'wallets': data_wallets, 'wallets': data_wallets,
'contacts': data_contacts} 'contacts': data_contacts}
return data return data
def get_person(self):
return Person(self.name, self.pubkey)
...@@ -18,6 +18,13 @@ class Graph(dict): ...@@ -18,6 +18,13 @@ class Graph(dict):
path = list() path = list()
graph_tmp = copy.deepcopy(self) graph_tmp = copy.deepcopy(self)
if from_person.pubkey not in graph_tmp.keys():
graph_tmp.add_person(from_person)
certifier_list = from_person.certifiers_of(self.community)
graph_tmp.add_certifier_list(certifier_list, from_person, to_person)
certified_list = from_person.certified_by(self.community)
graph_tmp.add_certified_list(certified_list, from_person, to_person)
if to_person.pubkey not in graph_tmp.keys(): if to_person.pubkey not in graph_tmp.keys():
# recursively feed graph searching for account node... # recursively feed graph searching for account node...
graph_tmp.explore_to_find_member(to_person, graph_tmp[from_person.pubkey]['nodes'], list()) graph_tmp.explore_to_find_member(to_person, graph_tmp[from_person.pubkey]['nodes'], list())
......
import logging from cutecoin.core.graph import Graph
import datetime
import math
from PyQt5.QtWidgets import QDialog from PyQt5.QtWidgets import QDialog
from ..gen_resources.member_uic import Ui_DialogMember from ..gen_resources.member_uic import Ui_DialogMember
...@@ -25,18 +23,41 @@ class MemberDialog(QDialog, Ui_DialogMember): ...@@ -25,18 +23,41 @@ class MemberDialog(QDialog, Ui_DialogMember):
if join_date is None: if join_date is None:
join_date = 'not a member' join_date = 'not a member'
# set infos in label # calculate path to account member
self.label_properties.setText( graph = Graph(self.community)
""" path = None
# if selected member is not the account member...
if person.pubkey != self.account.pubkey:
# add path from selected member to account member
path = graph.get_shortest_path_between_members(person, self.account.get_person())
text = """
<table cellpadding="5"> <table cellpadding="5">
<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr> <tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>
<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr> <tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>
</table>
""".format( """.format(
'Public key', 'Public key',
self.person.pubkey, self.person.pubkey,
'Join date', 'Join date',
join_date join_date
) )
)
if path:
distance = len(path) - 1
text += """<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""".format('Distance', distance)
if distance > 1:
index = 0
for node in path:
if index == 0:
text += """<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""".format('Path', node['text'])
else:
text += """<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""".format('', node['text'])
if index == distance and node['id'] != self.account.pubkey:
text += """<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""".format('', self.account.name)
index += 1
# close html text
text += "</table>"
# set text in label
self.label_properties.setText(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