本文整理汇总了Python中users.forms.RegistrationForm类的典型用法代码示例。如果您正苦于以下问题:Python RegistrationForm类的具体用法?Python RegistrationForm怎么用?Python RegistrationForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RegistrationForm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: start
def start(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
# user = User.objects.create_user(
# username=form.cleaned_data['username'],
# password=form.cleaned_data['password1'],
# email=form.cleaned_data['email']
# )
user = User(username=form.cleaned_data['username'], password=form.cleaned_data['password1'], email=form.cleaned_data['email'])
user.save()
return HttpResponseRedirect('/users/success/')
else:
form = RegistrationForm()
# 로그인 세션 확인
# 아이디와 비밀번호 비교해서 로그인 성공 시 'login_info' 세션 생성해서 아이디 저장
# request.session['login_info'] = "~~~id" 하고 is_login = TRUE 로 변경
if request.session.get('login_info', False):
is_login = True
else:
is_login = False
print(is_login)
variables = RequestContext(request, {
'form': form,
'is_login': is_login,
})
return render_to_response(
'torch/start.html',
variables,
)
开发者ID:mlf23,项目名称:Torch,代码行数:35,代码来源:views.py
示例2: register_page
def register_page(request):
"""
User can register here to get an account
:param request: HTTP request
:return: HTTP response
"""
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(
username=form.cleaned_data.get('username'),
password=form.cleaned_data.get('password'),
email=form.cleaned_data.get('email')
)
user.save()
subscription = Subscription(name=user,
registration_date=datetime.now(),
last_login_date=datetime.now(),
abo_date=datetime.now() + timedelta(days=30))
subscription.save()
return render(request, "users/register_success.html", {'username': form.cleaned_data['username']})
else:
form = RegistrationForm()
return render(request, "users/register.html", {"form": form})
开发者ID:Bisk1,项目名称:kongming,代码行数:25,代码来源:views.py
示例3: login
def login(request):
login_form = LoginForm()
register_form = RegistrationForm()
next = request.REQUEST.get('next')
if 'kind' in request.POST:
if request.POST['kind'] == 'login':
login_form = LoginForm(request.POST)
if login_form.is_valid():
username = login_form.get_username()
request.session['username'] = username
if next:
return HttpResponseRedirect(next)
return HttpResponseRedirect('/')
elif request.POST['kind'] == 'register':
register_form = RegistrationForm(request.POST)
if register_form.is_valid():
username = register_form.save()
request.session['username'] = username
if next:
return HttpResponseRedirect(next)
return HttpResponseRedirect('/')
context = {
'login_form': login_form,
'register_form': register_form,
'next': next,
}
return render_to_response(
'users/login.html', context, context_instance=RequestContext(request))
开发者ID:Mondego,项目名称:pyreco,代码行数:28,代码来源:allPythonContent.py
示例4: register
def register(request):
if request.is_ajax():
if request.POST['fratname'] and request.POST['university'] and request.POST['email'] and request.POST['type']:
try:
uni = University.objects.get(name=str(request.POST['university']))
except University.DoesNotExist:
uni = University(name=str(request.POST['university']), date = datetime.now())
uni.save()
form = RegistrationForm(request.POST)
clean = form.is_valid()
# Make some dicts to get passed back to the browser
rdict = {'bad':'false'}
errors = ""
if not clean:
rdict.update({'bad':'true'})
for e in form.errors.iteritems():
errors += str(e[1])
else:
date = datetime.now()
org = Organization(university = uni, name=request.POST['fratname'], date = date, type=request.POST['type'])
org.save()
user = User.objects.create_user(request.POST['email'], request.POST['email'], date.isoformat())
user.save()
user.get_profile().chapter = org
user.get_profile().university = uni
user.get_profile().ip = request.META['REMOTE_ADDR']
user.get_profile().save
json = simplejson.dumps(rdict)
return HttpResponse(errors)
return HttpResponse("fail")
开发者ID:cid2105,项目名称:virtual_greek,代码行数:30,代码来源:views.py
示例5: test_email_is_saved
def test_email_is_saved(self):
form = RegistrationForm(data=self.data)
self.assertTrue(form.is_valid())
user = form.save()
self.assertEqual(user.email, '[email protected]')
开发者ID:mlazowik,项目名称:chirrup,代码行数:7,代码来源:test_registrationForm.py
示例6: register
def register(request):
"""
Es invocada cuando hacemos un nuevo registro y se encarga de recoger los datos y almacenarlos.
"""
state = " Se dispone a realizar un nuevo registro.Recuerde que todos los campos son obligatorios"
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
name_user = form.cleaned_data['username']
email_user = form.cleaned_data['email']
pass_user = form.cleaned_data['password1']
create_user = User.objects.create_user(username= name_user, email= email_user, password=pass_user)
create_user.save()
pseudo = "@"+name_user
extend = ExtendUser(user=create_user, pseudo=pseudo)
extend.save()
return redirect('/login')
else:
state = " Error en el registro"
return render_to_response('nuevo.html', {'title':'Registro', 'formulario': form, 'state':state}, context_instance=RequestContext(request))
else:
form = RegistrationForm()
return render_to_response('nuevo.html', {'title':'Registro', 'formulario': form, 'state':state}, context_instance=RequestContext(request))
开发者ID:AdrianHG89,项目名称:DEA_Calidad,代码行数:28,代码来源:views.py
示例7: register
def register(request):
if is_registration_disabled():
raise Http404
if not is_free_rooms():
return HttpResponseRedirect('/waiting/')
title = "Registration"
definition = get_object_or_404(ZosiaDefinition, active_definition=True)
date_1, date_2, date_3, date_4 = definition.zosia_start, (definition.zosia_start + timedelta(days=1)),\
(definition.zosia_start + timedelta(days=2)),\
(definition.zosia_start + timedelta(days=3))
user_form = RegistrationForm(request.POST or None)
pref_form = preferences_form_fabric(definition)(request.POST or None)
org_form = OrganizationForm(request.POST or None)
f1 = user_form.is_valid()
f2 = pref_form.is_valid()
f3 = org_form.is_valid()
if f1 and f2 and f3:
user = user_form.save()
org = org_form.save()
send_confirmation_mail(request, user, definition)
preference = pref_form.save(commit=False)
preference.user = user
preference.org = org
preference.state = definition
preference.save()
return HttpResponseRedirect('/register/thanks/')
return render_to_response('register_form.html', locals())
开发者ID:ksiuwr,项目名称:zapisy_zosia,代码行数:33,代码来源:views.py
示例8: register
def register(request):
if request.POST:
form = RegistrationForm(request.POST, request.FILES)
if form.is_valid():
user = form.save()
email = user.email
first_name = "Claper"
activation_key = create_activation_key(email)
key_expires = datetime.datetime.now() + datetime.timedelta(2)
Activation.objects.create(user=user, activation_key=activation_key, key_expires=key_expires)
send_activation_key(email, activation_key, first_name)
#return redirect('/success/')
resp = {"code": "0"}
resp = json.dumps(resp)
return HttpResponse(resp, content_type="application/json")
else:
#resp = {"response": "fail", 'error': form['email'].errors}
resp = {"code": "1"}
resp = json.dumps(resp)
return HttpResponse(resp, content_type="application/json")
form = RegistrationForm()
return render(request, 'signup.html', {'form': form})
开发者ID:bucherok,项目名称:Clap-1,代码行数:27,代码来源:views.py
示例9: waiting_list
def waiting_list(request):
title = "Registration"
definition = get_object_or_404(ZosiaDefinition, active_definition=True)
date_1, date_2, date_3, date_4 = definition.zosia_start, (definition.zosia_start + timedelta(days=1)),\
(definition.zosia_start + timedelta(days=2)),\
(definition.zosia_start + timedelta(days=3))
if request.POST:
form = WaitingForm(request.POST)
user_form = RegistrationForm(request.POST)
f1 = form.is_valid()
f2 = user_form.is_valid()
if f1 and f2:
user = user_form.save()
send_confirmation_mail(request, user, definition)
waiting = form.save(commit=False)
waiting.state = definition
waiting.user = user
waiting.save()
return HttpResponseRedirect('/register/thanks/')
form = WaitingForm(request.POST)
user_form = RegistrationForm(request.POST)
return render_to_response('waiting.html', {'pref_form': form, 'user_form': user_form,
'date_1': date_1, 'date_2': date_2, 'date_3': date_3, 'date_4': date_4,
'definition': definition})
开发者ID:ksiuwr,项目名称:zapisy_zosia,代码行数:34,代码来源:views.py
示例10: hello
def hello(request, template="users/login.html"):
cc = {}
login_form = LoginForm()
registration_form = RegistrationForm()
if request.method == "POST" and "login_submit" in request.POST:
login_form = LoginForm(request.POST)
if login_form.is_valid():
user = authenticate(
username=login_form.cleaned_data["username"], password=login_form.cleaned_data["password"]
)
login(request, user)
messages.add_message(request, messages.SUCCESS, "Zostałeś zalogowany.")
if "next" in request.GET:
return HttpResponseRedirect(request.GET["next"])
else:
return HttpResponseRedirect(reverse("index"))
elif request.method == "POST" and "registration_submit" in request.POST:
registration_form = RegistrationForm(request.POST)
if registration_form.is_valid():
user_profile = registration_form.save()
user = authenticate(
username=registration_form.cleaned_data["username"],
password=registration_form.cleaned_data["password1"],
)
# send_registration_mail(request.LANGUAGE_CODE, registration_form.cleaned_data['email'], user_profile.activation_key)
return registered(request)
cc["login_form"] = login_form
cc["registration_form"] = registration_form
return render(request, template, Context(cc))
开发者ID:fjern,项目名称:piosenka,代码行数:32,代码来源:views.py
示例11: register
def register(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
form.register(request)
return redirect('users.views.home')
else:
form = RegistrationForm()
return render(request, 'register.hisp', {'form': form})
开发者ID:Soares,项目名称:Green-Primer,代码行数:9,代码来源:views.py
示例12: register
def register(request):
form = RegistrationForm(request.POST or None)
if request.POST and form.is_valid():
form.save()
user = authenticate(username=request.POST['username'],
password=request.POST['password'])
auth_login(request, user)
return render(request, 'registration/register_complete.html')
return render(request, 'registration/register.html', {'form': form})
开发者ID:Osmose,项目名称:charas-playdoh,代码行数:10,代码来源:views.py
示例13: test_user_submits_empty_form
def test_user_submits_empty_form(self):
form_data = {'name': '',
'email': '',
'password': ''}
from users.forms import RegistrationForm
form = RegistrationForm(form_data)
self.assertFalse(form.is_valid())
self.assertTrue(form.errors)
self.assertTrue(form.errors.get('name'))
self.assertTrue(form.errors.get('email'))
self.assertTrue(form.errors.get('password'))
开发者ID:harivenkata,项目名称:glodata,代码行数:11,代码来源:users_forms_tests.py
示例14: test_user_submits_valid_duplicate_data
def test_user_submits_valid_duplicate_data(self):
form_data = {'name': 'Nanda Kishore',
'email': '[email protected]',
'password': '1234'}
from users.forms import RegistrationForm
form = RegistrationForm(form_data)
self.assertFalse(form.is_valid())
self.assertTrue(form.errors)
self.assertFalse(form.errors.get('name'))
self.assertTrue(form.errors.get('email'))
self.assertFalse(form.errors.get('password'))
开发者ID:harivenkata,项目名称:glodata,代码行数:11,代码来源:users_forms_tests.py
示例15: post
def post(self, request, *args, **kwargs):
form = RegistrationForm(request.POST)
password = request.POST.get('password')
if form.is_valid():
user = form.save(commit=False)
user.set_password(password)
user.save()
messages.success(request, 'User Succefully registered.')
return HttpResponseRedirect('/')
ctx = {"form": form}
return render(request, "registration/register.html", ctx)
开发者ID:ARezaK,项目名称:Dr-referral-tracker,代码行数:11,代码来源:views.py
示例16: post
def post(self, *args, **kwargs):
form = RegistrationForm(self.request.POST)
if form.is_valid():
user = form.save(commit=False)
user.user_name = form.cleaned_data['username']
user.email = form.cleaned_data['email']
user.set_password(form.cleaned_data['password'])
user.save()
return HttpResponseRedirect(reverse('bookmark_create'))
return render(self.request, 'registration/register.html', {'form': form})
开发者ID:peteralfredoflynn,项目名称:urly-bird-evolved,代码行数:11,代码来源:views.py
示例17: test_user_submits_invalid_data
def test_user_submits_invalid_data(self):
form_data = {'name': 'Adnan',
'email': 'nonemail',
'password': '1234'}
from users.forms import RegistrationForm
form = RegistrationForm(form_data)
self.assertFalse(form.is_valid())
self.assertTrue(form.errors)
self.assertFalse(form.errors.get('name'))
self.assertTrue(form.errors.get('email'))
self.assertFalse(form.errors.get('password'))
开发者ID:harivenkata,项目名称:glodata,代码行数:11,代码来源:users_forms_tests.py
示例18: register
def register(request):
""" Allows creation of a new user.
"""
form = RegistrationForm(request.DATA)
if form.is_valid():
key = form.save()
data = {
'token': key
}
return OK_RESPONSE(data)
else:
return BAD_RESPONSE(form.errors)
开发者ID:jrcartee,项目名称:know-your-congress,代码行数:12,代码来源:views.py
示例19: test_user_submits_valid_form
def test_user_submits_valid_form(self):
form_data = {'name': 'Adnan',
'email': '[email protected]',
'password': 'empty'}
from users.forms import RegistrationForm
form = RegistrationForm(form_data)
self.assertTrue(form.is_valid())
self.assertFalse(form.errors)
self.assertTrue(form.cleaned_data)
self.assertEquals(form.cleaned_data.get('name'), form_data['name'])
self.assertEquals(form.cleaned_data.get('email'), form_data['email'])
self.assertEquals(form.cleaned_data.get('password'), form_data['password'])
开发者ID:harivenkata,项目名称:glodata,代码行数:12,代码来源:users_forms_tests.py
示例20: signup
def signup(request):
user = request.user
if user.is_authenticated():
return HttpResponseRedirect(reverse_lazy('dashboard'))
form = RegistrationForm()
if request.method == 'POST':
form = RegistrationForm(data=request.POST)
if form.is_valid():
email = form.cleaned_data['email']
password = form.cleaned_data['password']
existing_user = get_object_or_None(AuthUser, email=email)
if existing_user:
msg = _('That email already belongs to someone, please login:')
messages.warning(request, msg)
return HttpResponseRedirect(existing_user.get_login_uri())
else:
# create user
user = AuthUser.objects.create_user(
email=email.lower(),
password=password,
creation_ip=get_client_ip(request),
creation_user_agent=get_user_agent(request),
)
# login user
user_to_login = authenticate(email=email, password=password)
login(request, user_to_login)
# Log the login
LoggedLogin.record_login(request)
msg = _('Login Successful')
messages.success(request, msg)
return HttpResponseRedirect(reverse_lazy('dashboard'))
elif request.method == 'GET':
# Preseed name and/or email if passed through GET string
email = request.GET.get('e')
full_name = request.GET.get('name')
if email or full_name:
form = RegistrationForm(initial={
'email': email,
'full_name': full_name,
})
return {
'form': form,
'is_input_page': True,
}
开发者ID:RIDHA12,项目名称:explorer,代码行数:52,代码来源:views.py
注:本文中的users.forms.RegistrationForm类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论