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
a864da7e
Commit
a864da7e
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Member informations
parent
5c00507a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
res/ui/member.ui
+8
-1
8 additions, 1 deletion
res/ui/member.ui
src/sakia/gui/member.py
+54
-35
54 additions, 35 deletions
src/sakia/gui/member.py
with
62 additions
and
36 deletions
res/ui/member.ui
+
8
−
1
View file @
a864da7e
...
...
@@ -11,7 +11,7 @@
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
<string>
Member informations
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
...
...
@@ -82,6 +82,13 @@ QGroupBox::title {
</property>
</widget>
</item>
<item
row=
"3"
column=
"1"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"label_path"
>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
...
...
This diff is collapsed.
Click to expand it.
src/sakia/gui/member.py
+
54
−
35
View file @
a864da7e
import
datetime
from
PyQt5.QtCore
import
QObject
,
QEvent
from
PyQt5.QtCore
import
QObject
,
QEvent
,
QLocale
,
QDateTime
from
PyQt5.QtWidgets
import
QDialog
,
QWidget
from
..core.graph
import
WoTGraph
...
...
@@ -37,11 +37,13 @@ class MemberDialog(QObject):
self
.
community
=
community
self
.
account
=
account
self
.
identity
=
identity
self
.
refresh
()
@classmethod
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
def
as_widget
(
cls
,
parent_widget
,
app
,
account
,
community
,
identity
):
...
...
@@ -52,6 +54,7 @@ class MemberDialog(QObject):
if
self
.
identity
:
self
.
ui
.
busy
.
show
()
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
:
...
...
@@ -62,49 +65,27 @@ class MemberDialog(QObject):
else
:
join_date
=
datetime
.
datetime
.
fromtimestamp
(
join_date
).
strftime
(
"
%d/%m/%Y %I:%M
"
)
# 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
)
identity_selfcert
=
await
self
.
identity
.
selfcert
(
self
.
community
)
uid_publish_date
=
QLocale
.
toString
(
QLocale
(),
QDateTime
.
fromTime_t
(
identity_selfcert
.
timestamp
),
QLocale
.
dateTimeFormat
(
QLocale
(),
QLocale
.
ShortFormat
)
)
text
=
self
.
tr
(
"""
<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>
"""
).
format
(
self
.
tr
(
'
Public key
'
),
self
.
identity
.
pubkey
,
self
.
tr
(
'
UID Published on
'
),
uid_publish_date
,
self
.
tr
(
'
Join date
'
),
join_date
)
if
path
:
distance
=
len
(
path
)
-
1
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
.
format
(
self
.
tr
(
'
Distance
'
),
distance
))
if
distance
>
1
:
index
=
0
for
node
in
path
:
if
index
==
0
:
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
)
\
.
format
(
self
.
tr
(
'
Path
'
),
node
[
'
text
'
])
else
:
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
)
\
.
format
(
''
,
node
[
'
text
'
])
if
index
==
distance
and
node
[
'
id
'
]
!=
self
.
account
.
pubkey
:
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
)
\
.
format
(
''
,
self
.
account
.
name
)
index
+=
1
# close html text
text
+=
"
</table>
"
...
...
@@ -112,6 +93,44 @@ class MemberDialog(QObject):
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
:
distance
=
len
(
path
)
-
1
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
.
format
(
self
.
tr
(
'
Distance
'
),
distance
))
if
distance
>
1
:
index
=
0
for
node
in
path
:
if
index
==
0
:
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
)
\
.
format
(
self
.
tr
(
'
Path
'
),
node
[
'
text
'
])
else
:
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
)
\
.
format
(
''
,
node
[
'
text
'
])
if
index
==
distance
and
node
[
'
id
'
]
!=
self
.
account
.
pubkey
:
text
+=
self
.
tr
(
"""
<tr><td align=
"
right
"
><b>{:}</b></div></td><td>{:}</td></tr>
"""
)
\
.
format
(
''
,
self
.
account
.
name
)
index
+=
1
self
.
ui
.
label_path
.
setText
(
text
)
def
eventFilter
(
self
,
source
,
event
):
if
event
.
type
()
==
QEvent
.
Resize
:
self
.
ui
.
busy
.
resize
(
event
.
size
())
...
...
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