|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.contrib.sites.models import RequestSite |
|
|
|
|
from django.contrib.sites.models import Site |
|
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
|
|
|
|
|
|
from registration import signals |
|
|
|
|
from registration.models import RegistrationProfile |
|
|
|
|
@ -187,6 +188,35 @@ def RegisterAjaxView(request): |
|
|
|
|
# 404 |
|
|
|
|
# return HttpResponse('not ajax') |
|
|
|
|
|
|
|
|
|
def RegisterReply(request): |
|
|
|
|
if request.GET: |
|
|
|
|
email = request.GET['email'] |
|
|
|
|
try: |
|
|
|
|
user = User.objects.get(username=email) |
|
|
|
|
except User.DoesNotExist: |
|
|
|
|
response = {'errors': {'email': _(u'Пользователя с таким email не существует')}} |
|
|
|
|
return HttpResponse(json.dumps(response), content_type='application/json') |
|
|
|
|
if user.is_active: |
|
|
|
|
response = {'errors': {'email': _(u'Пользователя с таким email уже активирован')}} |
|
|
|
|
return HttpResponse(json.dumps(response), content_type='application/json') |
|
|
|
|
else: |
|
|
|
|
try: |
|
|
|
|
registration_profile = user.registrationprofile_set.all()[0] |
|
|
|
|
except IndexError: |
|
|
|
|
registration_profile = RegistrationProfile.create_profile(user) |
|
|
|
|
if Site._meta.installed: |
|
|
|
|
site = Site.objects.get_current() |
|
|
|
|
else: |
|
|
|
|
site = RequestSite(request) |
|
|
|
|
registration_profile.send_activation_email(site) |
|
|
|
|
response = {'success': True} |
|
|
|
|
return HttpResponse(json.dumps(response), content_type='application/json') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
return HttpResponse('no data') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.contrib.auth.forms import AuthenticationForm |
|
|
|
|
from registration.forms import LoginForm |
|
|
|
|
|
|
|
|
|
@ -210,6 +240,8 @@ def LoginView(request): |
|
|
|
|
#return HttpResponseRedirect(request.META.get('HTTP_REFERER','/')) |
|
|
|
|
else: |
|
|
|
|
response={'success':False, 'errors': form.errors} |
|
|
|
|
if getattr(form, 'inactive'): |
|
|
|
|
response.update({'inactive': True}) |
|
|
|
|
|
|
|
|
|
return HttpResponse(json.dumps(response), content_type='application/json') |
|
|
|
|
|
|
|
|
|
|