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

Fix crash with certifications expiring

parent cbc179f8
No related branches found
No related tags found
No related merge requests found
...@@ -90,7 +90,7 @@ class CertificationsRepo: ...@@ -90,7 +90,7 @@ class CertificationsRepo:
""" """
request = """SELECT * FROM certifications request = """SELECT * FROM certifications
WHERE currency=? AND (certifier=? or certified=?) WHERE currency=? AND (certifier=? or certified=?)
AND ((ts + ? < ?) or (written_on == 0 and ts + ? < ?)) AND ((ts + ? < ?) or (written_on == -1 and ts + ? < ?))
""" """
c = self._conn.execute(request, (currency, pubkey, pubkey, c = self._conn.execute(request, (currency, pubkey, pubkey,
sig_validity, current_ts, sig_validity, current_ts,
......
...@@ -70,6 +70,7 @@ class IdentityController(QObject): ...@@ -70,6 +70,7 @@ class IdentityController(QObject):
if valid: if valid:
menu = ContextMenu.from_data(self.view, self.model.app, None, (identity,)) menu = ContextMenu.from_data(self.view, self.model.app, None, (identity,))
menu.view_identity_in_wot.connect(self.view_in_wot) menu.view_identity_in_wot.connect(self.view_in_wot)
menu.identity_information_loaded.connect(self.model.table_model.certifier_loaded)
# Show the context menu. # Show the context menu.
menu.qmenu.popup(QCursor.pos()) menu.qmenu.popup(QCursor.pos())
......
...@@ -52,9 +52,9 @@ class IdentityModel(QObject): ...@@ -52,9 +52,9 @@ class IdentityModel(QObject):
async def refresh_identity_data(self): async def refresh_identity_data(self):
identity = self.identities_service.get_identity(self.connection.pubkey, self.connection.uid) identity = self.identities_service.get_identity(self.connection.pubkey, self.connection.uid)
certified = self.identities_service.certifications_sent(self.connection.pubkey)
identity = await self.identities_service.load_requirements(identity) identity = await self.identities_service.load_requirements(identity)
certifiers = await self.identities_service.load_certifiers_of(identity) certifiers = await self.identities_service.load_certifiers_of(identity)
certified = await self.identities_service.load_certified_by(identity)
await self.identities_service.load_certs_in_lookup(identity, certifiers, certified) await self.identities_service.load_certs_in_lookup(identity, certifiers, certified)
self.table_model.init_certifiers() self.table_model.init_certifiers()
......
from sakia.errors import NoPeerAvailable from sakia.errors import NoPeerAvailable
from sakia.data.entities import Identity
from sakia.data.processors import BlockchainProcessor from sakia.data.processors import BlockchainProcessor
from PyQt5.QtCore import QAbstractTableModel, QSortFilterProxyModel, Qt, \ from PyQt5.QtCore import QAbstractTableModel, QSortFilterProxyModel, Qt, \
QDateTime, QModelIndex, QLocale, QT_TRANSLATE_NOOP QDateTime, QModelIndex, QLocale, QT_TRANSLATE_NOOP
...@@ -119,6 +120,8 @@ class CertifiersTableModel(QAbstractTableModel): ...@@ -119,6 +120,8 @@ class CertifiersTableModel(QAbstractTableModel):
parameters = self.blockchain_service.parameters() parameters = self.blockchain_service.parameters()
publication_date = certification.timestamp publication_date = certification.timestamp
identity = self.identities_service.get_identity(certification.certifier) identity = self.identities_service.get_identity(certification.certifier)
if not identity:
identity = Identity(currency=certification.currency, pubkey=certification.certifier, uid="")
written = certification.written_on >= 0 written = certification.written_on >= 0
if written: if written:
expiration_date = publication_date + parameters.sig_validity expiration_date = publication_date + parameters.sig_validity
...@@ -126,6 +129,13 @@ class CertifiersTableModel(QAbstractTableModel): ...@@ -126,6 +129,13 @@ class CertifiersTableModel(QAbstractTableModel):
expiration_date = publication_date + parameters.sig_window expiration_date = publication_date + parameters.sig_window
return identity.uid, identity.pubkey, publication_date, expiration_date, written, identity return identity.uid, identity.pubkey, publication_date, expiration_date, written, identity
def certifier_loaded(self, identity):
for i, idty in enumerate(self.identities_data):
if idty[CertifiersTableModel.columns_ids.index('identity')] == identity:
self._certifiers_data[i] = self._certifiers_data(identity)
self.dataChanged.emit(self.index(i, 0), self.index(i, len(CertifiersTableModel.columns_ids)))
return
def init_certifiers(self): def init_certifiers(self):
""" """
Change the identities to display Change the identities to display
......
from PyQt5.QtWidgets import QDialog, QTabWidget, QVBoxLayout from PyQt5.QtWidgets import QDialog, QTabWidget, QVBoxLayout
from PyQt5.QtCore import QObject, pyqtSignal from PyQt5.QtCore import QObject, pyqtSignal
from sakia.decorators import asyncify from sakia.decorators import asyncify
from sakia.data.entities import Identity
from sakia.gui.widgets.dialogs import dialog_async_exec, QAsyncMessageBox from sakia.gui.widgets.dialogs import dialog_async_exec, QAsyncMessageBox
from .model import UserInformationModel from .model import UserInformationModel
from .view import UserInformationView from .view import UserInformationView
...@@ -11,7 +12,7 @@ class UserInformationController(QObject): ...@@ -11,7 +12,7 @@ class UserInformationController(QObject):
""" """
The homescreen view The homescreen view
""" """
identity_loaded = pyqtSignal() identity_loaded = pyqtSignal(Identity)
def __init__(self, parent, view, model): def __init__(self, parent, view, model):
""" """
...@@ -72,7 +73,7 @@ class UserInformationController(QObject): ...@@ -72,7 +73,7 @@ class UserInformationController(QObject):
self.model.identity.membership_timestamp, self.model.identity.membership_timestamp,
self.model.mstime_remaining(), await self.model.nb_certs()) self.model.mstime_remaining(), await self.model.nb_certs())
self.view.hide_busy() self.view.hide_busy()
self.identity_loaded.emit() self.identity_loaded.emit(self.model.identity)
except RuntimeError as e: except RuntimeError as e:
# object can be deleted by Qt during asynchronous ops # object can be deleted by Qt during asynchronous ops
# we don't care of this error # we don't care of this error
......
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