예제 #1
0
파일: views.py 프로젝트: hrdcdr/academy
def description_add(request):
    if request.method == 'POST':
        descriptionform = DescriptionForm(request.POST)
        if descriptionform.is_valid():
            description = descriptionform.save()
            return HttpResponseRedirect(description.get_absolute_url())
    else:
        descriptionform = DescriptionForm()
    content = {
        'descriptionform': descriptionform,
    }
    content.update(csrf(request))
    return render(request, 'description_edit.html', content)
예제 #2
0
파일: views.py 프로젝트: hrdcdr/academy
def description_add(request):
    if request.method == 'POST':
        descriptionform = DescriptionForm(request.POST)
        if descriptionform.is_valid():
            description = descriptionform.save()
            return HttpResponseRedirect(description.get_absolute_url())
    else:
        descriptionform = DescriptionForm()
    content = {
        'descriptionform': descriptionform,
    }
    content.update(csrf(request))
    return render(request, 'description_edit.html', content)
예제 #3
0
파일: views.py 프로젝트: hrdcdr/academy
def description_edit(request, did):
    description = Description.objects.get(pk=did)
    if request.method == 'POST':
        descriptionform = DescriptionForm(request.POST, instance=description)
        if descriptionform.is_valid():
            description = descriptionform.save()
            return HttpResponseRedirect(description.get_absolute_url())
    else:
        descriptionform = DescriptionForm(instance=description)
    content = {
        'description': description,
        'descriptionform': descriptionform,
    }
    content.update(csrf(request))
    return render(request, 'description_edit.html', content)
예제 #4
0
파일: views.py 프로젝트: hrdcdr/academy
def description_edit(request, did):
    description = Description.objects.get(pk=did)
    if request.method == 'POST':
        descriptionform = DescriptionForm(request.POST, instance=description)
        if descriptionform.is_valid():
            description = descriptionform.save()
            return HttpResponseRedirect(description.get_absolute_url())
    else:
        descriptionform = DescriptionForm(instance=description)
    content = {
        'description': description,
        'descriptionform': descriptionform,
    }
    content.update(csrf(request))
    return render(request, 'description_edit.html', content)
예제 #5
0
파일: views.py 프로젝트: fulloflove/engine
def issue(request, issue_id, context=None):
    if context is None:
        context = {}
    current_issue = get_object_or_404(Issue, pk=issue_id)
    comment_form = CommentForm()
    description_form = DescriptionForm(instance=current_issue)
    report_form = ReportForm(instance=current_issue)
    control_form = ControlForm(instance=current_issue)
    if request.method == 'POST':
        if 'comment_form' in request.POST:
            comment_form = CommentForm(request.POST)
            if comment_form.is_valid():
                curr_comment = comment_form.save(commit=False)
                curr_comment.author = request.user
                curr_comment.issue = current_issue
                curr_comment.save()
                comment_form = CommentForm()
        if 'description_form' in request.POST:
            description_form = DescriptionForm(request.POST, instance=current_issue)
            if description_form.is_valid():
                description_form.save()
                description_form = DescriptionForm(instance=current_issue)
        if 'report_form' in request.POST:
            report_form = ReportForm(request.POST, instance=current_issue)
            if report_form.is_valid():
                report_form.save()
                report_form = ReportForm(instance=current_issue)
        if 'control_form' in request.POST:
            control_form = ControlForm(request.POST, instance=current_issue)
            if control_form.is_valid():
                control_form.save()
                control_form = ControlForm(instance=current_issue)

    context['issue'] = current_issue
    context['comment_form'] = comment_form
    context['description_form'] = description_form
    context['report_form'] = report_form
    context['control_form'] = control_form
    context['status_list'] = Status.objects.all()
    return render(request, 'helpdesk/issue.html', context)