|
|
|
|
@ -1,19 +1,26 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.contrib.sites.models import RequestSite |
|
|
|
|
from django.contrib.sites.models import Site |
|
|
|
|
from django.contrib.sites.models import RequestSite, Site |
|
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
|
from django.http import Http404 |
|
|
|
|
from django.http import Http404, HttpResponse, HttpResponseRedirect |
|
|
|
|
from django.shortcuts import render |
|
|
|
|
from django.contrib.auth import login, logout, authenticate |
|
|
|
|
from django.views.decorators.debug import sensitive_post_parameters |
|
|
|
|
from django.views.decorators.cache import never_cache |
|
|
|
|
|
|
|
|
|
from registration import signals |
|
|
|
|
from registration.models import RegistrationProfile |
|
|
|
|
from registration.views import ActivationView as BaseActivationView |
|
|
|
|
from registration.views import RegistrationView as BaseRegistrationView |
|
|
|
|
from registration.forms import RegistrationFormUniqueEmail |
|
|
|
|
from accounts.forms import RegistrationCompleteForm, SocialRegistrationCompleteForm |
|
|
|
|
from accounts.models import User |
|
|
|
|
|
|
|
|
|
from social.apps.django_app.default.models import UserSocialAuth |
|
|
|
|
|
|
|
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RegistrationView(BaseRegistrationView): |
|
|
|
|
""" |
|
|
|
|
A registration backend which follows a simple workflow: |
|
|
|
|
@ -144,19 +151,20 @@ class ActivationView(BaseActivationView): |
|
|
|
|
return ('registration_activation_complete', (), {}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def registration_form_validate(request): |
|
|
|
|
""" |
|
|
|
|
Ajax валидация формы регистрации на лету |
|
|
|
|
""" |
|
|
|
|
data = {'success': False} |
|
|
|
|
if request.method == 'POST': |
|
|
|
|
form = RegistrationFormUniqueEmail(request.POST) |
|
|
|
|
if form.is_valid(): |
|
|
|
|
data['success'] = True |
|
|
|
|
else: |
|
|
|
|
data['errors'] = form.errors |
|
|
|
|
return HttpResponse(json.dumps(data), content_type='application/json') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.http import HttpResponse, HttpResponseRedirect |
|
|
|
|
|
|
|
|
|
from accounts.models import User |
|
|
|
|
|
|
|
|
|
from registration.forms import RegistrationFormUniqueEmail |
|
|
|
|
from django.contrib.auth import login, logout, authenticate |
|
|
|
|
|
|
|
|
|
from django.views.decorators.debug import sensitive_post_parameters |
|
|
|
|
from django.views.decorators.cache import never_cache |
|
|
|
|
|
|
|
|
|
@sensitive_post_parameters('password1', 'password2') |
|
|
|
|
@never_cache |
|
|
|
|
def RegisterAjaxView(request): |
|
|
|
|
@ -277,8 +285,6 @@ def complete_registration(request): |
|
|
|
|
else: |
|
|
|
|
return HttpResponse('not ajax') |
|
|
|
|
|
|
|
|
|
from django.shortcuts import render |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def acquire_email(request, template_name="registration/acquire_email.html"): |
|
|
|
|
""" |
|
|
|
|
|