def homepage(request): currency = CURRENCY welcome_page, categories, offer, banners, front_page_messages, second_banners, footer, footer_cat, user_terms, cart_items = get_initial_page_data(request) eshop_identity = CompanyInfo.objects.get(id=1) last_products = Product.my_query.active_for_site()[:20] brands = Brands.objects.all() posts = Post.objects.all() if 'register_post' in request.POST: register_form = RegisterForm(request.POST) if register_form.is_valid(): register_form.save() return HttpResponseRedirect(request.META.get('HTTP_REFERER')) else: register_form = RegisterForm() if 'search_pro' in request.POST: search_text = request.POST.get('search_pro') return redirect(reverse('page_results') + '?search_pro=%s'%(search_text)) if 'newsletter' in request.POST: newsletter_form = NewsLetterForm(request.POST) if newsletter_form.is_valid(): newsletter_form.save() messages.success(request, 'Το email σας καταχωρήθηκε!') return HttpResponseRedirect('/') else: newsletter_form = NewsLetterForm() if request.POST: username= request.POST.get('email-modal') password = request.POST.get('password-modal') user = auth.authenticate(username=username,password=password) if user: auth.login(request,user) return HttpResponseRedirect(request.META.get('HTTP_REFERER')) context = locals() context.update(csrf(request)) return render(request, 'obaju/index.html',context)
def sign(request): if request.method == "GET": return render(request, 'sign.html', {"error": ""}) else: if "register" in request.POST: form = RegisterForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("sign")) else: return render(request, 'sign.html', {"error": form.errors}) elif "login" in request.POST: form = LoginForm(request.POST) if form.is_valid(): user = User.objects.filter(username=form.cleaned_data["username"]).first() if user: valid = user.check_password(form.cleaned_data["password"]) else: valid = False if valid: login(request, user) return HttpResponseRedirect(reverse("home", kwargs={"uuid": "1"})) else: return render(request, 'sign.html', {"error": "نام کاربری یا رمز عبور اشتباه است"}) return render(request, 'sign.html', {"error": form.errors}) return HttpResponse()
def newUser(request): if request.method == "POST": formulario = RegisterForm(request.POST) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/') else: formulario = RegisterForm() return render_to_response('account/newUser.html',{'formNewUser': formulario}, context_instance=RequestContext(request))
def register(request): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') return redirect('login') else: form = RegisterForm() return render(request, 'register.html', {'form': form})
def register(request): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): form.save() new_user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password1']) auth_login(request, new_user) return HttpResponseRedirect('validated') else: form = RegisterForm() return TemplateResponse(request, 'account/register.html', {'form': form})
def register(request): if request.method == "POST": form = RegisterForm(request.POST) if form.is_valid(): form.save() user = authenticate(username=form.cleaned_data.get('username'), password=form.cleaned_data.get('password1')) login(request, user) return redirect('homepage') form = RegisterForm() return render(request, 'pages/register.html', context={ "form": form })
def register(request): if request.POST: form = RegisterForm(request.POST) if form.is_valid(): form.save() messages.success(request, u'恭喜你,注册成功。') do_login(request, authenticate(username=form.cleaned_data['email'], password=form.cleaned_data['password1'])) return shortcuts.redirect(reverse('account-home')) else: form = RegisterForm() return shortcuts.render_to_response('account/register.html', {'form': form}, context_instance=RequestContext(request))
def register(response): try: if response.method == "POST": form = RegisterForm(response.POST) if form.is_valid(): form.save() return redirect("/data_set/index") else: form = RegisterForm() return render(response, "account/register.html", {"form": form}) except: return render("error/error404.html")
def register_view(request): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): form.save() messages.info(request, _("your user has been created but need confirm email")) return HttpResponseRedirect(reverse('home')) else: form = RegisterForm(request.POST) ctx = {"register_form": form } return render(request, "register.html", ctx) else: form = RegisterForm() ctx = {"register_form" : form } return render(request, "register.html", ctx)
def register_user(request): if request.user.is_authenticated: return redirect("index") else: if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): form.save() email = form.cleaned_data.get('email') raw_password = form.cleaned_data.get('password1') user = authenticate(email=email, password=raw_password) login(request, user) return redirect('index') else: form = RegisterForm() return render(request, "account/register.html", {"form": form})
def register(request): if request.user.is_authenticated(): return HttpResponseRedirect("/") else: if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid() and not request.POST['zipcode']: new_user = form.save() new_user = authenticate(username=request.POST['username'], password=request.POST['password1']) login(request, new_user) #new_user.gender = request.POST['gender-radio'] #new_user.save() #userinfo_o = User_info(user_id=request.user)#, dob=request.POST['dob'], gender=request.POST['gender'],) #userinfo_o.save() request.session['new_user'] = 1 newurl = request.POST['next'] if newurl: return HttpResponseRedirect(newurl) else: return HttpResponseRedirect("/") else: form = RegisterForm() return render(request, "signup.html", { 'form': form, })
def user_register(request): ''' 注册 :param request: :return: ''' if request.method == "GET": register_form = RegisterForm() return render(request, 'account/register_bootstrap3.html', locals()) if request.method == "POST": register_form = RegisterForm(request.POST) message = '请检查填写的内容!' if register_form.is_valid(): password1 = register_form.cleaned_data['password1'] password2 = register_form.cleaned_data['password2'] if password1 == password2: new_user = register_form.save(commit=False) new_user.password = password1 new_user.save() return redirect(reverse("account:login")) else: message = "两次输入的密码不一致" return render(request, 'account/register_bootstrap3.html', locals()) # 当提交数据出错时,使用
def register(request): ''' 注册 :param request: :return: ''' if request.method == "POST": print(request.POST) user_form = RegisterForm(request.POST) userpro_form = UserProfileForm(request.POST) if user_form.is_valid() and userpro_form.is_valid(): new_user = user_form.save(commit=False) new_user.set_password(user_form.cleaned_data['password']) new_user.save() new_profile = userpro_form.save(commit=False) new_profile.user = new_user new_profile.save() return HttpResponse("register success") else: return HttpResponse("register fail") else: user_form = RegisterForm() userpro_form = UserProfileForm() return render(request, 'mybuggreport/register.html', { "form": user_form, "user_form": userpro_form })
def register(request): # if request.method == 'POST': # data = request.POST # username = data.get('username') # password1 = data.get('password1') # password2 = data.get('password2') # birth = data.get('birth') # phone = data.get('phone') # email = data.get('email') # 使用form完成注册 if request.method == 'POST': user_form = RegisterForm(request.POST) user_profile_form = UserProfileForm(request.POST) new_user = user_form.save(commit=False) # 从user_form中提取password1 new_user.set_password(user_form.cleaned_data['password1']) # 保存user new_user.save() new_user_profile = user_profile_form.save(commit=False) # 关联user_profile 和 user new_user_profile.user = new_user # 保存user_profile new_user_profile.save() from account.models import UserInfo UserInfo.objects.create(user=new_user) return redirect(reverse("account:user_login")) if request.method == 'GET': # 把注册表单发送给用户 return render(request, 'account/register.html')
def register(request): """ 注册逻辑 :param request: :return: """ if request.method == 'POST': user_form = RegisterForm(request.POST) if user_form.is_valid(): new_user = user_form.save(commit=False) new_user.set_password(user_form.cleaned_data['password']) new_user.save() return redirect('/account/login/') #render(request, 'account/login.html') else: user = User.objects.get( username=user_form.cleaned_data['password']) if user: return render(request, 'account/register.html', {'message': '用户已经注册!'}) else: return render(request, 'account/register.html', {'message': '两次密码输入不一致!'}) else: # 已经登录需要先退出登录 if request.user is not None: # if request.user.is_authenticated(): auth_logout(request) return render(request, 'account/register.html')
def register_post(request): form = RegisterForm(request.POST) if form.is_valid(): user = form.save() login(request, user) return redirect('account') else: return render(request, 'account/pages/register.html', {'form': form})
def register_view(request): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): form.save() messages.info( request, _("your user has been created but need confirm email")) return HttpResponseRedirect(reverse('home')) else: form = RegisterForm(request.POST) ctx = {"register_form": form} return render(request, "register.html", ctx) else: form = RegisterForm() ctx = {"register_form": form} return render(request, "register.html", ctx)
class Register(DetailEndpoint): model = Account form = RegisterForm() def get(self, request, *args, **kwargs): if request.user.is_authenticated(): messages.error(request, 'Вы авторизированы') return redirect('/') return render(request, 'account/register.html', {'form': self.form}) def post(self, request, *args, **kwargs): self.form = RegisterForm(request.POST) if self.form.is_valid(): self.form.save() messages.success(request, 'Удачно зареган, войдите') return redirect('/account/login') return render(request, 'account/register.html', {'form': self.form})
def register(request): name = "OLA" if request.method == "POST": mlf = RegisterForm(request.POST) if mlf.is_valid(): mlf.save() email = mlf.cleaned_data['email'] password = mlf.cleaned_data['password'] try: name = Users.objects.get(email=email, password=password) except ObjectDoesNotExist: pass else: name = "NOT VALID" else: name = "Error" form = RegisterForm(request.POST) return render(request, 'register.html', {"name": name, "phno": form})
def test_create_user(self): """ User creation test """ form = RegisterForm({'username': '******', 'email': '*****@*****.**', 'password1': '12345', 'password2': '12345'}) self.assertTrue(form.is_valid()) user = form.save() self.assertEqual(user.username, 'Admin') self.assertEqual(user.email, '*****@*****.**')
def register_view(request): if request.method=="POST": form = RegisterForm(request.POST) if form.is_valid(): user = form.save() login(request, user) return redirect('home',{'user':user}) else: form = RegisterForm() return render(request, 'signUp.html',{'form':form})
def register(request): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.set_password(form.cleaned_data['password']) user.save() return redirect(user_login) messages.error(request, 'formulaire non valid') else: form = RegisterForm() return render(request, 'registration/register.html', {'form': form})
def register_view(request): msg = "" if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): user = form.save() user.set_password(user.password) user.save() return redirect('home') else: msg = form._errors form = RegisterForm() return render(request, 'register.html', {'form': form, 'msg': msg})
def teacher(request): if request.method == 'POST': user_form = RegisterForm(request.POST) if user_form.is_valid(): new_user = user_form.save(commit=False) new_user.set_password('password') new_user.is_teacher = True new_user.save() return redirect('employes:teacher_profile_add') return redirect('employes:teacher_list') else: user_form = RegisterForm() return render(request, 'employes/dashbord/teacher_add.html', {'user_form': user_form})
def sign(request): if request.method == "GET": return render(request, 'sign.html', {"error": ""}) else: if "register" in request.POST: form = RegisterForm(request.POST) if form.is_valid(): form.save() elif "login" in request.POST: form = LoginForm(request.POST) if form.is_valid(): user = User.objects.filter( email=form.cleaned_data["email"]).first() if user: valid = user.check_password(form.cleaned_data["password"]) else: valid = False if valid: login(request, user) return HttpResponseRedirect(reverse("home")) return render(request, 'sign.html', {"error": "ایمیل یا پسورد اشتباه می باشد."}) return HTTPResponse()
def register_page(request): is_guest = False if request.user.is_authenticated(): is_guest = hasattr(request.user, 'additional') and request.user.additional.is_guest if not is_guest: return redirect('/') if request.POST: form = RegisterForm(data=request.POST) if form.is_valid(): user = form.save() messages.success(request, 'Successfully registered, you can now login') return redirect('/') return render(request, 'register.html', {'form': form}) return render(request, 'register.html', {'form': RegisterForm()})
def home(request): courses = Courses.objects.all() if request.method == 'POST': form = RegisterForm(request.POST) contactform = ContactForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.set_password(form.cleaned_data['password']) user.save() messages.success(request, 'Votre compte a ete cree avec succes') else: messages.error(request, 'Verifier vos informations') else: form = RegisterForm() contactform = ContactForm() return render(request, 'home.html', locals())
def register(request): if request.method == 'POST': register_form = RegisterForm(data=request.POST) if register_form.is_valid(): user = register_form.save() user.set_password(user.password) user.save() else: print(register_form.errors) else: register_form = RegisterForm() messages.info( request, 'Thankyou, You have been Registered, Feel Free To Shop') return render(request, 'account/register.html', {"BASE_URL": settings.BASE_URL, 'register_form': register_form})
def perwakilan_penghuni_tambah(request): account = RegisterForm(request.POST or None, prefix='account') perwakilan_penghuni = PerwakilanPenghuniForm(request.POST or None, prefix='perwakilan_penghuni') context = { "perwakilan_penghuni_form" : perwakilan_penghuni, "account_form" : account } if account.is_valid() and perwakilan_penghuni.is_valid(): user = account.save(commit=False) user.user_type = 2 user.save() perwakilan_penghuni_data = perwakilan_penghuni.save(commit=False) perwakilan_penghuni_data.user = user perwakilan_penghuni_data.save() return redirect('admin_kelola:index') return render(request, 'admin_kelola/perwakilan_penghuni/tambah.html', context)
def register_view(request): account = RegisterForm(request.POST or None, prefix='account') admin_skpd = AdminSKPDRegistrationForm(request.POST or None, prefix='admin_skpd') context = { "admin_skpd_form" : admin_skpd, "account_form" : account } if account.is_valid() and admin_skpd.is_valid(): user = account.save(commit=False) user.user_type = 3 user.save() admin_skpd_data = admin_skpd.save(commit=False) admin_skpd_data.user = user admin_skpd_data.save() return redirect('admin_skpd:login') return render(request, 'admin_skpd/auth/register.html', context)
def register_admin_kelola(request): account = RegisterForm(request.POST or None, prefix='account') admin_kelola = AdminKelolaRegistrationForm(request.POST or None, prefix='admin_kelola') context = { "admin_kelola_form" : admin_kelola, "account_form" : account } if account.is_valid() and admin_kelola.is_valid(): user = account.save(commit=False) user.user_type = 1 user.save() admin_kelola_data = admin_kelola.save(commit=False) admin_kelola_data.user = user admin_kelola_data.save() return redirect('admin_kelola:login') return render(request, 'admin_kelola/auth/register.html', context)
def register_view(request): account = RegisterForm(request.POST or None, prefix='account') warga = WargaRegistrationForm(request.POST or None, prefix='warga') context = { "warga_form" : warga, "account_form" : account } if account.is_valid() and warga.is_valid(): user = account.save(commit=False) user.user_type = 4 user.save() warga_data = warga.save(commit=False) warga_data.user = user warga_data.save() return redirect('warga:login') return render(request, 'warga/auth/register.html', context)
def user_register(request): if request.method == 'POST': form = RegisterForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass user = form.save() user.set_password(form.cleaned_data['password']) user.save() # Log user in user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password']) login(request, user) return redirect('/account/') # Redirect to account control panel else: form = RegisterForm() return render_to_response('register.html', { 'form': form }, RequestContext(request))
def register(request): if request.method == 'POST': # 회원가입 데이터 입력하고 버튼 눌렀을 때 user_form = RegisterForm(request.POST) if user_form.is_valid(): new_user = user_form.save(commit=False) new_user.set_password(user_form.cleaned_data['password']) new_user.save() return render(request, 'account/register_done.html', {'new_user': new_user}) else: # 회원가입 폼 나오게 user_form = RegisterForm() return render(request, 'account/register.html', {'form': user_form})
def register(request): if request.method == 'GET': context = {} context['form'] = RegisterForm return render(request, "register.html", context) elif request.method == 'POST': context = {} form = RegisterForm(request.POST) if form.is_valid(): user = form.save() user.set_password(form.cleaned_data.get('password')) user.save() login_user(request, user) return redirect(reverse('login')) else: pass return render(request, "register.html", context)
def post(self, request): form = RegisterForm(request.POST) if form.is_valid(): if form.cleaned_data['password_repeat'] == form.cleaned_data['password']: user = form.save() self.send_registation_email(user) messages.success(request, "Er is een verificatie email gestuurd naar je emailadres. Kijk hier eerst naar") return redirect("account:login") messages.error(request, "De wachtwoorden kwamen niet overeen!") self.context['form'] = form return render(request, self.template, self.context)
def register(request): # user_form = UserCreationForm() user_form = RegisterForm() user_profile_form = UserProfileForm() if request.POST: user_form = RegisterForm(request.POST) if user_form.is_valid(): u = user_form.save() g = Group.objects.get(name='player') g.user_set.add(u) profile = u.profile user_profile_form = UserProfileForm(request.POST, instance=profile) user_profile_form.save() return HttpResponseRedirect(reverse('account:register')) context = { 'user_form': user_form, 'user_profile_form': user_profile_form, } return render(request, 'account/register.html', context)
def register(request, token): if not token: return HttpResponseRedirect('/') try: account = Account.objects.get(token=token, user__is_active=False) except Account.DoesNotExist: return HttpResponseRedirect('/') is_registered = False if request.method == 'GET': form = RegisterForm(instance=account) SocialFormSet = inlineformset_factory(Account, Social, fk_name='account', extra=0) return render_to_response('account/registration.html', RequestContext(request, {'form': form, 'social_formset': SocialFormSet(instance=account)})) if request.method == 'POST': n = request.POST.get('name_register', None) if n: name, created = Name.objects.get_or_create(genitive=n) form = RegisterForm(request.POST, instance=account) SocialFormSet = inlineformset_factory(Account, Social, fk_name='account') social_formset = SocialFormSet(request.POST, instance=account) if form.is_valid() and social_formset.is_valid(): account = form.save(commit=False) account.name = name account.anonym = False account.save() social_formset.save() is_registered = True if not name.moderation: return HttpResponse(json.dumps({'status': True, 'redirect': '/', 'message': u'Регистрация прошла успешно'}), 'json') else: mail_admins( u'Регистрация нового пользователя. Необходима модерация имени.', u'Пользователем {user} зарегистрировано новое имя "{name}". Дата: {date}'.format(name=name.genitive, user=account.user.username, date=datetime.now()) ) html = render_to_string('names/popup__name_register.html', RequestContext(request, {'form': NameForm(instance=name), 'name': name})) return HttpResponse(json.dumps({'status': True, 'html': html, 'message': u'Ваша учетная запись зарегистрирована, но находится на модерации, пока вы не сможете пользоваться возможностями, доступными зарегистрированнным пользователям'}), 'json') return render_to_response('account/registration.html', RequestContext(request, {'form': form, 'social_formset': social_formset, 'is_registered': is_registered}))
def register_user(request): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): # save form, it gets user object user = form.save() # get user profile profile = user.get_profile() # send activation email to user send_account_activation_email.delay(profile) messages.info(request, _("Thanks for registering. Please check " "your inbox for activation email.")) # Redirect to account home page return redirect("message") else: form = RegisterForm() return render(request, 'account/register.html', { 'form': form, })