Ejemplo n.º 1
0
def getAddressBookCommonContext(request, form=None):
    '''
    Get common context
    '''
    page_title = "Addressbook"

    # add a list of pages in the view
    sections = misc.getSiteSections('addressbook')
    currency_symbols = misc.getCurrencySymbol(connector)
    book = savedAddress.objects.filter(status__gt=0)
    currencies_available = []
    for provider_id in connector.services.keys():
        currencies_available.append({
            'provider_id':
            provider_id,
            'currency':
            connector.config[provider_id]['currency'],
            'name':
            connector.config[provider_id]['name']
        })

    for address in book:
        timestamp = calendar.timegm(address.entered.timetuple())
        address.time_pretty = misc.twitterizeDate(timestamp)
        if address.status == 1:
            address.button_text = _("enable")
            address.status_text = 'Hidden'
            address.icon = "glyphicon-minus-sign"
            address.icon_color = 'red-font'
        elif address.status == 2:
            address.button_text = _("disable")
            address.status_text = 'Active'
            address.icon = "glyphicon-ok-circle"
            address.icon_color = 'green-font'

    context = {
        'globals': MainConfig['globals'],
        'system_errors': connector.errors,
        'system_alerts': connector.alerts,
        'user': request.user,
        'breadcrumbs': misc.buildBreadcrumbs(current_section),
        'page_sections': sections,
        'page_title': page_title,
        'book': book,
        'currencies': currencies_available,
        'currency_symbols': currency_symbols,
        'form': form,
    }

    return context
Ejemplo n.º 2
0
    def __init__(self, transactionDetails):
        self._transaction = {}
        self._cache = Cacher({
            'details': {},
        })

        if type(transactionDetails) is dict:
            self._transaction = transactionDetails

            self['timereceived_pretty'] = misc.twitterizeDate(
                self.get('timereceived', 'never'))
            self['time_pretty'] = misc.twitterizeDate(self.get(
                'time', 'never'))
            self['timereceived_human'] = datetime.datetime.fromtimestamp(
                self.get('timereceived', 0))
            self['time_human'] = datetime.datetime.fromtimestamp(
                self.get('time', 0))
            self['blocktime_human'] = datetime.datetime.fromtimestamp(
                self.get('blocktime', 0))
            self['blocktime_pretty'] = misc.twitterizeDate(
                self.get('blocktime', 'never'))
            self['currency_symbol'] = misc.getCurrencySymbol(
                connector, self['currency'])

            if self.get('category', False) in ['receive', 'send']:
                if self['confirmations'] <= MainConfig['globals'][
                        'confirmation_limit']:
                    self['status_icon'] = 'glyphicon-time'
                    self['status_color'] = '#AAA'
                    self['tooltip'] = self['confirmations']
                else:
                    self['status_icon'] = 'glyphicon-ok-circle'
                    self['status_color'] = '#1C9E3F'
                    self['tooltip'] = self['confirmations']

            accountObject = self['wallet'].getAccountByName(self['account'])
            self['account'] = accountObject

            if self['category'] == 'receive':
                self['icon'] = 'glyphicon-circle-arrow-down'
            elif self['category'] == 'send':
                self['icon'] = 'glyphicon-circle-arrow-up'
            elif self['category'] == 'move':
                self['icon'] = 'glyphicon-circle-arrow-right'
                self['otheraccount'] = self['wallet'].getAccountByName(
                    self['otheraccount'])
Ejemplo n.º 3
0
def getAddressBookCommonContext(request, form=None):
    '''
    Get common context
    '''
    page_title = "Addressbook"
    
    # add a list of pages in the view
    sections = misc.getSiteSections('addressbook')
    currency_symbols = misc.getCurrencySymbol(connector)
    book = savedAddress.objects.filter(status__gt=0)
    currencies_available = []
    for provider_id in connector.services.keys():
        currencies_available.append({'provider_id': provider_id, 'currency': connector.config[provider_id]['currency'], 'name': connector.config[provider_id]['name']})
        
    for address in book:
        timestamp = calendar.timegm(address.entered.timetuple())
        address.time_pretty = misc.twitterizeDate(timestamp)
        if address.status == 1:
            address.button_text = _("enable")
            address.status_text = 'Hidden'
            address.icon = "glyphicon-minus-sign"
            address.icon_color = 'red-font'
        elif address.status == 2:
            address.button_text = _("disable")
            address.status_text = 'Active'
            address.icon = "glyphicon-ok-circle"
            address.icon_color = 'green-font'
    
    context = {
               'globals': MainConfig['globals'],
               'system_errors': connector.errors,
               'system_alerts': connector.alerts,
               'user': request.user,
               'breadcrumbs': misc.buildBreadcrumbs(current_section),
               'page_sections': sections,
               'page_title': page_title,
               'book': book,
               'currencies': currencies_available,
               'currency_symbols': currency_symbols,
               'form': form,
               }
    
    return context
Ejemplo n.º 4
0
 def __init__(self, transactionDetails):
     self._transaction = {}
     self. _cache = Cacher({
                  'details': {},
                  })
     
     if type(transactionDetails) is dict:
         self._transaction = transactionDetails
         
         self['timereceived_pretty'] = misc.twitterizeDate(self.get('timereceived', 'never'))
         self['time_pretty'] = misc.twitterizeDate(self.get('time', 'never'))
         self['timereceived_human'] = datetime.datetime.fromtimestamp(self.get('timereceived', 0))
         self['time_human'] = datetime.datetime.fromtimestamp(self.get('time', 0))
         self['blocktime_human'] = datetime.datetime.fromtimestamp(self.get('blocktime', 0))
         self['blocktime_pretty'] = misc.twitterizeDate(self.get('blocktime', 'never'))
         self['currency_symbol'] = misc.getCurrencySymbol(connector, self['currency'])
         
         if self.get('category', False) in ['receive', 'send']:
             if self['confirmations'] <= MainConfig['globals']['confirmation_limit']:
                 self['status_icon'] = 'glyphicon-time'
                 self['status_color'] = '#AAA';
                 self['tooltip'] = self['confirmations']
             else:
                 self['status_icon'] = 'glyphicon-ok-circle'
                 self['status_color'] = '#1C9E3F';
                 self['tooltip'] = self['confirmations']
         
         accountObject = self['wallet'].getAccountByName(self['account'])
         self['account'] = accountObject
         
         if self['category'] == 'receive':
             self['icon'] = 'glyphicon-circle-arrow-down'
         elif self['category'] == 'send':
             self['icon'] = 'glyphicon-circle-arrow-up'
         elif self['category'] == 'move':
             self['icon'] = 'glyphicon-circle-arrow-right'
             self['otheraccount'] = self['wallet'].getAccountByName(self['otheraccount'])
Ejemplo n.º 5
0
 def getCurrencySymbol(self):
     '''
     Return the Unicode currency symbol
     '''
     return misc.getCurrencySymbol(connector, self.getCurrencyCode())
Ejemplo n.º 6
0
 def getCurrencySymbol(self):
     '''
     Return the Unicode currency symbol
     '''
     return misc.getCurrencySymbol(connector, self.getCurrencyCode())