本文整理汇总了Python中accounts.models.UserProfile.terms方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.terms方法的具体用法?Python UserProfile.terms怎么用?Python UserProfile.terms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.terms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_customer
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import terms [as 别名]
def add_customer(request):
form = RegistrationFormAdmin()
if request.method == "POST":
form = RegistrationFormAdmin(request.POST)
if form.is_valid():
username = generate_username(form.cleaned_data['first_name'],
form.cleaned_data['last_name'],
)
random_password = get_pronounceable_password()
user = User.objects.create_user(
username,
form.cleaned_data['email'],
random_password
)
user.first_name = form.cleaned_data['first_name']
user.last_name = form.cleaned_data['last_name']
user.is_active = True
user.save()
userprofile = UserProfile()
userprofile.title = form.cleaned_data['title']
userprofile.date_of_birth = form.cleaned_data['date_of_birth']
userprofile.phone = form.cleaned_data['phone']
userprofile.terms = form.cleaned_data['terms']
userprofile.user = user
userprofile.save()
address = Address()
address.line_1 = form.cleaned_data['line_1']
address.line_2 = form.cleaned_data['line_2']
address.city = form.cleaned_data['city']
address.county = form.cleaned_data['county']
address.postcode = form.cleaned_data['postcode']
address.user = user
address.save()
send_admin_welcome_email(user, random_password)
return HttpResponseRedirect('/admin/accounts/userprofile/')
else:
form = RegistrationFormAdmin(request.POST)
return render_to_response('admin/accounts/add_customer.html',
{'form': form}, context_instance=RequestContext(request))
示例2: login_register
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import terms [as 别名]
def login_register(request, *args):
next_url = '/'
message = None
if request.GET.has_key('next'):
next_url = request.GET.get('next')
if request.method == 'POST':
if "register" in request.POST:
registration_form = RegistrationForm(request.POST)
if registration_form.is_valid():
username = generate_username(
registration_form.cleaned_data['first_name'],
registration_form.cleaned_data['last_name']
)
user = User.objects.create_user(
username,
registration_form.cleaned_data['email'],
registration_form.cleaned_data['password'],
)
user.first_name = registration_form.cleaned_data['first_name']
user.last_name = registration_form.cleaned_data['last_name']
user.is_active = True
user.save()
user_profile = UserProfile()
user_profile.title = registration_form.cleaned_data['title']
user_profile.date_of_birth = registration_form.cleaned_data['date_of_birth']
user_profile.phone = registration_form.cleaned_data['phone']
user_profile.user = user
user_profile.terms = registration_form.cleaned_data['terms']
user_profile.save()
# Billing address
address = Address()
address.line_1 = registration_form.cleaned_data['line_1']
address.line_2 = registration_form.cleaned_data['line_2']
address.city = registration_form.cleaned_data['city']
address.county = registration_form.cleaned_data['county']
address.postcode = registration_form.cleaned_data['postcode']
address.user = user
address.save()
messages.info(request, "Congratulations, you have successfully registered with Pleasures All Mine.")
send_welcome_email(user_profile.user)
user = authenticate(
username=registration_form.cleaned_data['email'],
password=registration_form.cleaned_data['password']
)
login_after_registration(request, user)
return HttpResponseRedirect(next_url)
else:
registration_form = RegistrationForm(data=request.POST)
messages.warning(request, "Sorry, but you missed something, please fill all required fields.")
if 'login' in request.POST:
login_form = LoginForm(data=request.POST)
if login_form.is_valid():
user = authenticate(username=login_form.cleaned_data['username'],
password=login_form.cleaned_data['password'])
if user is not None:
if not request.POST.get('remember_me', None):
request.session.set_expiry(0)
messages.success(request, "Welcome to Pleasures All Mine, you have successfully logged in.")
return login(request, authentication_form=LoginForm,)
else:
login_form = LoginForm()
registration_form = RegistrationForm()
messages.warning(request, "Sorry, but you missed something, please fill all required fields.")
else:
messages.warning(request, "Sorry, but the username or password you have entered is incorrect, please try again.")
login_form = LoginForm()
registration_form = RegistrationForm()
else:
login_form = LoginForm()
else:
registration_form = RegistrationForm()
login_form = LoginForm()
return render_to_response(
'accounts/login_register.html',
{
'registration_form': registration_form,
'login_form': login_form,
'message': message,
'next_url': next_url,
}, RequestContext(request) )