本文整理汇总了Python中models.Feedback.scholar方法的典型用法代码示例。如果您正苦于以下问题:Python Feedback.scholar方法的具体用法?Python Feedback.scholar怎么用?Python Feedback.scholar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feedback
的用法示例。
在下文中一共展示了Feedback.scholar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: applicant_profile
# 需要导入模块: from models import Feedback [as 别名]
# 或者: from models.Feedback import scholar [as 别名]
def applicant_profile(request, event_name, name):
try:
applicant = Applicant.objects.get(norm_name=normalize_name(name), event__name=event_name)
except Applicant.DoesNotExist:
raise Http404('Applicant does not exist.')
try:
event = Event.objects.get(name=event_name)
except Event.DoesNotExist:
raise Http404('Event does not exist')
try:
feedback = Feedback.objects.get(applicant=applicant, scholar=request.user.mcuser)
except Feedback.DoesNotExist:
feedback = Feedback()
feedback.applicant = applicant
feedback.scholar = request.user.mcuser
if request.method == 'POST':
form = FeedbackForm(request.POST, instance=feedback)
if (form.is_valid()):
form.save()
if request.is_ajax():
return JsonResponse({'msg': 'saved successfully'})
return redirect('feedback:index', event_name)
else:
form = FeedbackForm(instance=feedback)
all_feedback = Feedback.objects.filter(applicant=applicant)
is_interviewer = request.user.mcuser in event.interviewers.all()
is_assigned = Assignment.objects.filter(scholar=request.user.mcuser, applicant=applicant).exists()
context = {
'feedback': all_feedback,
'applicant': applicant,
'form': form,
'state': get_state(),
'event_name': event_name,
'survey_link': event.survey_link,
'is_interviewer': is_interviewer and is_assigned,
'favorited': favorited(request.user.mcuser, applicant)
}
return render(request, 'feedback/applicant.html', context)