コード例 #1
0
ファイル: views.py プロジェクト: mikel365/Helix-Test
def createinterview(request):
    if request.session['usertype'] == "t":
        if request.POST:
            name = request.POST.get("name")
            group = request.POST.get("group")
            interview = Interview(name=name, group=group, user=User.objects.get(username=request.session['username']))
            interview.save()
            choices = [x for x in request.POST if x.startswith("ch")]
            for x in choices:
                choice = InterviewChoice(interview=interview, name=request.POST.get(x))
                choice.save()
            return redirect("/")
    return render(request, 'studtests/createint.html',
                  {'username': request.session['username'], 'usertype': request.session['usertype']})
コード例 #2
0
ファイル: views.py プロジェクト: mikel365/Helix-Test
def create_int_andr(request):
    int_name = request.POST.get("int_name")
    group = request.POST.get("group")
    choices = request.POST.get("choices").split("/")
    user = User.objects.get(pk=int(request.POST.get("user_id")))
    interview = Interview(name=int_name, user=user, group=group)
    exist = False
    try:
        int_ = Interview.objects.get(name=int_name)
        if int_.group == group:
            exist = True
    except:
        exist = False
    if not exist:
        interview.save()
        for x in choices:
            choice = InterviewChoice(interview=interview, name=x)
            choice.save()
            print choice
    return HttpResponse("done")