Jelajahi Sumber

Fix missing loans

Eren Yilmaz 5 tahun lalu
induk
melakukan
1a6ddc294b
1 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 6 1
      server_controller.py

+ 6 - 1
server_controller.py

@@ -125,7 +125,8 @@ def order(json_request):
 
     if sell:
         if not model.user_has_at_least_available(amount, user_id, ownable_id):
-            return BadRequest('You can not sell more than you own (this also takes into account existing sell orders and, if you are a bank, required minimum reserves at the ).')
+            return BadRequest('You can not sell more than you own (this also takes into account existing '
+                              'sell orders and, if you are a bank, required minimum reserves at the ).')
     try:
         expiry = model.current_db_timestamp() + timedelta(minutes=time_until_expiration).total_seconds()
     except OverflowError:
@@ -250,6 +251,7 @@ def buy_banking_license(json_request):
 def news(_json_request):
     return {'data': model.news()}
 
+
 def tender_calendar(_json_request):
     return {'data': model.tender_calendar()}
 
@@ -323,6 +325,9 @@ def repay_loan(json_request):
     amount = json_request['amount']
     user_id = model.get_user_id_by_session_id(json_request['session_id'])
     loan_id = json_request['loan_id']
+    if not model.user_has_loan_with_id(user_id, loan_id, ):
+        raise NotFound('Unknown loan ID.')
+
     if amount == 'all':
         amount = model.loan_remaining_amount(loan_id)
     if amount < 0: