add new notif task to tell sellers about item statuses every few days and add num of bids in listing

pull/3/head
lance 5 years ago
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()

@ -33,6 +33,7 @@
<th>List Date</th> <th>List Date</th>
<th>Whereabouts</th> <th>Whereabouts</th>
<th>Asking Price (XMR)</th> <th>Asking Price (XMR)</th>
<th>Bids</th>
</tr> </tr>
{% for item in items %} {% for item in items %}
<tr class="{% if item.owner == request.user %}item-mine{% endif %}"> <tr class="{% if item.owner == request.user %}item-mine{% endif %}">
@ -48,6 +49,7 @@
<td>{{ item.list_date | date:"d M, Y H:i:s" }}</td> <td>{{ item.list_date | date:"d M, Y H:i:s" }}</td>
<td><a href="https://duckduckgo.com/?q={{ item.whereabouts }}" target="_blank">{{ item.whereabouts }}</a></td> <td><a href="https://duckduckgo.com/?q={{ item.whereabouts }}" target="_blank">{{ item.whereabouts }}</a></td>
<td>{{ item.ask_price_xmr }}</td> <td>{{ item.ask_price_xmr }}</td>
<td>{{ item.bids.all | length }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

@ -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 }})