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

Call change_community in search_user and member

parent 5abd05e7
No related branches found
No related tags found
No related merge requests found
......@@ -73,15 +73,17 @@ class CertificationDialog(QObject):
self.ui.combo_community.currentIndexChanged.connect(self.change_current_community)
@classmethod
def open_dialog(cls, app, account, password_asker):
def open_dialog(cls, app, account, community, password_asker):
"""
Certify and identity
:param sakia.core.Application app: the application
:param sakia.core.Account account: the account certifying the identity
:param sakia.core.Community community: the community
:param sakia.gui.password_asker.PasswordAsker password_asker: the password asker
:return:
"""
dialog = cls(app, account, password_asker, QDialog(), Ui_CertificationDialog())
dialog.ui.combo_community.setCurrentText(community.name)
return dialog.exec()
@classmethod
......@@ -137,7 +139,8 @@ class CertificationDialog(QObject):
def change_current_community(self, index):
self.community = self.account.communities[index]
self.ui.search_user.change_community(self.community)
if self.isVisible():
self.ui.member_widget.change_community(self.community)
if self.widget.isVisible():
self.refresh()
def selected_pubkey(self):
......
......@@ -246,6 +246,7 @@ class MainWindow(QObject):
def open_certification_dialog(self):
CertificationDialog.open_dialog(self.app,
self.account,
self.community_view.community,
self.password_asker)
def open_add_contact_dialog(self):
......
......@@ -7,7 +7,7 @@ from ..core.graph import WoTGraph
from .widgets.busy import Busy
from ..tools.decorators import asyncify
from ..gen_resources.member_uic import Ui_MemberView
from ..tools.exceptions import MembershipNotFoundError
from ..tools.exceptions import MembershipNotFoundError, LookupFailureError, NoPeerAvailable
class MemberDialog(QObject):
......@@ -49,6 +49,14 @@ class MemberDialog(QObject):
def as_widget(cls, parent_widget, app, account, community, identity):
return cls(app, account, community, identity, QWidget(parent_widget), Ui_MemberView())
def change_community(self, community):
"""
Change current community
:param sakia.core.Community community: the new community
"""
self.community = community
self.refresh()
@asyncify
async def refresh(self):
if self.identity:
......@@ -56,22 +64,30 @@ class MemberDialog(QObject):
self.ui.label_uid.setText(self.identity.uid)
self.ui.label_properties.setText("")
try:
join_date = await self.identity.get_join_date(self.community)
except MembershipNotFoundError:
join_date = None
identity_selfcert = await self.identity.selfcert(self.community)
publish_time = await self.community.time(identity_selfcert.timestamp.number)
join_date = await self.identity.get_join_date(self.community)
if join_date is None:
join_date = self.tr('not a member')
else:
join_date = datetime.datetime.fromtimestamp(join_date).strftime("%d/%m/%Y %I:%M")
identity_selfcert = await self.identity.selfcert(self.community)
time = await self.community.time(identity_selfcert.timestamp.number)
except MembershipNotFoundError:
join_date = "###"
except (LookupFailureError, NoPeerAvailable):
publish_time = None
join_date = "###"
if publish_time:
uid_publish_date = QLocale.toString(
QLocale(),
QDateTime.fromTime_t(time),
QDateTime.fromTime_t(publish_time),
QLocale.dateTimeFormat(QLocale(), QLocale.ShortFormat)
)
else:
uid_publish_date = "###"
text = self.tr("""
<table cellpadding="5">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment