Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def register_step_first(request):
- context = {}
- if request.user.is_authenticated:
- return redirect('/')
- positions = request.POST.get('position', '')
- if request.method == 'POST':
- form = RegisterUserFirstStep(request.POST)
- if form.is_valid():
- main_category = request.POST.get('main_category', '')
- objects = form.save(commit=False)
- objects.step_register = 2
- objects.pos = positions
- objects.main_category = Category.objects.get(id = main_category)
- objects.save()
- login(request, objects, backend='django.contrib.auth.backends.ModelBackend')
- check_session_utm(request, objects)
- sms_confirm = getattr(settings, 'ACCOUNT_SMS_CONFIRMATION', '')
- phone = phonenumbers.parse(objects.username)
- cc = phonenumbers.region_code_for_number(phone)
- send_email_confirmation(request, objects, signup=False)
- if sms_confirm and cc == "RU":
- send_confirmation_code(request, objects)
- return redirect(objects.get_current_step_register(request.path))
- else:
- objects.is_verified = True
- objects.save()
- return redirect(objects.get_current_step_register(request.path))
- else:
- form = RegisterUserFirstStep(request.POST)
- else:
- form = RegisterUserFirstStep()
- context['form'] = form
- context['positions'] = User.get_lector_position()
- context['selectod_position'] = positions
- return render(request, 'account/singup_step_1.html', context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement