Skip to content
Snippets Groups Projects
Commit 7f21fcc7 authored by Fabian Krüger's avatar Fabian Krüger
Browse files

update backend: now supporting getLastChargesList

parent 4097f9df
No related branches found
No related tags found
No related merge requests found
......@@ -194,3 +194,20 @@ class PurchaseLogic:
user.updateMoney(purchase.price)
print("user_id:", user.id, "purchase_id:", purchase.id, "user.money:", user.money)
class ChargeLogic:
"""
Returns a list of the last charges of a specified user: [{'id': ..., 'amount': ...}, Decimal(...,...)]
@param user_id: the id of the specified user
@config-param max_charges: Number of charges to be shown. Depends on N_LAST_CHARGES
"""
def getLastChargesList(user_id):
max_charges = config['N_LAST_CHARGES']
charges = Charge.objects.filter(user=user_id).values('id', 'amount')
if max_charges < 0:
charges = list(charges.order_by('time_stamp').reverse())
else:
charges = list(charges.order_by('time_stamp').reverse())[:max_charges]
return charges
......@@ -5,8 +5,10 @@ T_ANNULLABLE_PURCHASE_M: time of minutes a user has for a purchase to undo it
N_MOST_BOUGHT_PRODUCTS: number of products to be shown in 'Häufig gekauft'
T_MOST_BOUGHT_PRODUCTS_D: number of days in the past that are used as time intervall limit to search for 'Häufig gekauft'
N_USERS_LOGIN: number of users that should be shown in the users list in the login-screen. A negative number means
'all users are selected'
'all users are selected'
T_USERS_LOGIN_D: number of days in the past that are used as time intervall limit to search for users
N_LAST_CHARGES: number of charges that should be shown in 'Letzte Aufladungen'. A negative number means 'all users are
selected'
"""
KAFFEEKASSE = {'N_LAST_BOUGHT_PRODUCTS': 5,
'T_LAST_BOUGHT_PRODUCTS_D': 30,
......@@ -15,4 +17,5 @@ KAFFEEKASSE = {'N_LAST_BOUGHT_PRODUCTS': 5,
'T_MOST_BOUGHT_PRODUCTS_D': 30,
'N_USERS_LOGIN': -1,
'T_USERS_LOGIN_D': 356,
'N_LAST_CHARGES': -1,
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment