Automatic email notifications based on date in django - 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.

Related

How to create a workflow in 2013 to send multiple email in a month

I want to create a Designer Workflow in 2013 which will trigger the email automatically for 5 times in a month. List is same but the calculation and logic is different for every email. First time, i can initiate the process to send the email (ex-creating a button to initiate) then email will be sent after 2 days then after 4 days resp
For this, i used 2 things-
HTTP Web Service call- but it is giving me unexpected error. Even I am not able to fetch the list records.
created a JavaScript with set Timeout function. But the problem is How and where to deploy and schedule this script so it will run till the last email and trigger it automatically after some days based on the logic.
can anyone help me please?
or if there are any other solution, please share.
You cannot put JavaScript into a workflow. SharePoint Designer 2013 Workflows have two built-in actions that will allow you to make it wait for a specified time.
Pause for Duration - allows you to specify a length of time to wait before executing the next step.
Pause until Date - allows you to specify a specify date/time in the future that the workflow should pause until that that date/time is reached.

Send Reminder Email using 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

send periodic notification using aws sns and lambda

I have the following use case scenario for which I am considering aws services to see how I can come up with a scalable solution. Thanks in advance for your help!
Scenario:
Users can sign up to an application(which is named say 'Let's Remind' or something else) using their email and phone.
The app does one thing that is to send email and sms alerts to user.
User can create n number of tasks for which he wants to be reminded. For instance he can set up a
monthly reminder for paying card dues. Currently the value of n is from 5 to 10 per user.
The notifications are flexible meaning it can be daily, weekly, monthly, bi-weekly. User can also
specify the start date of a notification. The end date is the date when the event is due (for instance
the day the card payment is due). Once this date is expired the notification is rendered inactive for
the current month.
For weekly,daily,bi-weekly notifications, the notifications are deleted once the event date is passed.
These are not recurring in nature.
For monthly recurring events such as payment of apartment rent etc, notification itself is not
deleted but rendered inactive after the event due date. Once the next event cycle (typically next
month billing cycle for payments use case) starts, the notification comes back to life and starts all
over again.
Use can delete any event anytime he wants. If an event is deleted, the notifications for that event
will be deleted as well.
First of all, I hope the use case is clear. Now here's my thoughts so far about solving this use case -
1) Use SNS since I need to send email and sms both. SES only supports emails.
2) When a user registers for the app, create 2 subscriptions(one for his email and one for his sms endpoint) and also create a topic for the user(maybe a dynamically generated random userid)
3) Once user creates an event (e.g. reminder for monthly apartment rental), store the event data such as userid, startdate, duedate, frequency, isactive in a dynamodb table.
4) Create a lambda function that will wake up when an entry is written to the dynamodb table (step 3); it will do the following -
i) it will read the event data from the dynamodb table
ii) determine the next date of the notification to be sent based on the current date and event
data
iii) For active events (check isActive column of the dynamodb record) create a scheduled cron
expression rule based on ii above in cloudwatch events and add the
target as the user's topic (created in step 2 above). For now, the notification message is
static.
I have some doubts/queries about step iii -
Is it possible to create cloudwatch event cron rule dynamically and add the user's topic as target dynamically as I described? Or is it better to trigger a second lambda function dedicated for sending messages to the user's topic using SNS notification? Which approach will be better for this use case?
If user base grows large, is it recommended to create one topic per user?
Am I on the right track with my approach above in general from a scalability point of view?
If not, can anyone suggest any better idea for implementing this use case?
Thanks in advance!
This will not work.
For SNS email subscriber to receive email notification sent via SNS it has to first confirm the subscription. You cannot just create subscriptions on the fly and send them email notification
I don't think SNS fits your use case. You would be better off sending email notifications using SES.
You can write your scheduling logic in Lambda though

django specific url/view that wont modify the session expiry date?

As I see each time the session is changed, i.e request.session['last_date'] = datetime.datetime.now() for example, the expiry_date is changed too.
Can I create an exception for that? I want to use the expiry_date as a timeout for the session, but I have a JS code in the client which send requests every few minutes, thus always extend the session expiry_date.
I want a way (simple, I hope) to write to the session without extending this date.
You can use the session.set_expiry function to set a custom expiry date, which will not be extended after modifying the session.

post event to facebook with place page id

via the graph api, I create events for facebook pages I have the create_event and manage_pages privileges for.
I post to https://graph.facebook.com/pageId/events with the usual name, location, start_time, street, city parameters. Works perfectly.
However, I haven't found a way to submit a certain place_id for the event (e.g. FB-ID of the venue). This is possible using the web client. When creating an event, you can select a place/venue, the resulting event page shows that place on the map and links to the place page. Events created via the api only show the location name as text.
I tried place_page_id and several others as parameters, but nothing worked.
Has anybody done that successfully?
Thanks
Yes, you can. A poorly documented property of Event is location_id. Works fine.
The way I handle it is to search for type=place and if I find the place in the vast Facebook data store I use the id of that place in the location_id field. If I don't find the right place I use the information I have for street and city. (If you have location_id you really don't need street and city).
No with the current API it is not possible. Here's the only parameters for creating an event available. They are the same for user events as well as page events.
name (string)
start_time (timestamp)
end_time (timestamp)
description (string)
location (string)
privacy_type (string)