def questionnaire_post(request, applicant, pagenum, page): for q in page.questions: answer = request.POST.get(q.name) applicant.answers[q.name] = answer applicant.save(request) if pagenum == len(QUESTIONNAIRE): post = make_forum_post(applicant) mybb = MyBB() tid = mybb.get_tid(APPLICANT_FORUM, applicant.charinfo.characterName) mybb.create_post(APPLICANT_FORUM, "Application Form", applicant.charinfo.characterName, post, tid=tid) applicant.has_applied = True applicant.save(request) return HttpResponseRedirect("/recruitment/apply/") else: return HttpResponseRedirect("/recruitment/apply/%s/" % (pagenum + 1))
def apply_view(request): if not request.user.is_authenticated() or request.user.profile.characterid is None: return direct_to_template(request, "recruitment/need-forum-auth.html") try: applicant = Applicant.from_request(request) except Exception as e: return direct_to_template(request, "recruitment/api-error.html", extra_context={"error": str(e)}) mybb = MyBB() if applicant.has_applied and mybb.get_tid(APPLICANT_FORUM, applicant.charinfo.characterName) is not None: if request.method == "POST": applicant.has_applied = False applicant.save(request) return HttpResponseRedirect("/recruitment/apply/") return direct_to_template(request, "recruitment/already-applied.html", extra_context={"applicant": applicant}) else: return direct_to_template(request, "recruitment/apply.html", extra_context={"applicant": applicant})