Skip to content
Snippets Groups Projects
Commit 4146d6b5 authored by inso's avatar inso
Browse files

Added currency name shortening

parent a96715ca
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ class Account(object): ...@@ -39,7 +39,7 @@ class Account(object):
be locally referenced by only one account. be locally referenced by only one account.
''' '''
referentials = {'Units': (units, '{0}'), referentials = {'Units': (units, '{0}'),
'UD': (relative, 'UD {0}') 'UD': (relative, 'ud {0}')
} }
def __init__(self, salt, pubkey, name, communities, wallets, contacts, def __init__(self, salt, pubkey, name, communities, wallets, contacts,
......
...@@ -12,6 +12,7 @@ from ..tools.exceptions import NoPeerAvailable ...@@ -12,6 +12,7 @@ from ..tools.exceptions import NoPeerAvailable
import logging import logging
import inspect import inspect
import hashlib import hashlib
import re
from requests.exceptions import RequestException, Timeout from requests.exceptions import RequestException, Timeout
...@@ -121,6 +122,24 @@ class Community(object): ...@@ -121,6 +122,24 @@ class Community(object):
def __eq__(self, other): def __eq__(self, other):
return (other.currency == self.currency) return (other.currency == self.currency)
@property
def short_currency(self):
words = re.split('[_\W]+', self.currency)
shortened = ""
if len(words) > 1:
shortened = ''.join([w[0] for w in words])
else:
vowels = ('a', 'e', 'i', 'o', 'u', 'y')
shortened = self.currency
shortened = ''.join([c for c in shortened if c not in vowels])
return shortened
@property
def currency_symbol(self):
letter = self.currency[0]
u = ord('\u24B6') + ord(letter) - ord('A')
return chr(u)
def dividend(self): def dividend(self):
ud = self.request(bma.blockchain.UD) ud = self.request(bma.blockchain.UD)
if len(ud['result']['blocks']) > 0: if len(ud['result']['blocks']) > 0:
......
...@@ -76,7 +76,7 @@ class HistoryTableModel(QAbstractTableModel): ...@@ -76,7 +76,7 @@ class HistoryTableModel(QAbstractTableModel):
amount = 0 amount = 0
for o in tx[1].outputs: for o in tx[1].outputs:
pubkeys = [w.pubkey for w in self.account.wallets] pubkeys = [w.pubkey for w in self.account.wallets]
if o.pubkey not in pubkeys: if o.pubkey in pubkeys:
outputs.append(o) outputs.append(o)
amount += o.amount amount += o.amount
comment = tx[1].comment comment = tx[1].comment
...@@ -86,12 +86,14 @@ class HistoryTableModel(QAbstractTableModel): ...@@ -86,12 +86,14 @@ class HistoryTableModel(QAbstractTableModel):
except PersonNotFoundError: except PersonNotFoundError:
sender = pubkey sender = pubkey
date_ts = self.community.get_block(tx[0]).mediantime date_ts = self.community.get_block(tx[0]).time
date = QDateTime.fromTime_t(date_ts) date = QDateTime.fromTime_t(date_ts)
amount_ref = self.account.units_to_ref(amount, self.community) amount_ref = self.account.units_to_ref(amount, self.community)
ref_name = self.account.ref_name(self.community.short_currency)
return (date.date(), sender, "", "{0}".format(amount_ref), comment) return (date.date(), sender, "", "{0} {1}".format(amount_ref, ref_name),
comment)
def data_sent(self, tx): def data_sent(self, tx):
amount = 0 amount = 0
...@@ -108,12 +110,14 @@ class HistoryTableModel(QAbstractTableModel): ...@@ -108,12 +110,14 @@ class HistoryTableModel(QAbstractTableModel):
receiver = Person.lookup(pubkey, self.community).name receiver = Person.lookup(pubkey, self.community).name
except PersonNotFoundError: except PersonNotFoundError:
receiver = pubkey receiver = pubkey
date_ts = self.community.get_block(tx[0]).mediantime date_ts = self.community.get_block(tx[0]).time
date = QDateTime.fromTime_t(date_ts) date = QDateTime.fromTime_t(date_ts)
amount_ref = self.account.units_to_ref(-amount, self.community) amount_ref = self.account.units_to_ref(-amount, self.community)
ref_name = self.account.ref_name(self.community.short_currency)
return (date.date(), receiver, "{0}".format(amount_ref), "", comment) return (date.date(), receiver, "{0} {1}".format(amount_ref, ref_name),
"", comment)
def data(self, index, role): def data(self, index, role):
row = index.row() row = index.row()
......
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