コード例 #1
0
ファイル: views.py プロジェクト: YSaxon/django-DefectDojo
def new_product(request):
    if request.method == 'POST':
        form = ProductForm(request.POST)
        if form.is_valid():
            product = form.save()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product added successfully.',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_product', args=(product.id,)))
    else:
        form = ProductForm()
    add_breadcrumb(title="New Product", top_level=False, request=request)
    return render(request, 'dojo/new_product.html',
                  {'form': form})
コード例 #2
0
def edit_product(request, pid):
    prod = Product.objects.get(pk=pid)
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=prod)
        if form.is_valid():
            form.save()
            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            prod.tags = t
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product updated successfully.',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_product', args=(pid, )))
    else:
        form = ProductForm(instance=prod,
                           initial={
                               'auth_users':
                               prod.authorized_users.all(),
                               'tags':
                               get_tag_list(Tag.objects.get_for_object(prod))
                           })
    add_breadcrumb(parent=prod, title="Edit", top_level=False, request=request)

    return render(request, 'dojo/edit_product.html', {
        'form': form,
        'product': prod,
    })
コード例 #3
0
def edit_product(request, pid):
    prod = Product.objects.get(pk=pid)
    jira_enabled = True
    jira_inst = None
    try:
        jira_inst = JIRA_PKey.objects.get(product=prod)
    except:
        jira_enabled = False
        pass
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=prod)
        if form.is_valid():
            form.save()
            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            prod.tags = t
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product updated successfully.',
                                 extra_tags='alert-success')
            if hasattr(settings, 'ENABLE_JIRA'):
                if settings.ENABLE_JIRA:
                    if jira_enabled:
                        jform = JIRAPKeyForm(request.POST, instance=jira_inst)
                    else:
                        jform = JIRAPKeyForm(request.POST)
                        new_conf = jform.save(commit=False)
                        new_conf.product_id = pid
                        new_conf.save()
                        messages.add_message(
                            request,
                            messages.SUCCESS,
                            'JIRA information updated successfully.',
                            extra_tags='alert-success')

            return HttpResponseRedirect(reverse('view_product', args=(pid, )))
    else:
        form = ProductForm(instance=prod,
                           initial={
                               'auth_users':
                               prod.authorized_users.all(),
                               'tags':
                               get_tag_list(Tag.objects.get_for_object(prod))
                           })
        if hasattr(settings, 'ENABLE_JIRA'):
            if settings.ENABLE_JIRA:
                if jira_enabled:
                    jform = JIRAPKeyForm(instance=jira_inst)
                else:
                    jform = JIRAPKeyForm()
        else:
            jform = None
    add_breadcrumb(parent=prod, title="Edit", top_level=False, request=request)

    return render(request, 'dojo/edit_product.html', {
        'form': form,
        'jform': jform,
        'product': prod,
    })
コード例 #4
0
ファイル: views.py プロジェクト: devGregA/django-DefectDojo
def new_product(request):
    jform = None
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=Product())
        if get_system_setting('enable_jira'):
                jform = JIRAPKeyForm(request.POST, instance=JIRA_PKey())
        else:
            jform = None

        if form.is_valid():
            product = form.save()
            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            product.tags = t
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product added successfully.',
                                 extra_tags='alert-success')
            if get_system_setting('enable_jira'):
                    if jform.is_valid():
                        jira_pkey = jform.save(commit=False)
                        if jira_pkey.conf is not None:
                            jira_pkey.product = product
                            jira_pkey.save()
                            messages.add_message(request,
                                                 messages.SUCCESS,
                                                 'JIRA information added successfully.',
                                                 extra_tags='alert-success')
            create_notification(event='product_added', title=product.name, url=request.build_absolute_uri(reverse('view_product', args=(product.id,))))
            return HttpResponseRedirect(reverse('view_product', args=(product.id,)))
    else:
        form = ProductForm()
        if get_system_setting('enable_jira'):
                jform = JIRAPKeyForm()
        else:
            jform = None
    add_breadcrumb(title="New Product", top_level=False, request=request)
    return render(request, 'dojo/new_product.html',
                  {'form': form,
                   'jform': jform})
コード例 #5
0
ファイル: views.py プロジェクト: YSaxon/django-DefectDojo
def edit_product(request, pid):
    prod = Product.objects.get(pk=pid)
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=prod)
        if form.is_valid():
            form.save()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product updated successfully.',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_product', args=(pid,)))
    else:
        form = ProductForm(instance=prod,
                           initial={'auth_users': prod.authorized_users.all()})

    add_breadcrumb(parent=prod, title="Edit", top_level=False, request=request)

    return render(request,
                  'dojo/edit_product.html',
                  {'form': form,
                   'product': prod,
                   })
コード例 #6
0
def new_product(request):
    jform = None
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=Product())
        if get_system_setting('enable_jira'):
            jform = JIRAPKeyForm(request.POST, instance=JIRA_PKey())
        else:
            jform = None

        if form.is_valid():
            product = form.save()
            tags = request.POST.getlist('tags')
            t = ", ".join('"{0}"'.format(w) for w in tags)
            product.tags = t
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product added successfully.',
                                 extra_tags='alert-success')
            if get_system_setting('enable_jira'):
                if jform.is_valid():
                    jira_pkey = jform.save(commit=False)
                    if jira_pkey.conf is not None:
                        jira_pkey.product = product
                        jira_pkey.save()
                        messages.add_message(
                            request,
                            messages.SUCCESS,
                            'JIRA information added successfully.',
                            extra_tags='alert-success')

            # SonarQube API Configuration
            sonarqube_form = Sonarqube_ProductForm(request.POST)
            if sonarqube_form.is_valid():
                sonarqube_product = sonarqube_form.save(commit=False)
                sonarqube_product.product = product
                sonarqube_product.save()

            create_notification(event='product_added',
                                title=product.name,
                                url=reverse('view_product',
                                            args=(product.id, )))
            return HttpResponseRedirect(
                reverse('view_product', args=(product.id, )))
    else:
        form = ProductForm()
        if get_system_setting('enable_jira'):
            jform = JIRAPKeyForm()
        else:
            jform = None

    add_breadcrumb(title="New Product", top_level=False, request=request)
    return render(request, 'dojo/new_product.html', {
        'form': form,
        'jform': jform,
        'sonarqube_form': Sonarqube_ProductForm()
    })
コード例 #7
0
ファイル: views.py プロジェクト: mattvaldes/django-DefectDojo
def new_product(request):
    if request.method == 'POST':
        form = ProductForm(request.POST)
        if form.is_valid():
            product = form.save()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product added successfully.',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(
                reverse('view_product', args=(product.id, )))
    else:
        form = ProductForm()
    add_breadcrumb(title="New Product", top_level=False, request=request)
    return render(request, 'dojo/new_product.html', {'form': form})
コード例 #8
0
def new_product(request):
    jform = None
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=Product())
        if hasattr(settings, 'ENABLE_JIRA'):
            if settings.ENABLE_JIRA:
                jform = JIRAPKeyForm(request.POST, instance=JIRA_PKey())
            else:
                jform = None
        else:
            jform = None

        if form.is_valid():
            product = form.save()
            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            product.tags = t
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product added successfully.',
                                 extra_tags='alert-success')
            if hasattr(settings, 'ENABLE_JIRA'):
                if settings.ENABLE_JIRA:
                    if jform.is_valid():
                        jira_pkey = jform.save(commit=False)
                        if jira_pkey.conf is not None:
                            jira_pkey.product = product
                            jira_pkey.save()
                            messages.add_message(
                                request,
                                messages.SUCCESS,
                                'JIRA information added successfully.',
                                extra_tags='alert-success')

            return HttpResponseRedirect(
                reverse('view_product', args=(product.id, )))
    else:
        form = ProductForm()
        if hasattr(settings, 'ENABLE_JIRA'):
            if settings.ENABLE_JIRA:
                jform = JIRAPKeyForm()
        else:
            jform = None
    add_breadcrumb(title="New Product", top_level=False, request=request)
    return render(request, 'dojo/new_product.html', {
        'form': form,
        'jform': jform
    })
コード例 #9
0
def edit_product(request, pid):
    prod = Product.objects.get(pk=pid)
    system_settings = System_Settings.objects.get()
    jira_enabled = system_settings.enable_jira
    jira_inst = None
    jform = None
    try:
        jira_inst = JIRA_PKey.objects.get(product=prod)
    except:
        jira_inst = None
        pass
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=prod)
        if form.is_valid():
            form.save()
            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            prod.tags = t
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product updated successfully.',
                                 extra_tags='alert-success')

            if get_system_setting('enable_jira') and jira_inst:
                jform = JIRAPKeyForm(request.POST, instance=jira_inst)
                # need to handle delete
                try:
                    jform.save()
                except:
                    pass
            elif get_system_setting('enable_jira'):
                jform = JIRAPKeyForm(request.POST)
                if jform.is_valid():
                    new_conf = jform.save(commit=False)
                    new_conf.product_id = pid
                    new_conf.save()
                    messages.add_message(
                        request,
                        messages.SUCCESS,
                        'JIRA information updated successfully.',
                        extra_tags='alert-success')

            return HttpResponseRedirect(reverse('view_product', args=(pid, )))
    else:
        form = ProductForm(instance=prod,
                           initial={
                               'auth_users':
                               prod.authorized_users.all(),
                               'tags':
                               get_tag_list(Tag.objects.get_for_object(prod))
                           })

        if jira_enabled and (jira_inst is not None):
            if jira_inst is not None:
                jform = JIRAPKeyForm(instance=jira_inst)
            else:
                jform = JIRAPKeyForm()
        elif jira_enabled:
            jform = JIRAPKeyForm()
        else:
            jform = None
    form.initial['tags'] = [tag.name for tag in prod.tags]
    product_tab = Product_Tab(pid, title="Edit Product", tab="settings")
    return render(request, 'dojo/edit_product.html', {
        'form': form,
        'product_tab': product_tab,
        'jform': jform,
        'product': prod
    })
コード例 #10
0
ファイル: views.py プロジェクト: devGregA/django-DefectDojo
def edit_product(request, pid):
    prod = Product.objects.get(pk=pid)
    system_settings = System_Settings.objects.get()
    jira_enabled = system_settings.enable_jira
    jira_inst = None
    jform = None
    try:
        jira_inst = JIRA_PKey.objects.get(product=prod)
    except:
        jira_inst = None
        pass
    if request.method == 'POST':
        form = ProductForm(request.POST, instance=prod)
        if form.is_valid():
            form.save()
            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            prod.tags = t
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Product updated successfully.',
                                 extra_tags='alert-success')

            if get_system_setting('enable_jira') and jira_inst:
                jform = JIRAPKeyForm(request.POST, instance=jira_inst)
                # need to handle delete
                try:
                    jform.save()
                except:
                    pass
            elif get_system_setting('enable_jira'):
                jform = JIRAPKeyForm(request.POST)
                if jform.is_valid():
                    new_conf = jform.save(commit=False)
                    new_conf.product_id = pid
                    new_conf.save()
                    messages.add_message(request,
                                            messages.SUCCESS,
                                            'JIRA information updated successfully.',
                                            extra_tags='alert-success')

            return HttpResponseRedirect(reverse('view_product', args=(pid,)))
    else:
        form = ProductForm(instance=prod,
                           initial={'auth_users': prod.authorized_users.all(),
                                    'tags': get_tag_list(Tag.objects.get_for_object(prod))})

        if jira_enabled and (jira_inst is not None):
            if jira_inst is not None:
                jform = JIRAPKeyForm(instance=jira_inst)
            else:
                jform = JIRAPKeyForm()
        elif jira_enabled:
            jform = JIRAPKeyForm()
        else:
            jform = None
    form.initial['tags'] = [tag.name for tag in prod.tags]
    product_tab = Product_Tab(pid, title="Edit Product", tab="settings")
    return render(request,
                  'dojo/edit_product.html',
                  {'form': form,
                   'product_tab': product_tab,
                   'jform': jform,
                   'product': prod
                   })