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
fd58087a
Commit
fd58087a
authored
10 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Referentials implementation
parent
798434ed
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
src/cutecoin/core/account.py
+17
-26
17 additions, 26 deletions
src/cutecoin/core/account.py
src/cutecoin/gui/mainwindow.py
+9
-7
9 additions, 7 deletions
src/cutecoin/gui/mainwindow.py
with
26 additions
and
33 deletions
src/cutecoin/core/account.py
+
17
−
26
View file @
fd58087a
...
...
@@ -29,6 +29,20 @@ class Account(object):
be locally referenced by only one account.
'''
@staticmethod
def
units
(
units
,
community
):
return
units
@staticmethod
def
relative
(
units
,
community
):
ud
=
community
.
dividend
()
relative_value
=
units
/
float
(
ud
)
return
relative_value
referentials
=
{
'
Units
'
:
(
units
.
__func__
,
'
{0}
'
),
'
UD
'
:
(
relative
.
__func__
,
'
UD {0}
'
)
}
def
__init__
(
self
,
salt
,
pubkey
,
name
,
communities
,
wallets
,
contacts
,
dead_communities
):
'''
...
...
@@ -41,7 +55,7 @@ class Account(object):
self
.
dead_communities
=
dead_communities
self
.
wallets
=
wallets
self
.
contacts
=
contacts
self
.
referential
=
0
self
.
referential
=
'
Units
'
@classmethod
def
create
(
cls
,
name
,
communities
,
wallets
,
confpath
):
...
...
@@ -108,33 +122,10 @@ class Account(object):
@property
def
units_to_ref
(
self
):
def
units
(
units
,
community
):
return
units
def
relative
(
units
,
community
):
ud
=
community
.
dividend
()
relative_value
=
units
/
float
(
ud
)
return
relative_value
def
units_to_zero
(
units
,
community
):
monetary_mass
=
community
.
monetary_mass
()
to_zero_value
=
units
-
(
monetary_mass
/
2
)
return
to_zero_value
def
relative_to_zero
(
units
,
community
):
monetary_mass
=
community
.
monetary_mass
()
ud
=
community
.
dividend
()
relative_mass
=
monetary_mass
/
float
(
ud
)
relative_value
=
units
/
float
(
ud
)
to_zero_value
=
relative_value
-
(
relative_mass
/
2
)
return
to_zero_value
referentials
=
[
units
,
relative
,
units_to_zero
,
relative_to_zero
]
return
referentials
[
self
.
referential
]
return
Account
.
referentials
[
self
.
referential
][
0
]
def
ref_name
(
self
,
currency
):
referentials
=
[
'
{0}
'
,
'
UD {0}
'
,
'
{0} -> 0
'
,
'
UD {0} -> 0
'
]
return
referentials
[
self
.
referential
].
format
(
currency
)
return
Account
.
referentials
[
self
.
referential
][
1
].
format
(
currency
)
def
set_walletpool_size
(
self
,
size
,
password
):
logging
.
debug
(
"
Defining wallet pool size
"
)
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/mainwindow.py
+
9
−
7
View file @
fd58087a
...
...
@@ -16,6 +16,7 @@ from .import_account import ImportAccountDialog
from
.certification
import
CertificationDialog
from
.password_asker
import
PasswordAskerDialog
from
..tools.exceptions
import
NoPeerAvailable
from
..core.account
import
Account
from
..__init__
import
__version__
import
logging
...
...
@@ -71,9 +72,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
combo_referential
=
QComboBox
(
self
)
self
.
combo_referential
.
setEnabled
(
False
)
self
.
combo_referential
.
currentIndexChanged
.
connect
(
self
.
referential_changed
)
self
.
combo_referential
.
addItems
((
"
Units
"
,
"
UD
"
,
"
Units to zero
"
,
"
UD to zero
"
))
self
.
combo_referential
.
currentTextChanged
.
connect
(
self
.
referential_changed
)
self
.
status_label
=
QLabel
(
""
,
self
.
statusbar
)
self
.
statusbar
.
addPermanentWidget
(
self
.
status_label
)
...
...
@@ -105,11 +104,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
error
,
QMessageBox
.
Ok
)
@pyqtSlot
(
int
)
def
referential_changed
(
self
,
ind
ex
):
@pyqtSlot
(
str
)
def
referential_changed
(
self
,
t
ex
t
):
if
self
.
app
.
current_account
:
self
.
app
.
current_account
.
set_display_referential
(
index
)
self
.
currencies_tabwidget
.
currentWidget
().
referential_changed
()
self
.
app
.
current_account
.
set_display_referential
(
text
)
if
self
.
currencies_tabwidget
.
currentWidget
():
self
.
currencies_tabwidget
.
currentWidget
().
referential_changed
()
def
action_change_account
(
self
,
account_name
):
self
.
busybar
.
show
()
...
...
@@ -190,6 +190,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
action_set_as_default
.
setEnabled
(
self
.
app
.
current_account
.
name
!=
self
.
app
.
default_account
)
self
.
password_asker
=
PasswordAskerDialog
(
self
.
app
.
current_account
)
self
.
combo_referential
.
addItems
(
Account
.
referentials
.
keys
())
self
.
combo_referential
.
setEnabled
(
True
)
self
.
menu_contacts
.
setEnabled
(
True
)
self
.
action_configure_parameters
.
setEnabled
(
True
)
...
...
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