Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
frozen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSE6
frozen
Commits
b0cb6afe
Commit
b0cb6afe
authored
2 years ago
by
Arno Wunderlich
Browse files
Options
Downloads
Patches
Plain Diff
use reference currency in notifications
parent
6b017c3f
No related branches found
Branches containing commit
No related tags found
1 merge request
!63
Small fixes 2002
Pipeline
#16026
passed
2 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tjts5901/views.py
+19
-20
19 additions, 20 deletions
src/tjts5901/views.py
with
19 additions
and
20 deletions
src/tjts5901/views.py
+
19
−
20
View file @
b0cb6afe
...
@@ -84,20 +84,14 @@ def get_item_price(item: Item) -> int:
...
@@ -84,20 +84,14 @@ def get_item_price(item: Item) -> int:
def
check_auction_ends
():
def
check_auction_ends
():
"""
"""
Check if all previously not processed auctions have ended now
Check if all previously not processed auctions have ended now
Get all closed items, check if they belong to the current user and inform about
Get all closed items, process all bids on these items and check if they won
the ending of the auction.
Then check if current_user needs to be informed
Then process all bids on these items and check if they won
"""
"""
items
=
Item
.
objects
.
filter
(
Q
(
closes_at
=
datetime
.
utcnow
())
&
Q
(
closed_processed
=
False
))
\
items
=
Item
.
objects
.
filter
(
Q
(
closes_at
__lte
=
datetime
.
utcnow
())
&
Q
(
closed_processed
=
False
))
\
.
order_by
(
'
-closes_at
'
)
.
order_by
(
'
-closes_at
'
)
for
item
in
items
:
for
item
in
items
:
item
.
update
(
closed_processed
=
True
)
item
.
update
(
closed_processed
=
True
)
message
=
None
if
item
.
seller
==
current_user
:
message
=
"
The auction of your item
\'
{}
\'
has ended.
"
.
format
(
item
.
title
)
item
.
update
(
seller_informed_about_result
=
True
)
# Get (potential) bids for the item and process them
# Get (potential) bids for the item and process them
bids
=
Bid
.
objects
(
item
=
item
).
order_by
(
'
-amount
'
)
bids
=
Bid
.
objects
(
item
=
item
).
order_by
(
'
-amount
'
)
...
@@ -111,19 +105,24 @@ def check_auction_ends():
...
@@ -111,19 +105,24 @@ def check_auction_ends():
bid
.
update
(
winning_bid
=
False
)
bid
.
update
(
winning_bid
=
False
)
bid
.
update
(
auction_end_processed
=
True
)
bid
.
update
(
auction_end_processed
=
True
)
# Inform seller if this is current user
# Inform current user about results of his auctions
if
item
.
seller
==
current_user
:
items_closed
=
Item
.
objects
.
filter
(
Q
(
closed_processed
=
True
)
&
Q
(
seller_informed_about_result
=
False
)
\
message
+=
"
Congrats! It was sold for {}.
"
.
format
(
bids
[
0
].
amount
)
&
Q
(
seller
=
current_user
))
message
=
None
# Inform current user if no one bid on the item
for
item
in
items_closed
:
else
:
# Get (potential) bids for the item and process them
if
item
.
seller
==
current_user
:
message
=
"
The auction of your item
\'
{}
\'
has ended.
"
.
format
(
item
.
title
)
message
+=
"
No one bid on your item. Try again!
"
bids
=
Bid
.
objects
(
item
=
item
).
order_by
(
'
-amount
'
)
if
len
(
bids
)
>=
1
:
message
+=
"
Congrats! It was sold for {}.
"
.
format
(
bids
[
0
].
amount
)
else
:
message
+=
"
No one bid on your item. Try again!
"
item
.
update
(
seller_informed_about_result
=
True
)
#Display message if not None
#Display message if not None
if
message
is
not
None
:
if
message
is
not
None
:
flash
((
message
))
flash
((
message
))
def
check_bids_ended
():
def
check_bids_ended
():
"""
"""
...
...
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