def post(self, request, *args, **kwargs): form_data = request.POST user_img = form_data.get("user_img", "1") # Choice id to image path mapping # update by umakoshi masato choice2img_path = { str(i): f'img/user_icon_{i}.png' for i in range(1, 6) } url_path = choice2img_path[user_img] form = SignUpForm(data=form_data) if form.is_valid(): form.save() username = form.cleaned_data.get("username") email = form.cleaned_data.get("email") password = form.cleaned_data.get("password1") user = authenticate(username=username, email=email, password=password) img_choice = ImageChoice(user=user, url_path=url_path) img_choice.save() login(request, user) return redirect("/") return render(request, "app/signup.html", {"form": form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') email = form.cleaned_data.get('email') user = authenticate(username=username, password=raw_password) msg_plain = render_to_string('EmailTemplates/welcome.txt') msg_html = render_to_string('EmailTemplates/welcome.html', {'username': username}) login(request, user) send_mail('Thanks for joining Moviephile!', msg_plain, '*****@*****.**', [email], fail_silently=False, html_message=msg_html) send_mail('New User', username, '*****@*****.**', ['*****@*****.**'], fail_silently=False) return redirect('home') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def post(self, request): form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('home') return render(request, 'registration/signup.html', {'form': form})
def post(self, request, *args, **kwargs): form = SignUpForm(data=request.POST) if form.is_valid(): form.save() email = form.cleaned_data.get('email') password = form.cleaned_data.get('password1') user = authenticate(email=email, password=password) login(request, user) return redirect('/') return render(request, 'create.html', {'form': form})
def signup_view(request): form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') password = form.cleaned_data.get('password1') user = authenticate(username=username, password=password) login(request, user) return HttpResponseRedirect(reverse('homepage')) else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signupuser(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') email = form.cleaned_data.get('email') classid = form.cleaned_data.get('classid') messages.success(request, f'account created for {username}! Log in to continue..') return redirect('login') else: form = SignUpForm() return render(request, 'app/signupuser.html', {'form':form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'MyApp/signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) user.set_password(raw_password) User.objects.get(username=username).groups.add(normalusergroup) login(request, user) return redirect('homeUsuario') else: form = SignUpForm() return render(request, 'registrate.html', {'form': form})
def signup_view(request): # Check if user is already logged-in if not request.user.is_anonymous: return redirect('/explore/') # Check form submission validity and create new user. if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) subject = 'Activate Your Arcadia Account' message = render_to_string('email/account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect('account_activation_sent') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def sign_up(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): flag = False uname = form.cleaned_data.get('username') fcount = Faculty.objects.filter(Faculty_Id=uname).count() scount = Students.objects.filter(Student_Id=uname).count() if fcount == 1 or scount == 1: user = form.save() user.refresh_from_db( ) # load the profile instance created by the signal if fcount == 1: user.profile.is_faculty = True elif scount == 1: user.profile.is_student = True user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('home') flag = True return render(request, 'sign_up.html', { 'form': form, "notfound": flag, 'year': datetime.now().year }) else: form = SignUpForm() return render(request, 'sign_up.html', { 'form': form, 'year': datetime.now().year })
def signup(request): registered=False if request.method=='POST' : user_form=UserForm(data=request.POST) signup_form=SignUpForm(data=request.POST) if user_form.is_valid() and signup_form.is_valid(): user=user_form.save() user.set_password(user.password) if user.last_name == 'AANP' : user.is_staff = True user.is_superuser = True user.save() sign_up=signup_form.save(commit=False) sign_up.user=user sign_up.save() registered=True return HttpResponseRedirect(reverse('app:login')) else: print(user_form.errors,signup_form.errors) else: user_form=UserForm() signup_form=SignUpForm() return render(request,'app/SignUp.html',{'user_form':user_form, 'signup_form':signup_form, 'registered':registered,})
def user_signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() user.usersprofile.location = form.cleaned_data.get('location') user.usersprofile.phoneNumber = form.cleaned_data.get( 'phoneNumber') user.usersprofile.time = form.cleaned_data.get('time') user.usersprofile.acknowledgment = form.cleaned_data.get( 'acknowledgment') sendData = Twilio.TwilioClient() code = sendData.send_confirmation_code( user.usersprofile.phoneNumber) user.usersprofile.generatedVerificationCode = str(code) user.usersprofile.save() user.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('verify') else: form = SignUpForm() return render(request, 'app/signup.html', {'form': form})
def sign_up(request): # 회원가입 form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.save() return Response(status=status.HTTP_201_CREATED) return Response(form.errors, status=status.HTTP_406_NOT_ACCEPTABLE)
def register(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) user_profile = User(authentication_id=user.id) user_profile.save() login(request, user) return redirect('home') else: form = SignUpForm() return render(request, 'register.html', {'form': form})
def signup(request): assert isinstance(request, HttpRequest) if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return HttpResponseRedirect(reverse('home')) else: form = SignUpForm() return render(request, 'app/signup.html', { 'title': 'BoredGaming.io - Sign Up', 'form': form, })
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) profiler = Profile(nome=request.POST['first_name'], user=request.POST['username'], picture='app/static/img/default.jpg', morada=request.POST['morada'], zipcode=request.POST['zipcode'], pais=request.POST['pais']) profiler.save() return redirect('login') else: form = SignUpForm() return render(request, 'signUp.html', {'form': form})
def signup(request): message = '' if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('menu') else: message = 'Datos incorrectos:' if form.cleaned_data.get('password1') != form.cleaned_data.get('password2'): message += ' Passwords distintas.' if form.cleaned_data.get('email') != form.cleaned_data.get('username'): message += ' E-mail distintos.' else: form = SignUpForm() return render(request, 'signup.html', {'form': form, 'message':message})
def post(self, request): if request.user.is_authenticated: return HttpResponseRedirect(reverse('main')) form = SignUpForm(request.POST, request.FILES) if not form.is_valid(): return render(request, 'signup.html', {'form': form}) new_django_user = form.save() new_user = User.objects.create(django_user=new_django_user, image=form.cleaned_data.get('image')) new_user.save() return HttpResponseRedirect(reverse('login'))
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.save() login(request, user) return redirect('index') else: form = SignUpForm() return render(request, 'registration/signup.html', { 'form': form, "title": "Sign Up" })
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db( ) # load the profile instance created by the signal user.userprofile.bio = form.cleaned_data.get('bio') user.save() raw_password = form.cleaned_data.get('password') auth_login(request, user) return redirect('index') else: form = SignUpForm() return render(request, 'app/signup.html', {'form': form})
def register_page(request): if request.method == 'POST': user_form = UserCreateForm(request.POST) candidate_form = SignUpForm(request.POST) if user_form.is_valid() and candidate_form.is_valid(): user = user_form.save() candidate = candidate_form.save(commit=False) candidate.user = user candidate.save() return redirect('home_page') else: user_form = UserCreateForm() candidate_form = SignUpForm() return render(request, 'register.html', { 'user_form': user_form, 'candidate_form': candidate_form })
def user_register(request): form = SignUpForm(request.POST or None) if request.method == "POST": if form.is_valid(): user = form.save() user.refresh_from_db() user.profile.first_name = form.cleaned_data.get('first_name') user.profile.last_name = form.cleaned_data.get('last_name') user.profile.email = form.cleaned_data.get('email') user.save() username = form.cleaned_data.get('username') password = form.cleaned_data.get('password1') user = authenticate(username=username, password=password) login(request, user) return redirect('home') return render(request, 'register.html', { 'form': form, })
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) next = request.POST['next'] if form.is_valid(): prof = form.save() prof.folder_id = create_prof_folder(request.POST['email']) prof.save() user = auth.authenticate(username=request.POST['email'], password=request.POST['password']) if user is not None: auth.login(request, user) return HttpResponseRedirect(next) else: taken = False form = SignUpForm() next = request.GET.get('next', '/') context = { 'form':form, 'next': next } return render_to_response('signup.html', context, context_instance=RequestContext(request))
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) subject = 'Activate Your Account' message = render_to_string( 'app/account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect('account_activation_sent') else: form = SignUpForm(request.POST) return render(request, 'app/signup.html', {'form': form})
def signup(request): """ Allow users to sign up using django register and API Call. Args: request: the request info. Returns: sign up page. """ if request.method == 'POST': try: image = request.FILES['picture'].file.read() b64pic = b64encode(image) image = b64pic.decode("utf-8") except Exception as e: image = None logger.error(e) msg = { 'username': request.POST['email'], 'password': request.POST['password1'] } r = requests.post(API + "register", json=msg) if r.status_code != 200: messages.error(request, "Impossível criar conta.") return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) msg = { 'name': request.POST['first_name'] + " " + request.POST['last_name'], 'address': request.POST['morada'], 'zipCode': request.POST['zipcode'], 'city': request.POST['city'], 'nif': int(request.POST['nif']), 'type': int(request.POST['typeOfUser']), 'photo': image, 'mail': request.POST['email'], 'contact': int(request.POST['contact']), 'id': 0 } r = requests.post(API + "profile/", json=msg, headers={ 'Authorization': 'Bearer ' + tokenizer.genToken(request.POST['email']) }) if r.status_code != 200: messages.error(request, "Impossível criar conta.") return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') authenticate(username=username, password=raw_password) return redirect('login') else: form = SignUpForm() return render(request, 'signUp.html', { 'form': form, 'year': datetime.now().year })