diff --git a/seahub/settings.py b/seahub/settings.py index b73c5ee4f6..682cefbde4 100644 --- a/seahub/settings.py +++ b/seahub/settings.py @@ -394,6 +394,9 @@ ACTIVATE_AFTER_REGISTRATION = True # This option will be ignored if ``ACTIVATE_AFTER_REGISTRATION`` set to ``True``. REGISTRATION_SEND_MAIL = False +#Control the language that send email. +SHARE_LINK_EMAIL_LANGUAGE = '' + REQUIRE_DETAIL_ON_REGISTRATION = False # Account initial password, for password resetting. diff --git a/seahub/share/views.py b/seahub/share/views.py index cbd796c1ae..30dcedd08a 100644 --- a/seahub/share/views.py +++ b/seahub/share/views.py @@ -9,7 +9,7 @@ from constance import config from django.core.cache import cache from django.http import HttpResponse, HttpResponseRedirect, Http404, \ HttpResponseBadRequest -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext as _, activate, deactivate from django.contrib import messages from django.utils import timezone 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, \ gen_token, normalize_cache_key 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 # Get an instance of a logger @@ -149,6 +150,8 @@ def send_shared_link(request): send_failed.append(to_email) continue + if SHARE_LINK_EMAIL_LANGUAGE: + activate(SHARE_LINK_EMAIL_LANGUAGE) # Add email to contacts. mail_sended.send(sender=None, user=request.user.username, email=to_email) @@ -192,6 +195,7 @@ def send_shared_link(request): except Exception: send_failed.append(to_email) + deactivate() if len(send_success) > 0: data = json.dumps({"send_success": send_success, "send_failed": send_failed}) return HttpResponse(data, status=200, content_type=content_type)