def signup_confirmed(request): if request.method != 'POST': return HttpResponseRedirect('/') signup_form = UserCreationForm(request.POST) if signup_form.is_valid(): signup_form.clean_username() signup_form.clean_password2() user = signup_form.save() # TODO: 회원가입이 완료되었다는 메시지 # UserProfile 이어주기 UserProfile.objects.create(user=user) else: return render_to_response( 'accounts/signup.html', RequestContext(request, { 'form': signup_form, 'errors': signup_form.errors })) return HttpResponseRedirect('/')
def test_clean_username_exception(self): # set up the form for testing form = UserCreationForm() form.cleaned_data = {'username': self.test_name} # use a context manager to watch for the validation error being raised with self.assertRaises(ValidationError): form.clean_username()
def test_clean_username_pass(self): # set up the form for testing form = UserCreationForm() form.cleaned_data = {'username': self.test_other_name} # use a context manager to watch for the validation error being raised self.assertEquals(form.clean_username(), self.test_other_name)
def create_user(request): if request.method == 'POST': user_form = UserCreationForm(request.POST) if user_form.is_valid(): username = user_form.clean_username() password = user_form.clean_password2() user_form.save() user = authenticate(username=username, password=password) user.first_name = request.POST[u'first_name'] user.last_name = request.POST[u'last_name'] user.save() login(request, user) return welcome(request) else: return render_to_response('create_user.html', { 'form': user_form, }, context_instance=RequestContext(request)) return render_to_response('create_user.html', { 'form': UserCreationForm(), }, context_instance=RequestContext(request))
def post(self, request, *args, **kwargs): form = UserCreationForm(request.POST) if form.is_valid(): username = form.clean_username() user_full_name = form.cleaned_data['first_name'] password = form.clean_password2() form.save() user = authenticate(username=username, password=password) login(request, user) userAccount = User_Account(pk=user.pk,user=user,user_full_name=user_full_name) userAccount.save() registration_subject = Activity.objects.all()[0].registration_email_subject registration_email_from = Activity.objects.all()[0].registration_email_from registration_content = Activity.objects.all()[0].registration_email_message activity_content = Activity.objects.all()[0].activity_registration activity_to = Activity.objects.all()[0].activity_email serverTZ = pytz.timezone(settings.TIME_ZONE) serverToday = serverTZ.localize(datetime.datetime.now()) c = { 'username': request.user.first_name.title(), 'articles_url': reverse('articles:index'), 'consultations_url': reverse('consultations:index'), 'professionals_url': reverse('professionals:index'), 'categories_url': reverse('categories:index'), 'contact_url': reverse('home:contactus'), 'user_email': request.user.username, 'from_email': registration_email_from, 'current_date': serverToday } html = registration_content t = Template(html) con = Context(c) message = t.render(con) #No need to make a connection #connection = get_connection(fail_silently=False,host="mail.gonaturalistic.com",port="465",username="******",password="******",use_tls=True) #msg = EmailMessage(registration_subject,message,registration_email_from,[username],connection=connection) msg = EmailMessage(registration_subject,message,registration_email_from,[username]) msg.content_subtype = "html" msg.send() activity_subject = "GoNaturalistic New Member" html = activity_content t = Template(html) con = Context(c) activity_message = t.render(con) msg2 = EmailMessage(activity_subject,activity_message,registration_email_from,[activity_to]) msg2.content_subtype = "html" msg2.send() if self.request.is_ajax(): data = {'user': '******'} return self.render_to_json_response(data) else: if self.request.is_ajax(): #data = {'user': '******'} return self.render_to_json_response(form.errors)
def register_user(request): form = UserCreationForm(request.POST or None) if form.is_valid(): username = form.clean_username() password = form.clean_password2() form.save() user = authenticate(username=username, password=password) login(request, user) return redirect(reverse('core:index')) return render(request, 'core/register.html', {'form': form})
def register_user(request): form = UserCreationForm(request.POST or None) if form.is_valid(): username = form.clean_username() password = form.clean_password2() form.save() user = authenticate(username=username, password=password) login(request, user) return redirect(reverse('core:index')) return render(request, 'core/register.html', {'form': form})
def signup_confirmed(request): if request.method != 'POST': return HttpResponseRedirect('/') signup_form = UserCreationForm(request.POST) if signup_form.is_valid(): signup_form.clean_username() signup_form.clean_password2() user=signup_form.save() # TODO: 회원가입이 완료되었다는 메시지 # UserProfile 이어주기 UserProfile.objects.create(user=user) else: return render_to_response('accounts/signup.html', RequestContext(request, { 'form': signup_form, 'errors': signup_form.errors })) return HttpResponseRedirect('/')
def newUser(request): newUserForm = UserCreationForm(request.POST) if not newUserForm.is_valid(): request.method = "GET" return auth_login_view(request, template_name='auth/login.html', extra_context={"newUserForm": newUserForm}) username = newUserForm.clean_username() password = newUserForm.clean_password2() newUserForm.save() user = authenticate(username=username, password=password) auth_login(request, user) return redirect("/")
def register(request): if request.method == 'POST': form = UserCreationForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass username = form.clean_username() password = form.clean_password2() user = User.objects.create_user(username, username, password) user.save() return render_to_response('registered.html') form = UserCreationForm() # A form bound to the POST data return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request))
def register(request): user_form = UserCreationForm(request.POST) if user_form.is_valid(): username = user_form.clean_username() password = user_form.clean_password2() user_form.save() user = authenticate(username=username, password=password) login(request, user) return redirect("profile") return render(request, 'register.html', { 'user_form' : user_form })
def registration(request): args = {} args.update(csrf(request)) form = UserCreationForm(request.POST) if form.is_valid(): username, password = form.clean_username(), form.clean_password2() User.objects.create_user(username, password=password) auth_user = auth.authenticate(username=username, password=password) auth.login(request, auth_user) return HttpResponseRedirect('/') else: form = UserCreationForm() args['form'] = form return render_to_response('registration/registration_form.html', args)
def sign_up(request): if request.user.is_authenticated(): return redirect('/') if request.method == 'GET': return render(request, 'sign_up.html', {'form': UserCreationForm()}) form = UserCreationForm(data=request.POST) if not form.is_valid(): return render(request, 'sign_up.html', {'form': UserCreationForm(), 'error_message': 'Wrong input data. <br>' + str(form.errors)}) users_count = User.objects.filter(username=form.clean_username()).count() if users_count != 0: return render(request, 'sign_up.html', {'form': UserCreationForm(), 'error_message': 'User with selected username already exists.'}) user = User() user.username = form.clean_username() user.set_password(form.clean_password2()) user.save() return redirect('/signin/')
def post(self, request, *args, **kwargs): form = UserCreationForm(data=request.POST) if form.is_valid(): username = form.clean_username() password = form.clean_password2() user = form.save() Stream.objects.create(user=user) instance = authenticate(username=username, password=password) login(request,instance) return redirect('/') return render_to_response('registration/register.html',{'form': form},RequestContext(request))
def post(self, request, *args, **kwargs): form = UserCreationForm(data=request.POST) if form.is_valid(): username = form.clean_username() password = form.clean_password2() user = form.save() Stream.objects.create(user=user) instance = authenticate(username=username, password=password) login(request, instance) return redirect('/') return render_to_response('registration/register.html', {'form': form}, RequestContext(request))
def newUser(request): newUserForm = UserCreationForm(request.POST) if not newUserForm.is_valid(): request.method = "GET" return auth_login_view(request, template_name='auth/login.html', extra_context={"newUserForm": newUserForm}) username = newUserForm.clean_username() password = newUserForm.clean_password2() newUserForm.save() user = authenticate(username=username, password=password) auth_login(request, user) return redirect("/")
def registration_view(request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): username = form.clean_username() pswd = form.clean_password2() new_client = User(username=username, password=pswd, \ registration_date=strftime('%Y-%m-%d %H:%M')) new_client.set_password(pswd) new_client.save() return redirect('/userlist/', permanent=True) else: form = UserCreationForm() return render(request, 'register.html', {'form': form})
def register(request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): username = form.clean_username() password = form.clean_password2() form.save() user = authenticate(username=username, password=password) login(request, user) return HttpResponseRedirect("/library/home/") else: form = UserCreationForm() return render(request, "registration/register.html", { 'form': form, })
def register(request): from django.contrib.auth.forms import UserCreationForm from django.template import RequestContext from django.contrib.auth import authenticate, login if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): name = form.clean_username() passw = form.clean_password2() form.save() user = authenticate(username=name,password=passw) login(request,user) return HttpResponseRedirect(reverse('bookmarks.views.index')) return render_to_response('registration/create.html', { 'form':UserCreationForm(), }, context_instance=RequestContext(request))
def register(request): if request.method == "POST": nexturl = request.POST.get("next") form = UserCreationForm(request.POST) if form.is_valid(): uname = form.clean_username() pwd = form.clean_password2() form.save() user = auth.authenticate(username=uname, password=pwd) auth.login(request, user) nexturl = "query" if nexturl == None else nexturl return redirect(nexturl) else: nexturl = request.GET.get("next") form = UserCreationForm() ctx = RequestContext(request, {"form": form, "next": nexturl}) return render_to_response("register.html", context_instance=ctx)
def register(request): if request.method == 'POST': user_form = UserCreationForm(request.POST) if user_form.is_valid(): username = user_form.clean_username() password = user_form.clean_password2() user_form.save() user = authenticate(username=username, password=password) login(request, user) return HttpResponseRedirect("/accounts/profile/") return render(request, 'register.html', { 'form' : user_form }) else: uf = UserCreationForm() return render_to_response('register.html', {'form': uf}, RequestContext(request))
def register(request): ''' Allow a new user to register ''' if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): username = form.clean_username() password = form.clean_password2() form.save() user = authenticate(username=username, password=password) user.is_staff = True user.save() return HttpResponseRedirect("/login") else: form = UserCreationForm() return render(request, "register.html", { 'form': form, })
def register(request): ''' Allow a new user to register ''' if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): username = form.clean_username() password = form.clean_password2() form.save() user = authenticate(username=username, password=password) user.is_staff = True user.save() return HttpResponseRedirect("/login") else: form = UserCreationForm() return render(request, "register.html", { 'form': form, })