-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from dev-lymar/chore/dev-integrate-celery-rabb…
…itmq Chore/dev integrate celery rabbitmq
- Loading branch information
Showing
11 changed files
with
118 additions
and
33 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This will make sure the app is always imported when | ||
# Django starts so that shared_task will use this app. | ||
from .celery import app as celery_app | ||
|
||
__all__ = ("celery_app",) |
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,26 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
import os | ||
|
||
from celery import Celery | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Set the default Django settings module for the 'celery' program. | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "melnichanka.settings") | ||
|
||
broker_user = os.getenv("RABBITMQ_DEFAULT_USER") | ||
broker_pass = os.getenv("RABBITMQ_DEFAULT_PASS") | ||
broker_url = f"amqp://{broker_user}:{broker_pass}@rabbitmq:5672//" | ||
|
||
app = Celery("melnichanka", broker=broker_url) | ||
|
||
# Using a string here means the worker doesn't have to serialize | ||
# the configuration object to child processes. | ||
# - namespace='CELERY' means all celery-related configuration keys | ||
# should have a `CELERY_` prefix. | ||
app.config_from_object("django.conf:settings", namespace="CELERY") | ||
|
||
# Load task modules from all registered Django apps. | ||
app.autodiscover_tasks() |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from celery import shared_task | ||
from django.conf import settings | ||
from django.core.mail import send_mail | ||
from django.urls import reverse | ||
|
||
domain = settings.DOMAIN_NAME | ||
|
||
|
||
@shared_task | ||
def send_reset_email(email, token): | ||
email_plaintext_message = "Для сброса пароля перейдите по ссылке: {}{}?token={}".format( | ||
domain, reverse("password_reset:reset-password-confirm"), token | ||
) | ||
|
||
send_mail( | ||
# title: | ||
"Сброс пароля для: {title}".format(title="EDO website"), | ||
# message: | ||
email_plaintext_message, | ||
# from: | ||
settings.EMAIL_HOST_USER, | ||
# to: | ||
[email], | ||
) |
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