Ejemplo n.º 1
0
def index(request, selected_provider_id=sorted(connector.config.keys())[0]):
    '''
    Handler for the accounts
    '''
    sections = misc.getSiteSections(current_section)
    selected_provider_id = int(selected_provider_id)
    
    g = GeoIP()
    notsupported = 0;
    peers = connector.getPeerInfo(selected_provider_id)
    if 'error' in peers :
        peers = {}
        notsupported = 1
    else :
        for peer in peers:
            info = g.city(peer['addr'].partition(':')[0])
            if info is None:
                info = {}
            peer['ip'] = peer['addr'].partition(':')[0]
            peer['port'] = peer['addr'].partition(':')[2]
            peer['country'] = info.get('country_name', "")
            peer['country_code'] = info.get('country_code', "")
            peer['city'] = info.get('city', None) if info.get('city', None) != None else ''
            peer['lat'] = info.get('latitude', "");
            peer['lon'] = info.get('longitude', "");
            peer['subver'] = peer['subver'].replace("/", "")
            peer['in'] = misc.humanBytes(peer['bytesrecv']) if 'bytesrecv' in peer else 'N/A'
            peer['out'] = misc.humanBytes(peer['bytessent']) if 'bytessent' in peer else 'N/A'
            peer['lastsend'] = misc.twitterizeDate(peer['lastsend']) if 'lastsend' in peer else 'N/A'
            peer['lastrecv'] = misc.twitterizeDate(peer['lastrecv']) if 'lastrecv' in peer else 'N/A'
            peer['conntime'] = misc.timeSince(peer['conntime']) if 'conntime' in peer else 'N/A'
            peer['syncnode'] = peer['syncnode'] if 'syncnode' in peer else False
    
    currency_codes = {}
    currency_names = {}
    currency_symbols = {}
    for provider_id in connector.config:
        currency_names[provider_id] = connector.config[provider_id]['name']
        currency_symbols[provider_id] = connector.config[provider_id]['symbol']
        currency_codes[provider_id] = connector.config[provider_id]['currency']
    
    currency_codes = sorted(currency_codes)
    
    page_title = _("Network")
    context = {
               'globals': MainConfig['globals'],
               'breadcrumbs': misc.buildBreadcrumbs(current_section, '', currency_names[selected_provider_id]),
               'system_errors': connector.errors,
               'system_alerts': connector.alerts,
               'page_title': page_title,
               'page_sections': sections,
               'request': request,
               'currency_codes': currency_codes,
               'currency_names': currency_names,
               'currency_symbols': currency_symbols,
               'selected_provider_id': selected_provider_id,
               'peers': peers,
               'notsupported': notsupported
               }
    return render(request, 'network/index.html', 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 getLastActivity(self):
        '''
        Return the date of the last activity
        '''
        last_transaction = self.listTransactions(1, 0)
        if last_transaction:
            last_activity = misc.twitterizeDate(last_transaction[0]['time'])
        else:
            last_activity = "never"

        self['last_activity'] = last_activity
        return last_activity
Ejemplo n.º 4
0
 def getLastActivity(self):
     '''
     Return the date of the last activity
     '''
     last_transaction = self.listTransactions(1, 0)
     if last_transaction:
         last_activity = misc.twitterizeDate(last_transaction[0]['time'])
     else:
         last_activity = "never"
         
     self['last_activity'] = last_activity
     return last_activity
Ejemplo n.º 5
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.º 6
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.º 7
0
def index(request):
    '''
    Handler for the dashboard main page
    '''
    currect_section = 'dashboard'
    
    # set the request in the connector object
    connector.request = request
    
    # get all wallets
    wallets = getWallets(connector)

    # more efficient if we do only one call
    transactions = []
    for wallet in wallets:
        transactions = transactions + wallet.listTransactions(5, 0)
    
    # sort result
    transactions = sorted(transactions, key=lambda k: k.get('time', 0), reverse=True)
    
    # get only 10 transactions
    transactions = transactions[0:5]

    # events
    list_of_events = Events.objects.all().order_by('-entered')[:5]  
    for single_event in list_of_events:
        timestamp = calendar.timegm(single_event.entered.timetuple())
        single_event.entered_pretty = misc.twitterizeDate(timestamp)
    
    page_title = "Dashboard"
    sections = misc.getSiteSections('dashboard')
    context = {
               'globals': MainConfig['globals'],
               'system_errors': connector.errors,
               'system_alerts': connector.alerts,
               'request': request,
               'breadcrumbs': misc.buildBreadcrumbs(currect_section),
               'page_title': page_title,
               'page_sections': sections,
               'wallets': wallets,
               'transactions': transactions,
               'events': list_of_events
               }
    return render(request, 'dashboard/index.html', context)
Ejemplo n.º 8
0
def index(request):
    '''
    Handler for the dashboard main page
    '''
    currect_section = 'dashboard'
    
    # set the request in the connector object
    connector.request = request
    
    # get all wallets
    wallets = getWallets(connector)

    # more efficient if we do only one call
    transactions = []
    for wallet in wallets:
        transactions = transactions + wallet.listTransactions(5, 0)
    
    # sort result
    transactions = sorted(transactions, key=lambda k: k.get('time', 0), reverse=True)
    
    # get only 10 transactions
    transactions = transactions[0:5]

    # events
    list_of_events = Events.objects.all().order_by('-entered')[:5]  
    for single_event in list_of_events:
        timestamp = calendar.timegm(single_event.entered.timetuple())
        single_event.entered_pretty = misc.twitterizeDate(timestamp)
    
    page_title = "Dashboard"
    sections = misc.getSiteSections('dashboard')
    context = {
               'globals': MainConfig['globals'],
               'system_errors': connector.errors,
               'system_alerts': connector.alerts,
               'request': request,
               'breadcrumbs': misc.buildBreadcrumbs(currect_section),
               'page_title': page_title,
               'page_sections': sections,
               'wallets': wallets,
               'transactions': transactions,
               'events': list_of_events
               }
    return render(request, 'dashboard/index.html', context)
Ejemplo n.º 9
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.º 10
0
def index(request, selected_provider_id=sorted(connector.config.keys())[0]):
    '''
    Handler for the accounts
    '''
    sections = misc.getSiteSections(current_section)
    selected_provider_id = int(selected_provider_id)

    g = GeoIP()
    notsupported = 0
    peers = connector.getPeerInfo(selected_provider_id)
    if 'error' in peers:
        peers = {}
        notsupported = 1
    else:
        for peer in peers:
            info = g.city(peer['addr'].partition(':')[0])
            if info is None:
                info = {}
            peer['ip'] = peer['addr'].partition(':')[0]
            peer['port'] = peer['addr'].partition(':')[2]
            peer['country'] = info.get('country_name', "")
            peer['country_code'] = info.get('country_code', "")
            peer['city'] = info.get(
                'city', None) if info.get('city', None) != None else ''
            peer['lat'] = info.get('latitude', "")
            peer['lon'] = info.get('longitude', "")
            peer['subver'] = peer['subver'].replace("/", "")
            peer['in'] = misc.humanBytes(
                peer['bytesrecv']) if 'bytesrecv' in peer else 'N/A'
            peer['out'] = misc.humanBytes(
                peer['bytessent']) if 'bytessent' in peer else 'N/A'
            peer['lastsend'] = misc.twitterizeDate(
                peer['lastsend']) if 'lastsend' in peer else 'N/A'
            peer['lastrecv'] = misc.twitterizeDate(
                peer['lastrecv']) if 'lastrecv' in peer else 'N/A'
            peer['conntime'] = misc.timeSince(
                peer['conntime']) if 'conntime' in peer else 'N/A'
            peer[
                'syncnode'] = peer['syncnode'] if 'syncnode' in peer else False

    currency_codes = {}
    currency_names = {}
    currency_symbols = {}
    for provider_id in connector.config:
        currency_names[provider_id] = connector.config[provider_id]['name']
        currency_symbols[provider_id] = connector.config[provider_id]['symbol']
        currency_codes[provider_id] = connector.config[provider_id]['currency']

    currency_codes = sorted(currency_codes)

    page_title = _("Network")
    context = {
        'globals':
        MainConfig['globals'],
        'breadcrumbs':
        misc.buildBreadcrumbs(current_section, '',
                              currency_names[selected_provider_id]),
        'system_errors':
        connector.errors,
        'system_alerts':
        connector.alerts,
        'page_title':
        page_title,
        'page_sections':
        sections,
        'request':
        request,
        'currency_codes':
        currency_codes,
        'currency_names':
        currency_names,
        'currency_symbols':
        currency_symbols,
        'selected_provider_id':
        selected_provider_id,
        'peers':
        peers,
        'notsupported':
        notsupported
    }
    return render(request, 'network/index.html', context)