Time Based Reminder Email in Django - django

I want incorporate a timed based reminder email of the events for the day in django. Basically I have a model which has all the events (including the date of the event). I want to send emails to concerned people at around 8.00 AM in the morning of each day about the events for the day. How do I incorporate this is django?
Thanks

I reckon a custom management command to send the alerts, commanded by django-chronograph should do the trick

I wrote a database-backed email queue, to send out emails from a single django install and not have to worry about SMTP throttling and whatnot. It's dead simple -- one model class for the email with a sendit() method, and a command-line script to flush the queue, which I run with cron.
http://gist.github.com/629663

Related

Cron for sending emails after 3 days in django

I dont have any knowledge about the cron. In my project once the task is assigned to employee email is sent to his mailid. If the employee does not complete the task within deadline I want to send the mail after every 3 days to complete the task. Can anyone give me I idea what I should do. The project is on my local environment, does it support or I should take server.
apscheduler would do the job
It would look like this
bg_scheduler = BackgroundScheduler()
bg_scheduler.add_job(send_email, 'interval', days=3)
bg_scheduler.start()

How to perform non-idempotent actions (send email) in a Actor model framework (e.g., akka.net)?

I am looking into using an actor model framework (akka.net with akka.net persistence, but I am looking for a general case answer) to build an 'widget order processing workflow'.
Pretty standard:
Customer orders widget
Payment is processed
Email confirmation sent to customer
Send picklist message to warehouse
Warehouse sends a 'widget has been shipped' message back
Send a 'your item has shipped' email to customer
Now let's say between 4 and 5 a server deployment/restart happens. This would cause a actor(s) rehydration (let's assume there is no snapshot yet). That means we would process the payment again, and resend the order placed email. However it turns out our customers don't like this 'feature'!
How to I prevent non-idempotent actions from re-occurring when using an actor model framework?
I have thought about having a separate store of 'payment processed for order db table'; but this feels like I am fighting the framework/paradigm and I wonder if there is a 'proper' way of doing this kind of thing!
Ok so it turns out it is pretty simple.
With akka.net persistence, after a system restore, messages are replayed. The correct state can be recreated by (re) processing these messages.
There is however a IsRestoring property, which can be checked to see if this is the first or a subsequent processing. Presumably other actor model framework have something similar.
So you do something like:
private void ProcessPayment (Order message)
{
if(!this.IsRestoring){
//Perform non-idempotent payment process
}
}
To make a robust workflow processor, you have to store ALL data of a workflow process in a permanent storage.
You can employ a database, a messaging system like Kafka, or use ready-made workflow management software.
Since you already use Akka, Akka Persistence also can be an option.
UPDATE
Building a system which continue to work correctly in presence of system failures and restarts is a considerable task, far more complex than developing an actor framework. That is, you cannot just take any actor framework and add fault tolerance to it.

Django Priority Queue

I want to build a delivery app in Django, wherein I will create delivery objects to be delivered according to priority(attribute of the object) by a delivery person. I will login and create the tasks and there can be many delivery persons to login and accept task asynchronously.
Objects(tasks) will be popped out as a delivery person logs in and accepts the task, and the next logged in delivery person would see the next priority task.
How can this be implemented in Django? Any references and implementation links are welcomed. Thanks in advance!

Django: Send reminder email

my app has list of events with start time (date and time). I want to make a scheduled task to send reminder via email to all user participate in event 1 hour before event start. (Note: Admin can change time of event).
I currently use celery to send email to list of participants when admin change the time of event.
Please suggest me some solution for this. Thanks.
Here's a recent(ish) discussion where a potential solution is proposed for celery: https://github.com/celery/celery/issues/4522.
I built Posthook to make solving these kinds of problems easier for developers. In your case, when a new event is created or the event time changes you can schedule a request back to your app for 1 hour before the start time. Then when you get the request from Posthook you can send out the reminder after validating that it still needs to be sent out.

How to use Akka with transactions across email and database?

I have a situation where I have a component with a list of users. I need to send an email to each user, and then update the user's record to indicate the time when the email was sent.
This seems like a good first use-case for Akka. I was thinking the component that gets the list of users would be an Actor, and a separate Actor would be created for each outbound email-sending Actor, which could be multithreaded. The email-sending Actor would be responsible for updating the date in the user record.
If the email-sending Actor failed, the user's record wouldn't be done, and the supervising Actor would be able to reschedule it.
Is that the right model? Or should the supervisor be responsible for updating the user record?
Or is this a bad use-case for Akka completely?
BTW, I could send mail via SMTP or a web service. I don't think it matters much for the discussion, but I thought I'd mention it.
I don't think you should get hung up on transactionality when there's IO involved. You have no guarantees that the emails will be read, received, received by the right person, received within a certain period of time, be understood etc.
Just send the email and then update the database.
Happy hAkking!