Commit 1463659a authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

enable moderation in SimpleBackend

Refs: #1990
parent e015e9e6
......@@ -39,6 +39,7 @@ from django.utils.translation import ugettext as _
from django.contrib.sites.models import Site
from django.contrib import messages
from django.db import transaction
from django.core.urlresolvers import reverse
from smtplib import SMTPException
from urllib import quote
......@@ -46,7 +47,7 @@ from urllib import quote
from astakos.im.models import AstakosUser, Invitation
from astakos.im.forms import *
from astakos.im.util import get_invitation
from astakos.im.settings import INVITATIONS_ENABLED, DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL
from astakos.im.settings import INVITATIONS_ENABLED, DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL, MODERATION_ENABLED
import socket
import logging
......@@ -221,10 +222,12 @@ class SimpleBackend(object):
* DEFAULT_CONTACT_EMAIL: service support email
* DEFAULT_FROM_EMAIL: from email
"""
user = None
try:
user = form.save()
status = messages.SUCCESS
if MODERATION_ENABLED:
message = _('Registration completed. You will receive an email upon your account\'s activation.')
else:
try:
_send_verification(self.request, user, email_template_name)
message = _('Verification sent to %s' % user.email)
except (SMTPException, socket.error) as e:
......@@ -243,8 +246,9 @@ def _send_verification(request, user, template_name):
site = Site.objects.get_current()
baseurl = request.build_absolute_uri('/').rstrip('/')
url = '%s%s?auth=%s&next=%s' % (baseurl,
reverse('astakos.im.target.activate'),
quote(user.auth_token))
reverse('astakos.im.views.activate'),
quote(user.auth_token),
quote(baseurl))
message = render_to_string(template_name, {
'user': user,
'url': url,
......
......@@ -45,6 +45,9 @@ COOKIE_DOMAIN = getattr(settings, 'ASTAKOS_COOKIE_DOMAIN', None)
IM_STATIC_URL = getattr(settings, 'ASTAKOS_IM_STATIC_URL', '/im/static/im/')
# If set to False and invitations not enabled newly created user will be automatically accepted
MODERATION_ENABLED = getattr(settings, 'ASTAKOS_MODERATION_ENABLED', True)
# SQLAlchemy (choose SQLite/MySQL/PostgreSQL).
BACKEND_DB_MODULE = getattr(settings, 'PITHOS_BACKEND_DB_MODULE', 'pithos.backends.lib.sqlalchemy')
BACKEND_DB_CONNECTION = getattr(settings, 'PITHOS_BACKEND_DB_CONNECTION', 'sqlite:///' + join(PROJECT_PATH, 'backend.db'))
......
......@@ -16,9 +16,11 @@
<li class="{% if not tab %}active{% endif %}">
<a href="{% url django.contrib.auth.views.password_change %}">Change password</a>
</li>
{% if invitations_enabled %}
<li class="{% if tab == "im/invitations" %}active{% endif %}">
<a href="{% url astakos.im.views.invite %}">Invitations</a>
</li>
{% endif %}
<li class="{% if tab == "im/feedback" %}active{% endif %}">
<a href="{% url astakos.im.views.send_feedback %}">Send feedback</a>
</li>
......
......@@ -273,6 +273,7 @@ def edit_profile(request, template_name='im/profile.html', extra_context={}):
extra_context,
user=request.user))
@requires_anonymous
def signup(request, on_failure='im/signup.html', on_success='im/signup_complete.html', extra_context={}, backend=None):
"""
Allows a user to create a local account.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment