Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Kaffeekasse 2000XT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lehrstuhl für Informatik 4 (Systemsoftware)
PASST
Projekte
Kaffeekasse 2000XT
Commits
0ddc680b
Commit
0ddc680b
authored
5 years ago
by
Fabian Krüger
Browse files
Options
Downloads
Patches
Plain Diff
backend now supports a transfer function
parent
d7702a77
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
store/backend.py
+33
-0
33 additions, 0 deletions
store/backend.py
store/store_config.py
+3
-0
3 additions, 0 deletions
store/store_config.py
with
36 additions
and
0 deletions
store/backend.py
+
33
−
0
View file @
0ddc680b
...
@@ -321,3 +321,36 @@ class TransferLogic:
...
@@ -321,3 +321,36 @@ class TransferLogic:
if
max_receivers
>=
0
:
if
max_receivers
>=
0
:
transfers
=
transfers
[:
max_receivers
]
transfers
=
transfers
[:
max_receivers
]
return
list
(
transfers
)
return
list
(
transfers
)
"""
Performs the transfer routine where a sender sends money to a receiver.
@param user_id: id of the user that wants to send money
@param receiver_id: id of the user that should get the money
@param amount: amount of money to be sent
@param token: unique token got by TokenLogic
'
s getToken
"""
@staticmethod
def
transfer
(
user_id
,
receiver_id
,
amount
,
token
):
sender
=
list
(
User
.
objects
.
filter
(
id
=
user_id
))[
0
]
receiver
=
list
(
User
.
objects
.
filter
(
id
=
receiver_id
))[
0
]
try
:
with
transfer
.
atomic
():
transfer_id
=
TransferLogic
.
__createTransferTuple
(
sender
,
receiver
,
amount
,
token
)
TransferLogic
.
__updateSenderMoney
(
sender
,
amount
)
TransferLogic
.
__updateReceiverMoney
(
receiver
,
amount
)
except
IntegrityError
:
return
list
(
Transfers
.
objects
.
filter
(
token
=
token
))[
0
]
return
transfer_id
def
__createTransferTuple
(
sender
,
receiver
,
amount
,
token
):
transfer
=
Transfer
(
sender
=
sender
,
receiver
=
receiver
,
amount
=
amount
,
token
=
token
,
annulated
=
False
)
transfer
.
save
()
return
transfer
.
id
def
__updateSenderMoney
(
sender
,
amount
):
sender
.
updateMoney
((
-
1
)
*
amount
)
def
__updateReceiverMoney
(
receiver
,
amount
):
receiver
.
updateMoney
(
amount
)
This diff is collapsed.
Click to expand it.
store/store_config.py
+
3
−
0
View file @
0ddc680b
...
@@ -10,6 +10,8 @@ T_USERS_LOGIN_D: number of days in the past that are used as time intervall limi
...
@@ -10,6 +10,8 @@ T_USERS_LOGIN_D: number of days in the past that are used as time intervall limi
N_LAST_CHARGES: number of charges that should be shown in
'
Letzte Aufladungen
'
. A negative number means
'
all users are
N_LAST_CHARGES: number of charges that should be shown in
'
Letzte Aufladungen
'
. A negative number means
'
all users are
selected
'
selected
'
T_ANNULLABLE_CHARGE_M: time of minutes a user has for a charge to undo it
T_ANNULLABLE_CHARGE_M: time of minutes a user has for a charge to undo it
N_TRANSFER_RECEIVERS: number of receivers that should be shown in
'
alle Überweisungen
'
. A negative value means
'
all
users are shown
'
"""
"""
KAFFEEKASSE
=
{
'
N_LAST_BOUGHT_PRODUCTS
'
:
5
,
KAFFEEKASSE
=
{
'
N_LAST_BOUGHT_PRODUCTS
'
:
5
,
'
T_LAST_BOUGHT_PRODUCTS_D
'
:
30
,
'
T_LAST_BOUGHT_PRODUCTS_D
'
:
30
,
...
@@ -20,4 +22,5 @@ KAFFEEKASSE = {'N_LAST_BOUGHT_PRODUCTS': 5,
...
@@ -20,4 +22,5 @@ KAFFEEKASSE = {'N_LAST_BOUGHT_PRODUCTS': 5,
'
T_USERS_LOGIN_D
'
:
356
,
'
T_USERS_LOGIN_D
'
:
356
,
'
N_LAST_CHARGES
'
:
10
,
'
N_LAST_CHARGES
'
:
10
,
'
T_ANNULLABLE_CHARGE_M
'
:
60
,
'
T_ANNULLABLE_CHARGE_M
'
:
60
,
'
N_TRANSFER_RECEIVERS
'
:
-
1
,
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment