diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 9c8708d641d66e34398a9ac35325b07ffdc04989..04021a4e1adb68eacd8a617768c31bab62443eec 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -39,7 +39,7 @@ class Account(object): be locally referenced by only one account. ''' referentials = {'Units': (units, '{0}'), - 'UD': (relative, 'UD {0}') + 'UD': (relative, 'ud {0}') } def __init__(self, salt, pubkey, name, communities, wallets, contacts, diff --git a/src/cutecoin/core/community.py b/src/cutecoin/core/community.py index d63eef724528945f2089314d1fd451201704b9af..0eb1330cdffba52b6e6bf29da0c6cd27c47f9c16 100644 --- a/src/cutecoin/core/community.py +++ b/src/cutecoin/core/community.py @@ -12,6 +12,7 @@ from ..tools.exceptions import NoPeerAvailable import logging import inspect import hashlib +import re from requests.exceptions import RequestException, Timeout @@ -121,6 +122,24 @@ class Community(object): def __eq__(self, other): 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): ud = self.request(bma.blockchain.UD) if len(ud['result']['blocks']) > 0: diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index 41a382872ba5697df6cd9fad9db74a28c2ed9fbd..f296d7145aab031a87e2f8bf1ee56e1cf56be2f6 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -76,7 +76,7 @@ class HistoryTableModel(QAbstractTableModel): amount = 0 for o in tx[1].outputs: pubkeys = [w.pubkey for w in self.account.wallets] - if o.pubkey not in pubkeys: + if o.pubkey in pubkeys: outputs.append(o) amount += o.amount comment = tx[1].comment @@ -86,12 +86,14 @@ class HistoryTableModel(QAbstractTableModel): except PersonNotFoundError: 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) 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): amount = 0 @@ -108,12 +110,14 @@ class HistoryTableModel(QAbstractTableModel): receiver = Person.lookup(pubkey, self.community).name except PersonNotFoundError: 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) 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): row = index.row()