mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 22:54:11 +00:00
Fixed bug when ACTIVATE_AFTER_REGISTRATION set to False on registraion complete.
This commit is contained in:
16
seahub/base/generic.py
Normal file
16
seahub/base/generic.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
class DirectTemplateView(TemplateView):
|
||||||
|
"""
|
||||||
|
Extend Django ``TemplateView`` to accept extra contexts.
|
||||||
|
"""
|
||||||
|
extra_context = None
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(self.__class__, self).get_context_data(**kwargs)
|
||||||
|
if self.extra_context is not None:
|
||||||
|
for key, value in self.extra_context.items():
|
||||||
|
if callable(value):
|
||||||
|
context[key] = value()
|
||||||
|
else:
|
||||||
|
context[key] = value
|
||||||
|
return context
|
@@ -7,6 +7,7 @@ from registration.views import activate
|
|||||||
from registration.views import register
|
from registration.views import register
|
||||||
|
|
||||||
from seahub.base.accounts import RegistrationForm
|
from seahub.base.accounts import RegistrationForm
|
||||||
|
from seahub.base.generic import DirectTemplateView
|
||||||
|
|
||||||
reg_dict = { 'backend': 'seahub.base.accounts.RegistrationBackend',
|
reg_dict = { 'backend': 'seahub.base.accounts.RegistrationBackend',
|
||||||
'form_class': RegistrationForm,
|
'form_class': RegistrationForm,
|
||||||
@@ -42,12 +43,11 @@ if ENABLE_SIGNUP:
|
|||||||
register,
|
register,
|
||||||
reg_dict,
|
reg_dict,
|
||||||
name='registration_register'),
|
name='registration_register'),
|
||||||
# Refer http://stackoverflow.com/questions/11005733/moving-from-direct-to-template-to-new-templateview-in-django to migrate direct_to_template with extra_context.
|
url(r'^register/complete/$',
|
||||||
# url(r'^register/complete/$',
|
DirectTemplateView.as_view(
|
||||||
# TemplateView.as_view(
|
template_name='registration/registration_complete.html',
|
||||||
# template_name='registration/registration_complete.html',
|
extra_context={ 'send_mail': settings.REGISTRATION_SEND_MAIL } ),
|
||||||
# extra_context={ 'send_mail': settings.REGISTRATION_SEND_MAIL } ),
|
name='registration_complete'),
|
||||||
# name='registration_complete'),
|
|
||||||
url(r'^register/closed/$',
|
url(r'^register/closed/$',
|
||||||
TemplateView.as_view(template_name='registration/registration_closed.html'),
|
TemplateView.as_view(template_name='registration/registration_closed.html'),
|
||||||
name='registration_disallowed'),
|
name='registration_disallowed'),
|
||||||
|
@@ -242,10 +242,11 @@ MAX_UPLOAD_FILE_NAME_LEN = 255
|
|||||||
MAX_FILE_NAME = MAX_UPLOAD_FILE_NAME_LEN
|
MAX_FILE_NAME = MAX_UPLOAD_FILE_NAME_LEN
|
||||||
MAX_PATH = 4096
|
MAX_PATH = 4096
|
||||||
|
|
||||||
# Set to True when user will be activaed after registration,
|
# Whether or not activate user when registration complete.
|
||||||
# and no email sending
|
# If set to ``False``, new user will be activated by admin or via activate link.
|
||||||
ACTIVATE_AFTER_REGISTRATION = True
|
ACTIVATE_AFTER_REGISTRATION = True
|
||||||
# In order to use email sending, `ACTIVATE_AFTER_REGISTRATION` must set to False
|
# Whether or not send activation Email to user when registration complete.
|
||||||
|
# This option will be ignored if ``ACTIVATE_AFTER_REGISTRATION`` set to ``True``.
|
||||||
REGISTRATION_SEND_MAIL = False
|
REGISTRATION_SEND_MAIL = False
|
||||||
|
|
||||||
# Seafile-applet address and port, used in repo download
|
# Seafile-applet address and port, used in repo download
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
{% extends "myhome_base.html" %}
|
{% extends "myhome_base.html" %}
|
||||||
{% block title %}感谢注册{% endblock %}
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block title %}{% trans "Registration complete" %}{% endblock %}
|
||||||
|
|
||||||
{% block main_panel %}
|
{% block main_panel %}
|
||||||
<div class="text-panel">
|
<div class="text-panel">
|
||||||
{% if send_mail %}
|
{% if send_mail %}
|
||||||
<p>感谢注册,激活邮件已发往您的邮箱,请查收。如果您在收件箱里没找到,请检查下是否被当成垃圾邮件了。</p>
|
<p>{% trans "An activation email has been sent. Please check your email and click on the link to activate your account." %}</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>感谢注册,请等待管理员激活你的帐号。</p>
|
<p>{% trans "Registration complete, please wait for administrator to activate your account." %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -231,10 +231,15 @@ def user_activate(request, user_id):
|
|||||||
user = User.objects.get(id=int(user_id))
|
user = User.objects.get(id=int(user_id))
|
||||||
user.is_active = True
|
user.is_active = True
|
||||||
user.save()
|
user.save()
|
||||||
|
messages.success(request, _(u'Successfully activated "%s".') % user.email)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
pass
|
messages.success(request, _(u'Failed to activate: user does not exist.'))
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse('sys_useradmin'))
|
next = request.META.get('HTTP_REFERER', None)
|
||||||
|
if not next:
|
||||||
|
next = reverse('sys_useradmin')
|
||||||
|
|
||||||
|
return HttpResponseRedirect(next)
|
||||||
|
|
||||||
def send_user_reset_email(request, email, password):
|
def send_user_reset_email(request, email, password):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user