Revision 7233d542 snf-astakos-app/astakos/im/activation_backends.py
b/snf-astakos-app/astakos/im/activation_backends.py | ||
---|---|---|
41 | 41 |
send_activation, send_account_creation_notification, activate |
42 | 42 |
) |
43 | 43 |
from astakos.im.settings import ( |
44 |
INVITATIONS_ENABLED, MODERATION_ENABLED, RE_USER_EMAIL_PATTERNS
|
|
44 |
INVITATIONS_ENABLED, RE_USER_EMAIL_PATTERNS |
|
45 | 45 |
) |
46 |
from astakos.im import settings as astakos_settings |
|
46 | 47 |
from astakos.im.forms import * |
47 | 48 |
|
48 | 49 |
import astakos.im.messages as astakos_messages |
... | ... | |
102 | 103 |
if provider == request.POST.get('provider', ''): |
103 | 104 |
initial_data = request.POST |
104 | 105 |
return globals()[formclass](initial_data, instance=instance, request=request) |
105 |
|
|
106 |
|
|
106 | 107 |
def handle_activation( |
107 | 108 |
self, user, activation_template_name='im/activation_email.txt', |
108 | 109 |
greeting_template_name='im/welcome_email.txt', |
... | ... | |
119 | 120 |
try: |
120 | 121 |
if user.is_active: |
121 | 122 |
return RegistationCompleted() |
122 |
|
|
123 |
|
|
123 | 124 |
if self._is_preaccepted(user): |
124 | 125 |
if user.email_verified: |
125 | 126 |
activate(user, greeting_template_name) |
... | ... | |
196 | 197 |
return True |
197 | 198 |
invitation = self.invitation |
198 | 199 |
if not invitation: |
199 |
return False
|
|
200 |
return not astakos_settings.MODERATION_ENABLED
|
|
200 | 201 |
if invitation.username == user.email and not invitation.is_consumed: |
201 | 202 |
invitation.consume() |
202 | 203 |
return True |
... | ... | |
212 | 213 |
def _is_preaccepted(self, user): |
213 | 214 |
if super(SimpleBackend, self)._is_preaccepted(user): |
214 | 215 |
return True |
215 |
if MODERATION_ENABLED: |
|
216 |
if astakos_settings.MODERATION_ENABLED:
|
|
216 | 217 |
return False |
217 | 218 |
return True |
218 | 219 |
|
... | ... | |
236 | 237 |
class RegistationCompleted(ActivationResult): |
237 | 238 |
def __init__(self): |
238 | 239 |
message = _(astakos_messages.REGISTRATION_COMPLETED) |
239 |
super(RegistationCompleted, self).__init__(message) |
|
240 |
super(RegistationCompleted, self).__init__(message) |
Also available in: Unified diff