Beispiel #1
0
def companys_add(request):
    if request.method == 'POST':
        form = CompanyForm(request.POST)
        if form.is_valid():
            company = form.save(commit=False)
            company.save()
            company.logger(str(request.user), " COMPANY_ADD_EXECUTED")
            messages.success(request, 'Company added')
            return redirect('/companys')
    else:
        form = CompanyForm()
        debug_logger(str(request.user), " COMPANY_ADD_ENTERED")
    return render(request, 'dfirtrack_main/company/companys_add.html',
                  {'form': form})
Beispiel #2
0
def companys_edit(request, pk):
    company = get_object_or_404(Company, pk=pk)
    if request.method == 'POST':
        form = CompanyForm(request.POST, instance=company)
        if form.is_valid():
            company = form.save(commit=False)
            company.save()
            company.logger(str(request.user), " COMPANY_EDIT_EXECUTED")
            messages.success(request, 'Company edited')
            return redirect('/companys')
    else:
        form = CompanyForm(instance=company)
        company.logger(str(request.user), " COMPANY_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/company/companys_edit.html',
                  {'form': form})
Beispiel #3
0
def companys_add_popup(request):
    if request.method == 'POST':
        form = CompanyForm(request.POST)
        if form.is_valid():
            company = form.save(commit=False)
            company.save()
            company.logger(str(request.user), " COMPANY_ADD_POPUP_EXECUTED")
            messages.success(request, 'Company added')
            return HttpResponse(
                '<script type="text/javascript">window.close();</script>')
    else:
        form = CompanyForm()
        debug_logger(str(request.user), " COMPANY_ADD_POPUP_ENTERED")
    return render(request, 'dfirtrack_main/company/companys_add_popup.html',
                  {'form': form})