Exemplo n.º 1
0
def analystmemos_edit(request, pk):
    analystmemo = get_object_or_404(Analystmemo, pk=pk)
    if request.method == 'POST':
        form = AnalystmemoForm(request.POST, instance=analystmemo)
        if form.is_valid():
            analystmemo = form.save(commit=False)
            analystmemo.analystmemo_modified_by_user_id = request.user
            analystmemo.save()
            analystmemo.logger(str(request.user), " ANALYSTMEMO_EDIT_EXECUTED")
            messages.success(request, 'Analystmemo edited')
            return redirect('/systems/' + str(analystmemo.system.system_id))
    else:
        form = AnalystmemoForm(instance=analystmemo)
        analystmemo.logger(str(request.user), " ANALYSTMEMO_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/analystmemo/analystmemos_edit.html',
                  {'form': form})
Exemplo n.º 2
0
def analystmemos_add(request):
    if request.method == 'POST':
        form = AnalystmemoForm(request.POST)
        if form.is_valid():
            analystmemo = form.save(commit=False)
            analystmemo.analystmemo_created_by_user_id = request.user
            analystmemo.analystmemo_modified_by_user_id = request.user
            analystmemo.save()
            analystmemo.logger(str(request.user), " ANALYSTMEMO_ADD_EXECUTED")
            messages.success(request, 'Analystmemo added')
            return redirect('/systems/' + str(analystmemo.system.system_id))
    else:
        if request.method == 'GET' and 'system' in request.GET:
            system = request.GET['system']
            form = AnalystmemoForm(initial={
                'system': system,
            })
        else:
            form = AnalystmemoForm()
        debug_logger(str(request.user), " ANALYSTMEMO_ADD_ENTERED")
    return render(request, 'dfirtrack_main/analystmemo/analystmemos_add.html',
                  {'form': form})