Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
8402a53f
Commit
8402a53f
authored
7 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
Fix exception after closing certifier information window
#769
parent
e6b88941
No related branches found
No related tags found
1 merge request
!770
Fix exception after closing certifier information window #769
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sakia/gui/navigation/identity/table_model.py
+56
-26
56 additions, 26 deletions
src/sakia/gui/navigation/identity/table_model.py
src/sakia/services/identities.py
+3
-3
3 additions, 3 deletions
src/sakia/services/identities.py
with
59 additions
and
29 deletions
src/sakia/gui/navigation/identity/table_model.py
+
56
−
26
View file @
8402a53f
from
sakia.errors
import
NoPeerAvailable
from
sakia.data.entities
import
Identity
from
sakia.data.entities
import
Identity
,
Certification
from
sakia.data.processors
import
BlockchainProcessor
from
PyQt5.QtCore
import
QAbstractTableModel
,
QSortFilterProxyModel
,
Qt
,
\
QDateTime
,
QModelIndex
,
QLocale
,
QT_TRANSLATE_NOOP
...
...
@@ -16,7 +16,7 @@ class CertifiersFilterProxyModel(QSortFilterProxyModel):
def
columnCount
(
self
,
parent
):
return
len
(
CertifiersTableModel
.
columns_ids
)
-
2
def
lessThan
(
self
,
left
,
right
):
"""
Sort table by given column number.
...
...
@@ -108,47 +108,56 @@ class CertifiersTableModel(QAbstractTableModel):
self
.
connection
=
connection
self
.
blockchain_service
=
blockchain_service
self
.
identities_service
=
identities_service
self
.
_certifiers_data
=
[]
self
.
_certifiers_data
=
list
()
def
certifier_data
(
self
,
certification
):
def
init_certifiers
(
self
):
"""
Init table with data to display
"""
self
.
beginResetModel
()
certifications
=
self
.
identities_service
.
certifications_received
(
self
.
connection
.
pubkey
)
logging
.
debug
(
"
Refresh {0} certifiers
"
.
format
(
len
(
certifications
)))
certifiers_data
=
[]
for
certifier
in
certifications
:
certifiers_data
.
append
(
self
.
certifier_data
(
certifier
))
self
.
_certifiers_data
=
certifiers_data
self
.
endResetModel
()
def
certifier_data
(
self
,
certification
:
Certification
)
->
tuple
:
"""
Return the identity in the form a tuple to display
:param
sakia.data.entities.
Certification certification: The certification to get data from
:param Certification certification: The certification to get data from
:return: The certification data in the form of a tuple
:rtype: tuple
"""
parameters
=
self
.
blockchain_service
.
parameters
()
publication_date
=
certification
.
timestamp
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
if
written
:
expiration_date
=
publication_date
+
parameters
.
sig_validity
else
:
expiration_date
=
publication_date
+
parameters
.
sig_window
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
identity
=
self
.
identities_service
.
get_identity
(
certification
.
certifier
)
if
not
identity
:
identity
=
Identity
(
currency
=
certification
.
currency
,
pubkey
=
certification
.
certifier
,
uid
=
""
)
def
init_certifiers
(
self
):
"""
Change the identities to display
return
identity
.
uid
,
identity
.
pubkey
,
publication_date
,
expiration_date
,
written
,
identity
def
certifier_loaded
(
self
,
identity
:
Identity
):
"""
self
.
beginResetModel
()
certifications
=
self
.
identities_service
.
certifications_received
(
self
.
connection
.
pubkey
)
logging
.
debug
(
"
Refresh {0} certifiers
"
.
format
(
len
(
certifications
)))
certifiers_data
=
[]
for
certifier
in
certifications
:
certifiers_data
.
append
(
self
.
certifier_data
(
certifier
))
Update identity of certifier after closing information window
self
.
_certifiers_data
=
certifiers_data
self
.
endResetModel
()
:param Identity identity: Updated identity of the certifier
:return:
"""
for
i
,
certifier_data
in
enumerate
(
self
.
_certifiers_data
):
if
certifier_data
[
CertifiersTableModel
.
columns_ids
.
index
(
'
identity
'
)]
==
identity
:
self
.
_certifiers_data
[
i
]
=
update_certifier_data_from_identity
(
certifier_data
,
identity
)
self
.
dataChanged
.
emit
(
self
.
index
(
i
,
0
),
self
.
index
(
i
,
len
(
CertifiersTableModel
.
columns_ids
)))
return
def
rowCount
(
self
,
parent
):
return
len
(
self
.
_certifiers_data
)
...
...
@@ -170,3 +179,24 @@ class CertifiersTableModel(QAbstractTableModel):
def
flags
(
self
,
index
):
return
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsEnabled
#######################
# STATIC FUNCTIONS
#######################
def
update_certifier_data_from_identity
(
certifier_data
:
tuple
,
identity
:
Identity
)
->
tuple
:
"""
Return certifier data from updated identity
:param tuple certifier_data: Certifier data list
:param Identity identity: Identity of the certifier
:return tuple:
"""
return
identity
.
uid
,
\
identity
.
pubkey
,
\
certifier_data
[
CertifiersTableModel
.
columns_ids
.
index
(
'
publication
'
)],
\
certifier_data
[
CertifiersTableModel
.
columns_ids
.
index
(
'
expiration
'
)],
\
certifier_data
[
CertifiersTableModel
.
columns_ids
.
index
(
'
written
'
)],
\
identity
This diff is collapsed.
Click to expand it.
src/sakia/services/identities.py
+
3
−
3
View file @
8402a53f
...
...
@@ -75,7 +75,7 @@ class IdentitiesService(QObject):
for
c
in
connections
:
identities
.
append
(
self
.
_identities_processor
.
get_identity
(
self
.
currency
,
c
.
pubkey
))
return
identities
def
is_identity_of_connection
(
self
,
identity
):
return
identity
.
pubkey
in
self
.
_connections_processor
.
pubkeys
()
...
...
@@ -485,7 +485,7 @@ class IdentitiesService(QObject):
"""
Get the list of certifications received by a given identity
:param str pubkey: the pubkey
:rtype:
L
ist[
sakia.data.entities.
Certification
s
]
:rtype:
l
ist[Certification]
"""
return
self
.
_certs_processor
.
certifications_received
(
self
.
currency
,
pubkey
)
...
...
@@ -493,6 +493,6 @@ class IdentitiesService(QObject):
"""
Get the list of certifications received by a given identity
:param str pubkey: the pubkey
:rtype:
L
ist[
sakia.data.entities.
Certification
s
]
:rtype:
l
ist[Certification]
"""
return
self
.
_certs_processor
.
certifications_sent
(
self
.
currency
,
pubkey
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment