add new notif task to tell sellers about item statuses every few days and add num of bids in listing
parent
1fad3cb762
commit
fc2e876ce0
@ -1 +1 @@
|
||||
from items.tasks import cleanup
|
||||
from items.tasks import cleanup, notifications
|
@ -0,0 +1,21 @@
|
||||
from logging import getLogger
|
||||
from huey import crontab
|
||||
from huey.contrib.djhuey import periodic_task
|
||||
from core.helpers.email_template import EmailTemplate
|
||||
from items.models import Item
|
||||
|
||||
|
||||
logger = getLogger('django.server')
|
||||
|
||||
@periodic_task(crontab(minute='0', hours='0', days='*/2'))
|
||||
def notify_seller_of_item_bids():
|
||||
items = Item.objects.all()
|
||||
for item in items:
|
||||
if len(item.bids.all()) > 0:
|
||||
logger.info(f'[INFO] Item #{item.id} has some bids. Notifying the seller.')
|
||||
email_template = EmailTemplate(
|
||||
item=item,
|
||||
scenario='item_has_bids',
|
||||
role='seller'
|
||||
)
|
||||
email_template.send()
|
@ -0,0 +1,9 @@
|
||||
Congratulations {{ item.owner }},
|
||||
|
||||
Your item, "{{ item.name }}" (#{{ item.id }}), has received {{ item.bids.values | length }} bid(s).
|
||||
|
||||
Please review the bids whenever you can. A link to the item is below:
|
||||
|
||||
https://{{ site_url }}{{ item_path }}
|
||||
|
||||
Thanks for using {{ site_name }}!
|
@ -0,0 +1 @@
|
||||
[{{ site_name }}] Bids Received! (#{{ item.id }})
|
Reference in New Issue