mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 13:50:07 +00:00
[language] send email
This commit is contained in:
@@ -394,6 +394,9 @@ ACTIVATE_AFTER_REGISTRATION = True
|
|||||||
# This option will be ignored if ``ACTIVATE_AFTER_REGISTRATION`` set to ``True``.
|
# This option will be ignored if ``ACTIVATE_AFTER_REGISTRATION`` set to ``True``.
|
||||||
REGISTRATION_SEND_MAIL = False
|
REGISTRATION_SEND_MAIL = False
|
||||||
|
|
||||||
|
#Control the language that send email.
|
||||||
|
SHARE_LINK_EMAIL_LANGUAGE = ''
|
||||||
|
|
||||||
REQUIRE_DETAIL_ON_REGISTRATION = False
|
REQUIRE_DETAIL_ON_REGISTRATION = False
|
||||||
|
|
||||||
# Account initial password, for password resetting.
|
# Account initial password, for password resetting.
|
||||||
|
@@ -9,7 +9,7 @@ from constance import config
|
|||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.http import HttpResponse, HttpResponseRedirect, Http404, \
|
from django.http import HttpResponse, HttpResponseRedirect, Http404, \
|
||||||
HttpResponseBadRequest
|
HttpResponseBadRequest
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _, activate, deactivate
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
@@ -31,7 +31,8 @@ from seahub.utils import string2list, gen_shared_link, \
|
|||||||
is_valid_username, is_valid_email, send_html_email, is_org_context, \
|
is_valid_username, is_valid_email, send_html_email, is_org_context, \
|
||||||
gen_token, normalize_cache_key
|
gen_token, normalize_cache_key
|
||||||
from seahub.utils.mail import send_html_email_with_dj_template, MAIL_PRIORITY
|
from seahub.utils.mail import send_html_email_with_dj_template, MAIL_PRIORITY
|
||||||
from seahub.settings import SITE_ROOT, REPLACE_FROM_EMAIL, ADD_REPLY_TO_HEADER
|
from seahub.settings import SITE_ROOT, REPLACE_FROM_EMAIL, \
|
||||||
|
ADD_REPLY_TO_HEADER, SHARE_LINK_EMAIL_LANGUAGE
|
||||||
from seahub.profile.models import Profile
|
from seahub.profile.models import Profile
|
||||||
|
|
||||||
# Get an instance of a logger
|
# Get an instance of a logger
|
||||||
@@ -149,6 +150,8 @@ def send_shared_link(request):
|
|||||||
send_failed.append(to_email)
|
send_failed.append(to_email)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if SHARE_LINK_EMAIL_LANGUAGE:
|
||||||
|
activate(SHARE_LINK_EMAIL_LANGUAGE)
|
||||||
# Add email to contacts.
|
# Add email to contacts.
|
||||||
mail_sended.send(sender=None, user=request.user.username,
|
mail_sended.send(sender=None, user=request.user.username,
|
||||||
email=to_email)
|
email=to_email)
|
||||||
@@ -192,6 +195,7 @@ def send_shared_link(request):
|
|||||||
except Exception:
|
except Exception:
|
||||||
send_failed.append(to_email)
|
send_failed.append(to_email)
|
||||||
|
|
||||||
|
deactivate()
|
||||||
if len(send_success) > 0:
|
if len(send_success) > 0:
|
||||||
data = json.dumps({"send_success": send_success, "send_failed": send_failed})
|
data = json.dumps({"send_success": send_success, "send_failed": send_failed})
|
||||||
return HttpResponse(data, status=200, content_type=content_type)
|
return HttpResponse(data, status=200, content_type=content_type)
|
||||||
|
Reference in New Issue
Block a user