Send Reminder Email using Django - django

I have a model of student with event date time and student's email field.
I want to send a reminder email 12hours before event time to student's email. What are the ways to achieve this?

You'll need a scheduler for this. Celery is one of the most popular tools used for such tasks with Django.
With celery, you can set a certain task to run at a given time like so:
send_reminder_email.apply_async(eta=datetime_object)
You can read more details here: http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

Related

How to configure alerts for employee contract expiration in odoo

How do i configure the system to email me when an employees contract is going to expire? For example I need to get an email 30 days before the expiration. i tried to create an automated action following some tutorial but i don't find the filed Timer Trigger Date and Delay After Trigger Date in odoo 8 any help please ?
hr_contract model have end date_end based on that write corn job or what ever you want

Scheduling/Queueing Tasks Django/Celery

I'd like to add a scheduling option to allow user to manually input a date and time that would delay their post to be published to that specific date/time. So if the user uploads five posts in one day but only wants to publish one per day, then they could input a specific date and time for each post to be published (i.e. Post #1 publish on 1/8/18 3:30pm, Post #2 publish on 1/13/18 4:00pm, etc.)
Thinking about using Celery to approach this problem. Having trouble visualizing how to connect Celery Tasks to the Post Form (or Model) so user can have the option to adjust the timing according to their scheduling needs. If you could explain with visual examples and where the examples are taking place (i.e. views.py, etc.) that would be greatly appreciated. Thanks!

Managing identifiers when offline in an event sourced system

I have an event sourced system that runs on a server with clients that need to work offline from time to time. To make this work I have the domain events streamed from the server to the client when online so that the offline database is up to date in case the client goes offline. This works just fine.
When offline the user might add a new customer with the following sequence...
Add new customer command.
Customer aggregate added.
Customer aggregate creates initial appointment aggregate.
Query of read data returns new appointment details.
Command used to modify the appointment.
When back online I cannot reply the events for the server. Adding the new customer is fine but the resultant new appointment has an identifier I do not know about. So trying to replay the appointment update command fails because I have no idea what the correct appointment id should be.
Any ideas?
You need to review Greg Young's talk CQRS, not just for server systems.
Also Stack overflow question Occasionally Connected CQRS Systems, and the dddcqrs topic Merging Events in Occasionally Connected Clients.
I have no idea what the correct appointment id should be
Generate the ids when you generate the commands; you'll know what the appointment id is going to be, because you told the customer aggregate what id to use when creating the appointment.

Any job queue systems that allow scheduling jobs by date?

I have a Django application.
One of my models looks like this:
class MyModel(models.Model):
def house_cleaning(self):
// cleaning up data of the model instance
Every time when I update an instance of MyModel, I'd need to clean up the data N days later. So I'd like to schedule a job to call
this_instance.house_cleaning()
N days from now.
Is there any job queue that would allow me to:
Integrate well with Django - allow me to call a method of individual model instances
Only run jobs that are scheduled to run today
Ideally handle failures gracefully
Thanks
django-chronograph might be good for your use case. If you write your cleanup jobs as django commands, then you schedule them to run at some time. It runs using unix cron behind the scene.
Is there any reason why a cron job wouldn't work? Or something like django-cron that behaves the same way? It's pretty easy to write stand-alone Django scripts. If you want to trigger house cleaning on some change to you model after a certain number of days, why not create a date flag in the model which is set to N days in the future when the job needs to be scheduled? You could run a script on a daily basis which pulls all records where the date is <= today, calls the instance's house_cleaning() method and then clears the date field. If an exception is raised during the process, it's easy enough to log it or dispatch an email.

Automatic email notifications based on date in django

I have to implement a way to send automatic notification emails based on a model DateFields. I'll put an example.
I have a DateField with 2010-07-23 stored in it and I want django to send an email to a designated user when the current date reaches a week before (send it in 2010-07-16). Is there any way to accomplish this?
You'll need to set up an external job, probably triggered via cron, that checks the date and sends the email as necessary.