This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25231b7
commit 97a6d46
Showing
13 changed files
with
218 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .base import * | ||
|
||
SCHEDULER_AUTOSTART = False | ||
DEBUG = True | ||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG | ||
|
||
|
16 changes: 16 additions & 0 deletions
16
systers_portal/templates/community/weekly_digest_email.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
</head> | ||
<body> | ||
Hey {{user}}, We have details for {{community}} for you. | ||
We have {{count}} members as of now!. Get the latest news and resources available at the community | ||
by checking out the Systers Portal. <br> | ||
Thank You, <br> | ||
AnitaB.org | ||
</body> | ||
</html> |
15 changes: 15 additions & 0 deletions
15
systers_portal/templates/meetup/location_change_email.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
</head> | ||
<body> | ||
Hello {{user}},<br> | ||
<p>This is to inform you that the location for {{meetup}} has been changed to {{meetup.meetup_location}}<br></p> | ||
Thank You,<br> | ||
AnitaB.org | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
</head> | ||
<body> | ||
Hello {{user}},<br> | ||
<p>This is a gentle reminder for {{meetup}} which will begin on {{meetup.date}} {%if meetup.time%} at {{meetup.time}} {% endif %} <br></p> | ||
Thank You,<br> | ||
AnitaB.org | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
</head> | ||
<body> | ||
Hello {{user}},<br> | ||
<p>This is to inform you that the timing for {{meetup}} has been changed to {{meetup.date}} {%if meetup.time%} {{meetup.time}} {% endif %} <br></p> | ||
Thank You,<br> | ||
AnitaB.org | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
from django.apps import AppConfig | ||
from django.conf import settings | ||
|
||
|
||
class UsersConfig(AppConfig): | ||
name = 'users' | ||
|
||
def ready(self): | ||
import users.signals # noqa # pylint: disable=unused-variable | ||
from . import scheduler | ||
if settings.SCHEDULER_AUTOSTART: | ||
scheduler.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import datetime | ||
import logging | ||
from datetime import timedelta | ||
|
||
from apscheduler.schedulers.background import BackgroundScheduler | ||
from django.core.mail import send_mail | ||
from django.template.loader import render_to_string | ||
from django_apscheduler.jobstores import register_events, register_job | ||
|
||
from django.conf import settings | ||
|
||
from meetup.utils import send_reminder | ||
from meetup.models import Meetup | ||
|
||
from community.models import Community | ||
|
||
from systers_portal.settings.dev import FROM_EMAIL | ||
|
||
scheduler = BackgroundScheduler(settings.SCHEDULER_CONFIG) | ||
|
||
|
||
@register_job(scheduler, 'cron', day_of_week='mon', hour=5, minute=30, replace_existing=True) | ||
def weekly_digest(): | ||
communities = Community.objects.all() | ||
for community in communities: | ||
subject = "Weekly update from {0}".format(community) | ||
count = community.members.count() | ||
for member in community.members: | ||
html_text = \ | ||
render_to_string("templates/community/weekly_digest_email.html", | ||
{'user': member, | ||
'count': count, | ||
'community': community}) | ||
send_mail( | ||
subject, | ||
'Weekly Digest', | ||
FROM_EMAIL, | ||
[member.user.email], | ||
html_message=html_text, | ||
) | ||
|
||
|
||
def start(): | ||
if settings.DEBUG: | ||
logging.basicConfig() | ||
logging.getLogger('apscheduler').setLevel(logging.DEBUG) | ||
register_events(scheduler) | ||
scheduler.start() | ||
meetup_list = Meetup.objects.filter(date__gte=datetime.date.today()) | ||
for meetup in meetup_list: | ||
name = "Reminder for {0}".format(meetup.title) | ||
scheduler.add_job(send_reminder, "date", run_date=meetup.date - timedelta(hours=1), | ||
args=[meetup], id=name, replace_existing=True) |