forked from github/plane
Merge branch 'chore/api_endpoints' of github.com:makeplane/plane into develop-deploy
This commit is contained in:
commit
05f8c7e9d8
@ -61,7 +61,6 @@ class IssueSerializer(BaseSerializer):
|
|||||||
|
|
||||||
# Validate assignees are from project
|
# Validate assignees are from project
|
||||||
if data.get("assignees", []):
|
if data.get("assignees", []):
|
||||||
print(data.get("assignees"))
|
|
||||||
data["assignees"] = ProjectMember.objects.filter(
|
data["assignees"] = ProjectMember.objects.filter(
|
||||||
project_id=self.context.get("project_id"),
|
project_id=self.context.get("project_id"),
|
||||||
is_active=True,
|
is_active=True,
|
||||||
|
@ -450,7 +450,7 @@ class IssueCommentAPIEndpoint(WebhookMixin, BaseAPIView):
|
|||||||
|
|
||||||
serializer_class = IssueCommentSerializer
|
serializer_class = IssueCommentSerializer
|
||||||
model = IssueComment
|
model = IssueComment
|
||||||
webhook_event = "issue_comment"
|
webhook_event = "issue-comment"
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
ProjectLitePermission,
|
ProjectLitePermission,
|
||||||
]
|
]
|
||||||
|
@ -123,7 +123,6 @@ class ProjectAPIEndpoint(WebhookMixin, BaseAPIView):
|
|||||||
projects, many=True, fields=self.fields, expand=self.expand,
|
projects, many=True, fields=self.fields, expand=self.expand,
|
||||||
).data,
|
).data,
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
project = self.get_queryset().get(workspace__slug=slug, pk=project_id)
|
project = self.get_queryset().get(workspace__slug=slug, pk=project_id)
|
||||||
serializer = ProjectSerializer(project, fields=self.fields, expand=self.expand,)
|
serializer = ProjectSerializer(project, fields=self.fields, expand=self.expand,)
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
|
@ -27,8 +27,8 @@ class GPTIntegrationEndpoint(BaseAPIView):
|
|||||||
|
|
||||||
# Get the configuration value
|
# Get the configuration value
|
||||||
instance_configuration = InstanceConfiguration.objects.values("key", "value")
|
instance_configuration = InstanceConfiguration.objects.values("key", "value")
|
||||||
api_key = get_configuration_value(instance_configuration, "OPENAI_API_KEY")
|
api_key = get_configuration_value(instance_configuration, "OPENAI_API_KEY", os.environ.get("OPENAI_API_KEY"))
|
||||||
gpt_engine = get_configuration_value(instance_configuration, "GPT_ENGINE")
|
gpt_engine = get_configuration_value(instance_configuration, "GPT_ENGINE", os.environ.get("GPT_ENGINE", "gpt-3.5-turbo"))
|
||||||
|
|
||||||
# Check the keys
|
# Check the keys
|
||||||
if not api_key or not gpt_engine:
|
if not api_key or not gpt_engine:
|
||||||
@ -47,10 +47,6 @@ class GPTIntegrationEndpoint(BaseAPIView):
|
|||||||
|
|
||||||
final_text = task + "\n" + prompt
|
final_text = task + "\n" + prompt
|
||||||
|
|
||||||
instance_configuration = InstanceConfiguration.objects.values("key", "value")
|
|
||||||
|
|
||||||
gpt_engine = get_configuration_value(instance_configuration, "GPT_ENGINE")
|
|
||||||
|
|
||||||
client = OpenAI(
|
client = OpenAI(
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
)
|
)
|
||||||
|
@ -596,7 +596,7 @@ class IssueActivityEndpoint(BaseAPIView):
|
|||||||
class IssueCommentViewSet(WebhookMixin, BaseViewSet):
|
class IssueCommentViewSet(WebhookMixin, BaseViewSet):
|
||||||
serializer_class = IssueCommentSerializer
|
serializer_class = IssueCommentSerializer
|
||||||
model = IssueComment
|
model = IssueComment
|
||||||
webhook_event = "issue_comment"
|
webhook_event = "issue-comment"
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
ProjectLitePermission,
|
ProjectLitePermission,
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
import csv
|
import csv
|
||||||
import io
|
import io
|
||||||
|
import os
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.mail import EmailMultiAlternatives, get_connection
|
from django.core.mail import EmailMultiAlternatives, get_connection
|
||||||
@ -32,7 +33,7 @@ row_mapping = {
|
|||||||
"priority": "Priority",
|
"priority": "Priority",
|
||||||
"estimate": "Estimate",
|
"estimate": "Estimate",
|
||||||
"issue_cycle__cycle_id": "Cycle",
|
"issue_cycle__cycle_id": "Cycle",
|
||||||
"issue_module__module_id": "Module"
|
"issue_module__module_id": "Module",
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIGNEE_ID = "assignees__id"
|
ASSIGNEE_ID = "assignees__id"
|
||||||
@ -51,17 +52,55 @@ def send_export_email(email, slug, csv_buffer):
|
|||||||
csv_buffer.seek(0)
|
csv_buffer.seek(0)
|
||||||
|
|
||||||
# Configure email connection from the database
|
# Configure email connection from the database
|
||||||
instance_configuration = InstanceConfiguration.objects.filter(key__startswith='EMAIL_').values("key", "value")
|
instance_configuration = InstanceConfiguration.objects.filter(
|
||||||
|
key__startswith="EMAIL_"
|
||||||
|
).values("key", "value")
|
||||||
connection = get_connection(
|
connection = get_connection(
|
||||||
host=get_configuration_value(instance_configuration, "EMAIL_HOST"),
|
host=get_configuration_value(
|
||||||
port=int(get_configuration_value(instance_configuration, "EMAIL_PORT", "587")),
|
instance_configuration, "EMAIL_HOST", os.environ.get("EMAIL_HOST")
|
||||||
username=get_configuration_value(instance_configuration, "EMAIL_HOST_USER"),
|
),
|
||||||
password=get_configuration_value(instance_configuration, "EMAIL_HOST_PASSWORD"),
|
port=int(
|
||||||
use_tls=bool(get_configuration_value(instance_configuration, "EMAIL_USE_TLS", "1")),
|
get_configuration_value(
|
||||||
use_ssl=bool(get_configuration_value(instance_configuration, "EMAIL_USE_SSL", "0")),
|
instance_configuration, "EMAIL_PORT", os.environ.get("EMAIL_PORT")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
username=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_USER",
|
||||||
|
os.environ.get("EMAIL_HOST_USER"),
|
||||||
|
),
|
||||||
|
password=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_PASSWORD",
|
||||||
|
os.environ.get("EMAIL_HOST_PASSWORD"),
|
||||||
|
),
|
||||||
|
use_tls=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_TLS",
|
||||||
|
os.environ.get("EMAIL_USE_TLS", "1"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
use_ssl=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_SSL",
|
||||||
|
os.environ.get("EMAIL_USE_SSL", "0"),
|
||||||
|
)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
msg = EmailMultiAlternatives(subject=subject, body=text_content, from_email=get_configuration_value(instance_configuration, "EMAIL_FROM"), to=[email], connection=connection)
|
msg = EmailMultiAlternatives(
|
||||||
|
subject=subject,
|
||||||
|
body=text_content,
|
||||||
|
from_email=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_FROM",
|
||||||
|
os.environ.get("EMAIL_FROM", "Team Plane <team@mailer.plane.so>"),
|
||||||
|
),
|
||||||
|
to=[email],
|
||||||
|
connection=connection,
|
||||||
|
)
|
||||||
msg.attach(f"{slug}-analytics.csv", csv_buffer.getvalue())
|
msg.attach(f"{slug}-analytics.csv", csv_buffer.getvalue())
|
||||||
msg.send(fail_silently=False)
|
msg.send(fail_silently=False)
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Python imports
|
||||||
|
import os
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.mail import EmailMultiAlternatives, get_connection
|
from django.core.mail import EmailMultiAlternatives, get_connection
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
@ -14,9 +17,9 @@ from sentry_sdk import capture_exception
|
|||||||
from plane.license.models import InstanceConfiguration
|
from plane.license.models import InstanceConfiguration
|
||||||
from plane.license.utils.instance_value import get_configuration_value
|
from plane.license.utils.instance_value import get_configuration_value
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def email_verification(first_name, email, token, current_site):
|
def email_verification(first_name, email, token, current_site):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
realtivelink = "/request-email-verification/" + "?token=" + str(token)
|
realtivelink = "/request-email-verification/" + "?token=" + str(token)
|
||||||
abs_url = current_site + realtivelink
|
abs_url = current_site + realtivelink
|
||||||
@ -33,17 +36,56 @@ def email_verification(first_name, email, token, current_site):
|
|||||||
text_content = strip_tags(html_content)
|
text_content = strip_tags(html_content)
|
||||||
|
|
||||||
# Configure email connection from the database
|
# Configure email connection from the database
|
||||||
instance_configuration = InstanceConfiguration.objects.filter(key__startswith='EMAIL_').values("key", "value")
|
instance_configuration = InstanceConfiguration.objects.filter(
|
||||||
|
key__startswith="EMAIL_"
|
||||||
|
).values("key", "value")
|
||||||
connection = get_connection(
|
connection = get_connection(
|
||||||
host=get_configuration_value(instance_configuration, "EMAIL_HOST"),
|
host=get_configuration_value(
|
||||||
port=int(get_configuration_value(instance_configuration, "EMAIL_PORT", "587")),
|
instance_configuration, "EMAIL_HOST", os.environ.get("EMAIL_HOST")
|
||||||
username=get_configuration_value(instance_configuration, "EMAIL_HOST_USER"),
|
),
|
||||||
password=get_configuration_value(instance_configuration, "EMAIL_HOST_PASSWORD"),
|
port=int(
|
||||||
use_tls=bool(get_configuration_value(instance_configuration, "EMAIL_USE_TLS", "1")),
|
get_configuration_value(
|
||||||
|
instance_configuration, "EMAIL_PORT", os.environ.get("EMAIL_PORT")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
username=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_USER",
|
||||||
|
os.environ.get("EMAIL_HOST_USER"),
|
||||||
|
),
|
||||||
|
password=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_PASSWORD",
|
||||||
|
os.environ.get("EMAIL_HOST_PASSWORD"),
|
||||||
|
),
|
||||||
|
use_tls=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_TLS",
|
||||||
|
os.environ.get("EMAIL_USE_TLS", "1"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
use_ssl=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_SSL",
|
||||||
|
os.environ.get("EMAIL_USE_SSL", "0"),
|
||||||
|
)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Initiate email alternatives
|
# Initiate email alternatives
|
||||||
msg = EmailMultiAlternatives(subject=subject, body=text_content, from_email=get_configuration_value(instance_configuration, "EMAIL_FROM"), to=[email], connection=connection)
|
msg = EmailMultiAlternatives(
|
||||||
|
subject=subject,
|
||||||
|
body=text_content,
|
||||||
|
from_email=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_FROM",
|
||||||
|
os.environ.get("EMAIL_FROM", "Team Plane <team@mailer.plane.so>"),
|
||||||
|
),
|
||||||
|
to=[email],
|
||||||
|
connection=connection,
|
||||||
|
)
|
||||||
msg.attach_alternative(html_content, "text/html")
|
msg.attach_alternative(html_content, "text/html")
|
||||||
msg.send()
|
msg.send()
|
||||||
return
|
return
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Python import
|
||||||
|
import os
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.mail import EmailMultiAlternatives, get_connection
|
from django.core.mail import EmailMultiAlternatives, get_connection
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
@ -32,14 +35,51 @@ def forgot_password(first_name, email, uidb64, token, current_site):
|
|||||||
|
|
||||||
instance_configuration = InstanceConfiguration.objects.filter(key__startswith='EMAIL_').values("key", "value")
|
instance_configuration = InstanceConfiguration.objects.filter(key__startswith='EMAIL_').values("key", "value")
|
||||||
connection = get_connection(
|
connection = get_connection(
|
||||||
host=get_configuration_value(instance_configuration, "EMAIL_HOST"),
|
host=get_configuration_value(
|
||||||
port=int(get_configuration_value(instance_configuration, "EMAIL_PORT", "587")),
|
instance_configuration, "EMAIL_HOST", os.environ.get("EMAIL_HOST")
|
||||||
username=get_configuration_value(instance_configuration, "EMAIL_HOST_USER"),
|
),
|
||||||
password=get_configuration_value(instance_configuration, "EMAIL_HOST_PASSWORD"),
|
port=int(
|
||||||
use_tls=bool(get_configuration_value(instance_configuration, "EMAIL_USE_TLS", "1")),
|
get_configuration_value(
|
||||||
|
instance_configuration, "EMAIL_PORT", os.environ.get("EMAIL_PORT")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
username=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_USER",
|
||||||
|
os.environ.get("EMAIL_HOST_USER"),
|
||||||
|
),
|
||||||
|
password=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_PASSWORD",
|
||||||
|
os.environ.get("EMAIL_HOST_PASSWORD"),
|
||||||
|
),
|
||||||
|
use_tls=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_TLS",
|
||||||
|
os.environ.get("EMAIL_USE_TLS", "1"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
use_ssl=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_SSL",
|
||||||
|
os.environ.get("EMAIL_USE_SSL", "0"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = EmailMultiAlternatives(
|
||||||
|
subject=subject,
|
||||||
|
body=text_content,
|
||||||
|
from_email=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_FROM",
|
||||||
|
os.environ.get("EMAIL_FROM", "Team Plane <team@mailer.plane.so>"),
|
||||||
|
),
|
||||||
|
to=[email],
|
||||||
|
connection=connection,
|
||||||
)
|
)
|
||||||
# Initiate email alternatives
|
|
||||||
msg = EmailMultiAlternatives(subject=subject, body=text_content, from_email=get_configuration_value(instance_configuration, "EMAIL_FROM"), to=[email], connection=connection)
|
|
||||||
msg.attach_alternative(html_content, "text/html")
|
msg.attach_alternative(html_content, "text/html")
|
||||||
msg.send()
|
msg.send()
|
||||||
return
|
return
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Python imports
|
||||||
|
import os
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.mail import EmailMultiAlternatives, get_connection
|
from django.core.mail import EmailMultiAlternatives, get_connection
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
@ -12,6 +15,7 @@ from sentry_sdk import capture_exception
|
|||||||
from plane.license.models import InstanceConfiguration
|
from plane.license.models import InstanceConfiguration
|
||||||
from plane.license.utils.instance_value import get_configuration_value
|
from plane.license.utils.instance_value import get_configuration_value
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def magic_link(email, key, token, current_site):
|
def magic_link(email, key, token, current_site):
|
||||||
try:
|
try:
|
||||||
@ -26,17 +30,55 @@ def magic_link(email, key, token, current_site):
|
|||||||
|
|
||||||
text_content = strip_tags(html_content)
|
text_content = strip_tags(html_content)
|
||||||
|
|
||||||
instance_configuration = InstanceConfiguration.objects.filter(key__startswith='EMAIL_').values("key", "value")
|
instance_configuration = InstanceConfiguration.objects.filter(
|
||||||
|
key__startswith="EMAIL_"
|
||||||
|
).values("key", "value")
|
||||||
connection = get_connection(
|
connection = get_connection(
|
||||||
host=get_configuration_value(instance_configuration, "EMAIL_HOST"),
|
host=get_configuration_value(
|
||||||
port=int(get_configuration_value(instance_configuration, "EMAIL_PORT", "587")),
|
instance_configuration, "EMAIL_HOST", os.environ.get("EMAIL_HOST")
|
||||||
username=get_configuration_value(instance_configuration, "EMAIL_HOST_USER"),
|
),
|
||||||
password=get_configuration_value(instance_configuration, "EMAIL_HOST_PASSWORD"),
|
port=int(
|
||||||
use_tls=bool(get_configuration_value(instance_configuration, "EMAIL_USE_TLS", "1")),
|
get_configuration_value(
|
||||||
|
instance_configuration, "EMAIL_PORT", os.environ.get("EMAIL_PORT")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
username=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_USER",
|
||||||
|
os.environ.get("EMAIL_HOST_USER"),
|
||||||
|
),
|
||||||
|
password=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_PASSWORD",
|
||||||
|
os.environ.get("EMAIL_HOST_PASSWORD"),
|
||||||
|
),
|
||||||
|
use_tls=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_TLS",
|
||||||
|
os.environ.get("EMAIL_USE_TLS", "1"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
use_ssl=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_SSL",
|
||||||
|
os.environ.get("EMAIL_USE_SSL", "0"),
|
||||||
|
)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Initiate email alternatives
|
msg = EmailMultiAlternatives(
|
||||||
msg = EmailMultiAlternatives(subject=subject, body=text_content, from_email=get_configuration_value(instance_configuration, "EMAIL_FROM"), to=[email], connection=connection)
|
subject=subject,
|
||||||
|
body=text_content,
|
||||||
|
from_email=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_FROM",
|
||||||
|
os.environ.get("EMAIL_FROM", "Team Plane <team@mailer.plane.so>"),
|
||||||
|
),
|
||||||
|
to=[email],
|
||||||
|
connection=connection,
|
||||||
|
)
|
||||||
msg.attach_alternative(html_content, "text/html")
|
msg.attach_alternative(html_content, "text/html")
|
||||||
msg.send()
|
msg.send()
|
||||||
return
|
return
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Python import
|
||||||
|
import os
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.mail import EmailMultiAlternatives, get_connection
|
from django.core.mail import EmailMultiAlternatives, get_connection
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
@ -46,14 +49,52 @@ def project_invitation(email, project_id, token, current_site, invitor):
|
|||||||
# Configure email connection from the database
|
# Configure email connection from the database
|
||||||
instance_configuration = InstanceConfiguration.objects.filter(key__startswith='EMAIL_').values("key", "value")
|
instance_configuration = InstanceConfiguration.objects.filter(key__startswith='EMAIL_').values("key", "value")
|
||||||
connection = get_connection(
|
connection = get_connection(
|
||||||
host=get_configuration_value(instance_configuration, "EMAIL_HOST"),
|
host=get_configuration_value(
|
||||||
port=int(get_configuration_value(instance_configuration, "EMAIL_PORT", "587")),
|
instance_configuration, "EMAIL_HOST", os.environ.get("EMAIL_HOST")
|
||||||
username=get_configuration_value(instance_configuration, "EMAIL_HOST_USER"),
|
),
|
||||||
password=get_configuration_value(instance_configuration, "EMAIL_HOST_PASSWORD"),
|
port=int(
|
||||||
use_tls=bool(get_configuration_value(instance_configuration, "EMAIL_USE_TLS", "1")),
|
get_configuration_value(
|
||||||
|
instance_configuration, "EMAIL_PORT", os.environ.get("EMAIL_PORT")
|
||||||
)
|
)
|
||||||
# Initiate email alternatives
|
),
|
||||||
msg = EmailMultiAlternatives(subject=subject, body=text_content, from_email=get_configuration_value(instance_configuration, "EMAIL_FROM"), to=[email], connection=connection)
|
username=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_USER",
|
||||||
|
os.environ.get("EMAIL_HOST_USER"),
|
||||||
|
),
|
||||||
|
password=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_PASSWORD",
|
||||||
|
os.environ.get("EMAIL_HOST_PASSWORD"),
|
||||||
|
),
|
||||||
|
use_tls=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_TLS",
|
||||||
|
os.environ.get("EMAIL_USE_TLS", "1"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
use_ssl=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_SSL",
|
||||||
|
os.environ.get("EMAIL_USE_SSL", "0"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = EmailMultiAlternatives(
|
||||||
|
subject=subject,
|
||||||
|
body=text_content,
|
||||||
|
from_email=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_FROM",
|
||||||
|
os.environ.get("EMAIL_FROM", "Team Plane <team@mailer.plane.so>"),
|
||||||
|
),
|
||||||
|
to=[email],
|
||||||
|
connection=connection,
|
||||||
|
)
|
||||||
|
|
||||||
msg.attach_alternative(html_content, "text/html")
|
msg.attach_alternative(html_content, "text/html")
|
||||||
msg.send()
|
msg.send()
|
||||||
return
|
return
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# Python imports
|
||||||
|
import os
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.mail import EmailMultiAlternatives, get_connection
|
from django.core.mail import EmailMultiAlternatives, get_connection
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
@ -55,23 +58,48 @@ def workspace_invitation(email, workspace_id, token, current_site, invitor):
|
|||||||
key__startswith="EMAIL_"
|
key__startswith="EMAIL_"
|
||||||
).values("key", "value")
|
).values("key", "value")
|
||||||
connection = get_connection(
|
connection = get_connection(
|
||||||
host=get_configuration_value(instance_configuration, "EMAIL_HOST"),
|
host=get_configuration_value(
|
||||||
port=int(
|
instance_configuration, "EMAIL_HOST", os.environ.get("EMAIL_HOST")
|
||||||
get_configuration_value(instance_configuration, "EMAIL_PORT", "587")
|
),
|
||||||
|
port=int(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration, "EMAIL_PORT", os.environ.get("EMAIL_PORT")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
username=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_USER",
|
||||||
|
os.environ.get("EMAIL_HOST_USER"),
|
||||||
),
|
),
|
||||||
username=get_configuration_value(instance_configuration, "EMAIL_HOST_USER"),
|
|
||||||
password=get_configuration_value(
|
password=get_configuration_value(
|
||||||
instance_configuration, "EMAIL_HOST_PASSWORD"
|
instance_configuration,
|
||||||
|
"EMAIL_HOST_PASSWORD",
|
||||||
|
os.environ.get("EMAIL_HOST_PASSWORD"),
|
||||||
),
|
),
|
||||||
use_tls=bool(
|
use_tls=bool(
|
||||||
get_configuration_value(instance_configuration, "EMAIL_USE_TLS", "1")
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_TLS",
|
||||||
|
os.environ.get("EMAIL_USE_TLS", "1"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
use_ssl=bool(
|
||||||
|
get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_USE_SSL",
|
||||||
|
os.environ.get("EMAIL_USE_SSL", "0"),
|
||||||
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
# Initiate email alternatives
|
|
||||||
msg = EmailMultiAlternatives(
|
msg = EmailMultiAlternatives(
|
||||||
subject=subject,
|
subject=subject,
|
||||||
body=text_content,
|
body=text_content,
|
||||||
from_email=get_configuration_value(instance_configuration, "EMAIL_FROM"),
|
from_email=get_configuration_value(
|
||||||
|
instance_configuration,
|
||||||
|
"EMAIL_FROM",
|
||||||
|
os.environ.get("EMAIL_FROM", "Team Plane <team@mailer.plane.so>"),
|
||||||
|
),
|
||||||
to=[email],
|
to=[email],
|
||||||
connection=connection,
|
connection=connection,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user