示例#1
0
def headlines_add(request):
    if request.method == 'POST':
        form = HeadlineForm(request.POST)
        if form.is_valid():
            headline = form.save(commit=False)
            headline.save()
            headline.logger(str(request.user), " HEADLINE_ADD_EXECUTED")
            messages.success(request, 'Headline added')
            return redirect('/headlines')
    else:
        form = HeadlineForm()
        debug_logger(str(request.user), " HEADLINE_ADD_ENTERED")
    return render(request, 'dfirtrack_main/headline/headlines_add.html', {'form': form})
示例#2
0
def headlines_edit(request, pk):
    headline = get_object_or_404(Headline, pk=pk)
    if request.method == 'POST':
        form = HeadlineForm(request.POST, instance=headline)
        if form.is_valid():
            headline = form.save(commit=False)
            headline.save()
            headline.logger(str(request.user), " HEADLINE_EDIT_EXECUTED")
            messages.success(request, 'Headline edited')
            return redirect('/headlines')
    else:
        form = HeadlineForm(instance=headline)
        headline.logger(str(request.user), " HEADLINE_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/headline/headlines_edit.html', {'form': form})