mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 19:08:21 +00:00
[html email] added html email for user add/passwd_reset, link share
This commit is contained in:
@@ -11,6 +11,8 @@ from seahub.utils import IS_EMAIL_CONFIGURED
|
||||
|
||||
from captcha.fields import CaptchaField
|
||||
|
||||
import seahub.settings as settings
|
||||
|
||||
class AuthenticationForm(forms.Form):
|
||||
"""
|
||||
Base class for authenticating users. Extend this to get a form that accepts
|
||||
@@ -84,7 +86,6 @@ class PasswordResetForm(forms.Form):
|
||||
"""
|
||||
Generates a one-use only link for resetting password and sends to the user
|
||||
"""
|
||||
#from django.core.mail import send_mail
|
||||
from django.core.mail import EmailMessage
|
||||
|
||||
user = self.users_cache
|
||||
@@ -104,6 +105,8 @@ class PasswordResetForm(forms.Form):
|
||||
'user': user,
|
||||
'token': token_generator.make_token(user),
|
||||
'protocol': use_https and 'https' or 'http',
|
||||
'media_url': settings.MEDIA_URL,
|
||||
'logo_path': settings.LOGO_PATH,
|
||||
}
|
||||
|
||||
msg = EmailMessage(_("Password reset on %s") % site_name,
|
||||
|
@@ -2,7 +2,7 @@
|
||||
import os
|
||||
import logging
|
||||
import simplejson as json
|
||||
from django.core.mail import send_mail
|
||||
from django.core.mail import EmailMessage
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import IntegrityError
|
||||
from django.http import HttpResponse, HttpResponseRedirect, Http404, \
|
||||
@@ -39,6 +39,7 @@ from seahub.utils import render_permission_error, string2list, render_error, \
|
||||
gen_file_share_link, IS_EMAIL_CONFIGURED, check_filename_with_rename, \
|
||||
get_repo_last_modify, is_valid_username
|
||||
|
||||
import seahub.settings as settings
|
||||
try:
|
||||
from seahub.settings import CLOUD_MODE
|
||||
except ImportError:
|
||||
@@ -799,17 +800,24 @@ def send_shared_link(request):
|
||||
mail_sended.send(sender=None, user=request.user.username,
|
||||
email=to_email)
|
||||
|
||||
use_https = request.is_secure()
|
||||
domain = RequestSite(request).domain
|
||||
c = {
|
||||
'email': request.user.username,
|
||||
'to_email': to_email,
|
||||
'file_shared_link': file_shared_link,
|
||||
'site_name': SITE_NAME,
|
||||
'domain': domain,
|
||||
'protocol': use_https and 'https' or 'http',
|
||||
'media_url': settings.MEDIA_URL,
|
||||
'logo_path': settings.LOGO_PATH,
|
||||
}
|
||||
|
||||
try:
|
||||
send_mail(_(u'Your friend shared a file to you on Seafile'),
|
||||
t.render(Context(c)), None, [to_email],
|
||||
fail_silently=False)
|
||||
msg = EmailMessage(_(u'Your friend shared a file to you on Seafile'),
|
||||
t.render(Context(c)), None, [to_email])
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
except Exception, e:
|
||||
logger.error(str(e))
|
||||
data = json.dumps({'error':_(u'Internal server error. Send failed.')})
|
||||
@@ -1073,17 +1081,25 @@ def send_shared_upload_link(request):
|
||||
mail_sended.send(sender=None, user=request.user.username,
|
||||
email=to_email)
|
||||
|
||||
|
||||
use_https = request.is_secure()
|
||||
domain = RequestSite(request).domain
|
||||
c = {
|
||||
'email': request.user.username,
|
||||
'to_email': to_email,
|
||||
'shared_upload_link': shared_upload_link,
|
||||
'site_name': SITE_NAME,
|
||||
'domain': domain,
|
||||
'protocol': use_https and 'https' or 'http',
|
||||
'media_url': settings.MEDIA_URL,
|
||||
'logo_path': settings.LOGO_PATH,
|
||||
}
|
||||
|
||||
try:
|
||||
send_mail(_(u'Your friend shared a upload link to you on Seafile'),
|
||||
t.render(Context(c)), None, [to_email],
|
||||
fail_silently=False)
|
||||
msg = EmailMessage(_(u'Your friend shared a upload link to you on Seafile'),
|
||||
t.render(Context(c)), None, [to_email])
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
except Exception, e:
|
||||
logger.error(str(e))
|
||||
data = json.dumps({'error':_(u'Internal server error. Send failed.')})
|
||||
|
@@ -1,8 +1,17 @@
|
||||
{% load i18n %}
|
||||
<div style="background:#f2f2f2;padding:40px 0;">
|
||||
<div style="width:700px;background:#fff;border-style:solid;border-width:1px;border-color:#eaeaea #cccccc #a6a6a6;border-radius:4px;box-shadow:0 2px 2px #cdcdcd;margin:0 auto;">
|
||||
<img src="https://dev.seafile.com/seahub/media/img/seafile_logo.png" alt="" style="display:block;margin:20px 0 15px 50px;" />
|
||||
<img src="{{ protocol }}://{{domain}}{{media_url}}{{logo_path}}" alt="" style="display:block;margin:20px 0 15px 50px;" />
|
||||
<div style="padding:30px 55px 40px;min-height:300px;border-top:1px solid #efefef;box-shadow:inset 0 30px 30px #fcfcfc;">
|
||||
{% block email_con %}{% endblock %}
|
||||
|
||||
<p style="font-size:14px;color:#434144;margin:30px 0;">
|
||||
{% trans "Thanks for using our site!" %}
|
||||
</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -21,14 +21,6 @@
|
||||
{% trans "Your username, in case you've forgotten:" %} {{ user.username }}
|
||||
</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;margin:30px 0;">
|
||||
{% trans "Thanks for using our site!" %}
|
||||
</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
{% endautoescape %}
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -1,11 +1,22 @@
|
||||
{% load i18n %}{% autoescape off %}
|
||||
{% extends 'email_base.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block email_con %}
|
||||
|
||||
{% autoescape off %}
|
||||
|
||||
<p style="color:#121214;font-size:14px;">{% trans "Hi," %}</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% blocktrans %}You're receiving this e-mail because {{ email }} is sharing a file to you on {{ site_name }}.{% endblocktrans%}
|
||||
</p>
|
||||
|
||||
{% trans "Please go to the following page and view the file:" %}
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% trans "Please go to the following page and view the file:" %}<br />
|
||||
{{ file_shared_link }}
|
||||
|
||||
{% trans "Thanks for using our site!" %}
|
||||
|
||||
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
{% endautoescape %}
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -1,11 +1,20 @@
|
||||
{% load i18n %}{% autoescape off %}
|
||||
{% extends 'email_base.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block email_con %}
|
||||
{% autoescape off %}
|
||||
|
||||
<p style="color:#121214;font-size:14px;">{% trans "Hi," %}</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% blocktrans %}You're receiving this e-mail because {{ email }} has shared an upload link to you on {{ site_name }}.{% endblocktrans%}
|
||||
</p>
|
||||
|
||||
{% trans "You can go to the following page and upload your files:" %}
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% trans "You can go to the following page and upload your files:" %}<br />
|
||||
{{ shared_upload_link }}
|
||||
|
||||
{% trans "Thanks for using our site!" %}
|
||||
|
||||
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
{% endautoescape %}
|
||||
{% endblock %}
|
||||
|
@@ -1,19 +1,32 @@
|
||||
{% load i18n %}{% autoescape off %}
|
||||
{% extends 'email_base.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block email_con %}
|
||||
|
||||
{% autoescape off %}
|
||||
|
||||
<p style="color:#121214;font-size:14px;">{% trans "Hi," %}</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% if org %}
|
||||
{% blocktrans with org_name=org.org_name %}You're receiving this e-mail because {{ user }} added you to organization "{{ org_name }}" on {{ site_name }}.{% endblocktrans%}
|
||||
{% else %}
|
||||
{% blocktrans %}You're receiving this e-mail because {{ user }} added you to {{ site_name }}.{% endblocktrans%}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% trans "Following is your account information:" %}
|
||||
{% blocktrans %}Email: {{ email }}{% endblocktrans %}
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% trans "Following is your account information:" %}<br />
|
||||
{% blocktrans %}Email: {{ email }}{% endblocktrans %}<br />
|
||||
{% blocktrans %}Password: {{ password }}{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
{% trans "Please go to the following page and log in:" %}
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% trans "Please go to the following page and log in:" %}<br />
|
||||
{{ protocol }}://{{ domain }}{% url 'auth_login' %}
|
||||
|
||||
{% trans "Thanks for using our site!" %}
|
||||
|
||||
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
{% endautoescape %}
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -1,10 +1,21 @@
|
||||
{% load i18n %}{% autoescape off %}
|
||||
{% extends 'email_base.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block email_con %}
|
||||
|
||||
{% autoescape off %}
|
||||
|
||||
<p style="color:#121214;font-size:14px;">{% trans "Hi," %}</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% blocktrans %}You're receiving this e-mail because staff has reset your password at {{ site_name }}. {% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<p style="font-size:14px;color:#434144;">
|
||||
{% blocktrans %}Your new password is {{ password }}, please modify your password as soon as possible.{% endblocktrans %}
|
||||
|
||||
{% trans "Thanks for using our site!" %}
|
||||
|
||||
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
{% endautoescape %}
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -6,7 +6,7 @@ import logging
|
||||
import simplejson as json
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.mail import send_mail
|
||||
from django.core.mail import EmailMessage
|
||||
from django.contrib import messages
|
||||
from django.http import HttpResponse, Http404, HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response
|
||||
@@ -459,14 +459,25 @@ def send_user_reset_email(request, email, password):
|
||||
Send email when reset user password.
|
||||
"""
|
||||
|
||||
use_https = request.is_secure()
|
||||
domain = RequestSite(request).domain
|
||||
|
||||
t = loader.get_template('sysadmin/user_reset_email.html')
|
||||
c = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
'site_name': settings.SITE_NAME,
|
||||
'media_url': settings.MEDIA_URL,
|
||||
'logo_path': settings.LOGO_PATH,
|
||||
'domain': domain,
|
||||
'protocol': use_https and 'https' or 'http',
|
||||
'media_url': settings.MEDIA_URL,
|
||||
'logo_path': settings.LOGO_PATH,
|
||||
}
|
||||
send_mail(_(u'Password Reset'), t.render(Context(c)),
|
||||
None, [email], fail_silently=False)
|
||||
msg = EmailMessage(_(u'Password Reset'), t.render(Context(c)),
|
||||
None, [email])
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
@login_required
|
||||
@sys_staff_required
|
||||
@@ -520,9 +531,14 @@ def send_user_add_mail(request, email, password):
|
||||
'domain': domain,
|
||||
'protocol': use_https and 'https' or 'http',
|
||||
'site_name': settings.SITE_NAME,
|
||||
'media_url': settings.MEDIA_URL,
|
||||
'logo_path': settings.LOGO_PATH,
|
||||
}
|
||||
send_mail(_(u'Seafile Registration Information'), t.render(Context(c)),
|
||||
None, [email], fail_silently=False)
|
||||
msg = EmailMessage(_(u'Seafile Registration Information'), t.render(Context(c)),
|
||||
None, [email])
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
|
||||
@login_required
|
||||
def user_add(request):
|
||||
|
Reference in New Issue
Block a user