def subscribe(request,email,lesson_id,token): from django.shortcuts import redirect from django.contrib.auth import authenticate, login from django.http import HttpResponseRedirect uname = email.replace('--att--','@') uname = uname.replace('--dot--','.') lesson = Lesson.objects.get(pk=lesson_id) try: user = UserProfile.objects.get(username=uname) except: user = UserProfile() user.username = uname user.set_password('123') user.is_active = True user.email = uname user.save() user.backend = 'main.auth.ProfileUserModelBackend' login(request, user) try: Subscriber2Lesson.objects.get(lesson=lesson, user=user) except: u2l = Subscriber2Lesson() u2l.user = user u2l.lesson = lesson u2l.save() return redirect('my_profile')
def enter(request,email,token): from django.shortcuts import redirect from django.contrib.auth import authenticate, login from django.http import HttpResponseRedirect uname = email.replace('--att--','@') uname = uname.replace('--dot--','.') try: user = User.objects.get(username=uname) except: user = UserProfile() user.username = uname user.set_password('123') user.is_active = True user.email = uname user.save() user = User.objects.get(username=uname) user.backend = 'main.auth.ProfileUserModelBackend' login(request, user) return redirect('lesson_for_student', id=1)