Пример #1
0
 def create_wallets(self):
     for currency in Currency.get_all_currency_chars():
         _, created = Wallet.objects.get_or_create(user=self,
                                                   currency=currency)
         if not created:
             logging.warning(
                 "Wallet with currency %s already existed for user %s" %
                 (currency, self))
Пример #2
0
 def get(self, request, *args, **kwargs):
     data = {
         "wallets": [{
             "name":
             currency.sign,
             "credit":
             get_dollarial_company().get_credit(currency.char)
         } for currency in Currency.get_all_currencies()]
     }
     return render(request, 'admin_panel/admin_index.html', data)
Пример #3
0
 def test_fields_content(self):
     self.login()
     self.__create_transactions()
     transactions = self.__get_transaction()
     page = self.__get_page()
     for i in range(3):
         self.assertIn(str(transactions[i].transaction_id), self.__get_text(page.id[i]))
         self.assertIn(str(transactions[i].transaction_amount), self.__get_text(page.amount[i]))
         self.assertIn(Currency.get_by_char(transactions[i].transaction_currency[0]).sign,
                       self.__get_text(page.currency[i]))
         self.assertIn(str(transactions[i].transaction_wage), self.__get_text(page.wage[i]))
         self.assertIn(transactions[i].transaction_owner.username, self.__get_text(page.owner[i]))
         self.assertIn(transactions[i].transaction_status, self.__get_text(page.status[i]))
         self.assertIn(str(transactions[i].transaction_deleted), self.__get_text(page.deleted[i]))
Пример #4
0
 def get_wallet(self, currency):
     if currency not in Currency.get_all_currency_chars():
         logging.error("No such kind of currency %s" % currency)
         return None
     return Wallet.objects.get_or_create(user=self, currency=currency)[0]
Пример #5
0
 def currency_sign(self):
     return Currency.get_by_char(self.currency).sign
Пример #6
0
def update_credit_all(user):
    for c in Currency.get_all_currency_chars():
        update_credit(user, c)