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

Member informations

parent 5c00507a
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Member informations</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
...@@ -82,6 +82,13 @@ QGroupBox::title { ...@@ -82,6 +82,13 @@ QGroupBox::title {
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="label_path">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
......
import datetime import datetime
from PyQt5.QtCore import QObject, QEvent from PyQt5.QtCore import QObject, QEvent, QLocale, QDateTime
from PyQt5.QtWidgets import QDialog, QWidget from PyQt5.QtWidgets import QDialog, QWidget
from ..core.graph import WoTGraph from ..core.graph import WoTGraph
...@@ -37,11 +37,13 @@ class MemberDialog(QObject): ...@@ -37,11 +37,13 @@ class MemberDialog(QObject):
self.community = community self.community = community
self.account = account self.account = account
self.identity = identity self.identity = identity
self.refresh()
@classmethod @classmethod
def open_dialog(cls, app, account, community, identity): def open_dialog(cls, app, account, community, identity):
return cls(app, account, community, identity, QDialog(), Ui_MemberView()).exec() dialog = cls(app, account, community, identity, QDialog(), Ui_MemberView())
dialog.refresh()
dialog.refresh_path()
dialog.exec()
@classmethod @classmethod
def as_widget(cls, parent_widget, app, account, community, identity): def as_widget(cls, parent_widget, app, account, community, identity):
...@@ -52,6 +54,7 @@ class MemberDialog(QObject): ...@@ -52,6 +54,7 @@ class MemberDialog(QObject):
if self.identity: if self.identity:
self.ui.busy.show() self.ui.busy.show()
self.ui.label_uid.setText(self.identity.uid) self.ui.label_uid.setText(self.identity.uid)
self.ui.label_properties.setText("")
try: try:
join_date = await self.identity.get_join_date(self.community) join_date = await self.identity.get_join_date(self.community)
except MembershipNotFoundError: except MembershipNotFoundError:
...@@ -62,26 +65,47 @@ class MemberDialog(QObject): ...@@ -62,26 +65,47 @@ class MemberDialog(QObject):
else: else:
join_date = datetime.datetime.fromtimestamp(join_date).strftime("%d/%m/%Y %I:%M") join_date = datetime.datetime.fromtimestamp(join_date).strftime("%d/%m/%Y %I:%M")
# calculate path to account member
graph = WoTGraph(self.app, self.community) identity_selfcert = await self.identity.selfcert(self.community)
path = None uid_publish_date = QLocale.toString(
# if selected member is not the account member... QLocale(),
if self.identity.pubkey != self.account.pubkey: QDateTime.fromTime_t(identity_selfcert.timestamp),
# add path from selected member to account member QLocale.dateTimeFormat(QLocale(), QLocale.ShortFormat)
account_identity = await self.account.identity(self.community) )
path = await graph.get_shortest_path_to_identity(self.identity,
account_identity)
text = self.tr(""" text = self.tr("""
<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>
<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>
""").format( """).format(
self.tr('Public key'), self.tr('Public key'),
self.identity.pubkey, self.identity.pubkey,
self.tr('UID Published on'),
uid_publish_date,
self.tr('Join date'), self.tr('Join date'),
join_date join_date
) )
# close html text
text += "</table>"
# set text in label
self.ui.label_properties.setText(text)
self.ui.busy.hide()
@asyncify
async def refresh_path(self):
text = ""
self.ui.label_path.setText("")
# calculate path to account member
graph = WoTGraph(self.app, self.community)
path = None
# if selected member is not the account member...
if self.identity.pubkey != self.account.pubkey:
# add path from selected member to account member
account_identity = await self.account.identity(self.community)
path = await graph.get_shortest_path_to_identity(self.identity,
account_identity)
if path: if path:
distance = len(path) - 1 distance = len(path) - 1
...@@ -105,12 +129,7 @@ class MemberDialog(QObject): ...@@ -105,12 +129,7 @@ class MemberDialog(QObject):
.format('', .format('',
self.account.name) self.account.name)
index += 1 index += 1
# close html text self.ui.label_path.setText(text)
text += "</table>"
# set text in label
self.ui.label_properties.setText(text)
self.ui.busy.hide()
def eventFilter(self, source, event): def eventFilter(self, source, event):
if event.type() == QEvent.Resize: if event.type() == QEvent.Resize:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment