예제 #1
0
def tag_add(request):
    """Add a tag."""
    if request.method == "POST":
        form = forms.AddTagForm(request.POST, user=request.user)
        tag = form.save_if_valid()
        if tag is not None:
            messages.success(
                request, u"Tag '{0}' added.".format(
                    tag.name)
                )
            return redirect("manage_tags")
    else:
        pf = PinnedFilters(request.COOKIES)
        form = forms.AddTagForm(
            user=request.user,
            initial=pf.fill_form_querystring(request.GET).dict(),
            )
    return TemplateResponse(
        request,
        "manage/tag/add_tag.html",
        {
            "form": form,
            "hide_multiselect": 1,
            }
        )
예제 #2
0
파일: views.py 프로젝트: Dannyzen/moztrap
def suite_add(request):
    """Add a suite."""
    if request.method == "POST":
        form = forms.AddSuiteForm(request.POST, user=request.user)
        suite = form.save_if_valid()
        if suite is not None:
            messages.success(
                request, u"Suite '{0}' added.".format(
                    suite.name)
                )
            return redirect("manage_suites")
    else:
        pf = PinnedFilters(request.COOKIES)
        # Note: inital takes a dict, NOT a QueryDict.  It won't work correctly
        # with a QueryDict.
        form = forms.AddSuiteForm(
            user=request.user,
            initial=pf.fill_form_querystring(request.GET).dict(),
            )
    return TemplateResponse(
        request,
        "manage/suite/add_suite.html",
        {
            "form": form
            }
        )
예제 #3
0
파일: views.py 프로젝트: ballacky13/moztrap
def suite_add(request):
    """Add a suite."""
    if request.method == "POST":
        form = forms.AddSuiteForm(request.POST, user=request.user)
        suite = form.save_if_valid()
        if suite is not None:
            messages.success(
                request, u"Suite '{0}' added.".format(
                    suite.name)
                )
            return redirect("manage_suites")
    else:
        pf = PinnedFilters(request.COOKIES)
        # @@@ I wonder if there's a bug here.  Passing in a QueryDict to
        # a BaseModelForm doesn't work.  It only works for BaseForm.  For
        # BaseModelForm, you must pass in a dict so that the values are
        # not lists.  BaseModelForm doesn't convert them from lists to single
        # values properly.
        form = forms.AddSuiteForm(
            user=request.user,
            initial=pf.fill_form_querystring(request.GET).dict(),
            )
    return TemplateResponse(
        request,
        "manage/suite/add_suite.html",
        {
            "form": form
            }
        )
예제 #4
0
파일: views.py 프로젝트: vaidik/moztrap
def run_add(request):
    """Add a run."""
    if request.method == "POST":
        form = forms.AddRunForm(request.POST, user=request.user)
        run = form.save_if_valid()
        if run is not None:
            messages.success(request, u"Run '{0}' added.".format(run.name))
            return redirect("manage_runs")
    else:
        pf = PinnedFilters(request.COOKIES)
        form = forms.AddRunForm(
            user=request.user,
            initial=pf.fill_form_querystring(request.GET).dict(),
        )
    return TemplateResponse(request, "manage/run/add_run.html", {"form": form})
예제 #5
0
def suite_add(request):
    """Add a suite."""
    if request.method == "POST":
        form = forms.AddSuiteForm(request.POST, user=request.user)
        suite = form.save_if_valid()
        if suite is not None:
            messages.success(request, u"Suite '{0}' added.".format(suite.name))
            return redirect("manage_suites")
    else:
        pf = PinnedFilters(request.COOKIES)
        # Note: inital takes a dict, NOT a QueryDict.  It won't work correctly
        # with a QueryDict.
        form = forms.AddSuiteForm(
            user=request.user,
            initial=pf.fill_form_querystring(request.GET).dict(),
        )
    return TemplateResponse(request, "manage/suite/add_suite.html",
                            {"form": form})
예제 #6
0
def case_add_bulk(request):
    """Add cases in bulk."""
    if request.method == "POST":
        form = forms.AddBulkCaseForm(request.POST,
                                     request.FILES,
                                     user=request.user)
        if form.is_valid():
            cases = form.save()
            messages.success(
                request, u"Added {0} test case{1}.".format(
                    len(cases), "" if len(cases) == 1 else "s"))
            return redirect("manage_cases")
    else:
        pf = PinnedFilters(request.COOKIES)
        form = forms.AddBulkCaseForm(user=request.user,
                                     initial=pf.fill_form_querystring(
                                         request.GET))
    return TemplateResponse(request, "manage/case/add_case_bulk.html",
                            {"form": form})
예제 #7
0
파일: views.py 프로젝트: ballacky13/moztrap
def case_add(request):
    """Add a single case."""
    if request.method == "POST":
        form = forms.AddCaseForm(request.POST, request.FILES, user=request.user)
        if form.is_valid():
            case = form.save()
            messages.success(
                request, u"Test case '{0}' added.".format(
                    case.versions.all()[0].name)
                )
            return redirect("manage_cases")
    else:
        pf = PinnedFilters(request.COOKIES)
        form = forms.AddCaseForm(user=request.user, initial=pf.fill_form_querystring(request.GET))
    return TemplateResponse(
        request,
        "manage/case/add_case.html",
        {
            "form": form
            }
        )
예제 #8
0
def case_add_bulk(request):
    """Add cases in bulk."""
    if request.method == "POST":
        form = forms.AddBulkCaseForm(
            request.POST, request.FILES, user=request.user)
        if form.is_valid():
            cases = form.save()
            messages.success(
                request, u"Added {0} test case{1}.".format(
                    len(cases), "" if len(cases) == 1 else "s")
                )
            return redirect("manage_cases")
    else:
        pf = PinnedFilters(request.COOKIES)
        form = forms.AddBulkCaseForm(user=request.user, initial=pf.fill_form_querystring(request.GET))
    return TemplateResponse(
        request,
        "manage/case/add_case_bulk.html",
        {
            "form": form
            }
        )
예제 #9
0
파일: views.py 프로젝트: Dannyzen/moztrap
def run_add(request):
    """Add a run."""
    if request.method == "POST":
        form = forms.AddRunForm(request.POST, user=request.user)
        run = form.save_if_valid()
        if run is not None:
            messages.success(
                request, u"Run '{0}' added.".format(
                    run.name)
                )
            return redirect("manage_runs")
    else:
        pf = PinnedFilters(request.COOKIES)
        form = forms.AddRunForm(
            user=request.user,
            initial=pf.fill_form_querystring(request.GET).dict(),
            )
    return TemplateResponse(
        request,
        "manage/run/add_run.html",
        {
            "form": form
            }
        )
예제 #10
0
@never_cache
@permission_required("library.create_cases")
def case_add(request):
    """Add a single case."""
    if request.method == "POST":
        form = forms.AddCaseForm(request.POST,
                                 request.FILES,
                                 user=request.user)
        if form.is_valid():
            case = form.save()
            messages.success(
                request,
                u"Test case '{0}' added.".format(case.versions.all()[0].name))
            return redirect("manage_cases")
    else:
        pf = PinnedFilters(request.COOKIES)
        form = forms.AddCaseForm(
            user=request.user,
            initial=pf.fill_form_querystring(request.GET).dict(),
        )
    return TemplateResponse(request, "manage/case/add_case.html",
                            {"form": form})


@never_cache
@permission_required("library.create_cases")
def case_add_bulk(request):
    """Add cases in bulk."""
    if request.method == "POST":
        form = forms.AddBulkCaseForm(request.POST,
                                     request.FILES,