示例#1
0
def questionrecord(request, p=1):
    status = False
    user = getUI(getUsr(request))

    if request.method == 'GET':
        form = QuestionInfoModelForm()
    else:
        form = QuestionInfoModelForm(request.POST, request=request)
        if form.is_valid():
            cleaned_data = form.cleaned_data

            question = cleaned_data['question']
            answer = cleaned_data['answer']
            tag = cleaned_data['tag']

            QuestionInfo.objects.get_or_create(question=question, answer=answer, tag=tag, user=user)

            form = QuestionInfoModelForm()
            status = True

    minequestion = QuestionInfo.objects.filter(user=getUI(getUsr(request)), display=True).order_by('-modify_time')
    questions = pages(minequestion, int(p))
    minequestion = [question.data for question in questions.object_list]

    return render(
        request,
        'huntjob/question/record.html',
        dict(blog=minequestion, pages=questions, next_url='huntjob:questionmine', form=form, status=status, **getQuestionDict(request))
    )
示例#2
0
def questionedit(request):
    if request.method == 'POST':
        minequestion, created = QuestionInfo.objects.get_or_create(user=getUI(getUsr(request)), display=True)
        form = QuestionInfoModelForm(request.POST, request.FILES, instance=minequestion)
        if form.is_valid():
            form.save()

    try:
        minequestion = model_to_dict(QuestionInfo.objects.get(user=getUI(getUsr(request)), display=True))
        form = QuestionInfoModelForm(minequestion)
    except Exception:
        form = QuestionInfoModelForm()

    return render(
        request,
        'huntjob/question/edit.html',
        dict(form=form, userinfo=getUI(getUsr(request)), **getQuestionDict(request))
    )
示例#3
0
def questionrecord(request, p=1):
    status = False
    user = getUI(getUsr(request))

    if request.method == "GET":
        form = QuestionInfoModelForm()
    else:
        form = QuestionInfoModelForm(request.POST, request=request)
        if form.is_valid():
            cleaned_data = form.cleaned_data

            question = cleaned_data["question"]
            answer = cleaned_data["answer"]
            tag = cleaned_data["tag"]

            QuestionInfo.objects.get_or_create(question=question, answer=answer, tag=tag, user=user)

            form = QuestionInfoModelForm()
            status = True

    minequestion = QuestionInfo.objects.filter(user=getUI(getUsr(request)), display=True).order_by("-modify_time")
    questions = pages(minequestion, int(p))
    minequestion = [question.data for question in questions.object_list]

    return render(
        request,
        "huntjob/question/record.html",
        dict(
            blog=minequestion,
            pages=questions,
            next_url="huntjob:questionmine",
            form=form,
            status=status,
            **getQuestionDict(request)
        ),
    )
示例#4
0
def questionedit(request):
    if request.method == "POST":
        minequestion, created = QuestionInfo.objects.get_or_create(user=getUI(getUsr(request)), display=True)
        form = QuestionInfoModelForm(request.POST, request.FILES, instance=minequestion)
        if form.is_valid():
            form.save()

    try:
        minequestion = model_to_dict(QuestionInfo.objects.get(user=getUI(getUsr(request)), display=True))
        form = QuestionInfoModelForm(minequestion)
    except:
        form = QuestionInfoModelForm()

    return render(
        request,
        "huntjob/question/edit.html",
        dict(form=form, userinfo=getUI(getUsr(request)), **getQuestionDict(request)),
    )