コード例 #1
0
def recommendations_add(request):
    if request.method == 'POST':
        form = RecommendationForm(request.POST)
        if form.is_valid():
            recommendation = form.save(commit=False)
            recommendation.save()
            recommendation.logger(str(request.user),
                                  " RECOMMENDATION_ADD_EXECUTED")
            messages.success(request, 'Recommendation added')
            return redirect('/recommendations')
    else:
        form = RecommendationForm()
        debug_logger(str(request.user), " RECOMMENDATION_ADD_ENTERED")
    return render(request,
                  'dfirtrack_main/recommendation/recommendations_add.html',
                  {'form': form})
コード例 #2
0
def recommendations_edit(request, pk):
    recommendation = get_object_or_404(Recommendation, pk=pk)
    if request.method == 'POST':
        form = RecommendationForm(request.POST, instance=recommendation)
        if form.is_valid():
            recommendation = form.save(commit=False)
            recommendation.save()
            recommendation.logger(str(request.user),
                                  " RECOMMENDATION_EDIT_EXECUTED")
            messages.success(request, 'Recommendation edited')
            return redirect('/recommendations')
    else:
        form = RecommendationForm(instance=recommendation)
        recommendation.logger(str(request.user),
                              " RECOMMENDATION_EDIT_ENTERED")
    return render(request,
                  'dfirtrack_main/recommendation/recommendations_edit.html',
                  {'form': form})
コード例 #3
0
def recommendations_add_popup(request):
    if request.method == 'POST':
        form = RecommendationForm(request.POST)
        if form.is_valid():
            recommendation = form.save(commit=False)
            recommendation.save()
            recommendation.logger(str(request.user),
                                  " RECOMMENDATION_ADD_POPUP_EXECUTED")
            messages.success(request, 'Recommendation added')
            return HttpResponse(
                '<script type="text/javascript">window.close();</script>')
    else:
        form = RecommendationForm()
        debug_logger(str(request.user), " RECOMMENDATION_ADD_POPUP_ENTERED")
    return render(
        request,
        'dfirtrack_main/recommendation/recommendations_add_popup.html',
        {'form': form})