本文整理汇总了Python中accounts.models.UserProfile.verify_token方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.verify_token方法的具体用法?Python UserProfile.verify_token怎么用?Python UserProfile.verify_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.verify_token方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view_jobs
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import verify_token [as 别名]
def view_jobs(request):
key = request.GET.get('key', None)
user = UserProfile.verify_token(key)
if request.method == 'GET':
jobs = Job.objects.all()
context = {'jobs': jobs}
if request.method == 'POST':
jobs_ids = request.POST.getlist('requested_jobs[]')
if request.user.is_anonymous() and (not key or not user):
request.session['add_new_jobs_pending'] = True
request.session['requested_jobs'] = jobs_ids
request.session['redirect_to'] = reverse('jobs')
return HttpResponseRedirect(reverse('account_login'))
context = {}
if not user:
user = request.user
add_interview_requests(request, user, jobs_ids)
return render(request, 'jobs/jobs.html', context)
示例2: apply_success
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import verify_token [as 别名]
def apply_success(request):
key = request.GET.get('key', None)
user = UserProfile.verify_token(key)
if not key or not user:
messages.add_message(request, messages.ERROR,
'A valid application key is required to view this page.')
else:
jobs_url = reverse('jobs') + '?key=' + key
availability_url = reverse('available', args=[user.id]) + '?key=' + key
return render(request, 'candidates/apply.html',
{'success': 'success',
'jobs_url': jobs_url,
'availability_url': availability_url
})
示例3: apply
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import verify_token [as 别名]
def apply(request):
key = request.GET.get('key', None)
user = UserProfile.verify_token(key)
if not key and request.method == 'POST':
form = UserApplyStep1Form(request.POST)
if form.is_valid():
data = form.data
first_name = data['first_name']
last_name = data['last_name']
email = data['email']
citizenship = data['citizenship']
skype_id = data['skype_id']
timezone = data['timezone']
user, created = User.objects.get_or_create(
first_name=first_name,
last_name=last_name,
email=email,
username=email
)
if not created:
messages.add_message(request, messages.ERROR,
email + ' has already been registered.')
else:
userprofile = UserProfile(
user=user,
timezone=timezone,
citizenship=citizenship,
skype_id=skype_id,
user_type='Candidate'
)
userprofile.save()
key = user.userprofile.generate_token()
return HttpResponseRedirect(
reverse('candidate_apply') + '?key=' + key)
elif not key and request.method == 'GET':
form = UserApplyStep1Form()
elif key and user and request.method == 'POST':
form = UserApplyStep2Form(request.POST, request.FILES)
if form.is_valid():
files = form.files
data = form.data
try:
candidate = user.candidate
candidate.birth_year = data['birth_year']
candidate.gender = data['gender']
candidate.education = data['education']
candidate.education_major = data['education_major']
candidate.image = files['image']
candidate.save()
except Candidate.DoesNotExist:
candidate = Candidate.objects.create(user=user,
birth_year=data['birth_year'],
gender=data['gender'],
education=data['education'],
education_major=data['education_major'],
image=files['image']
)
CandidateDocument.objects.create(
candidate=candidate,
document=files['resume'],
document_type='Resume'
)
messages.add_message(request, messages.SUCCESS,
'Form submitted successfully.')
return HttpResponseRedirect(
reverse('candidate_apply_success') + '?key=' + key)
elif key and user and request.method == 'GET':
form = UserApplyStep2Form()
else:
messages.add_message(request, messages.ERROR,
'A valid application key is required to submit documents. ' +
'Please contact the administrator.')
form = None
return render(request, 'candidates/apply.html', {'form': form})