def update(plan_id, values): """ .. function:: RPC TestPlan.update(plan_id, values) Update the fields of the selected test plan. :param plan_id: PK of TestPlan to modify :type plan_id: int :param values: Field values for :class:`tcms.testplans.models.TestPlan` :type values: dict :return: Serialized :class:`tcms.testplans.models.TestPlan` object :rtype: dict :raises TestPlan.DoesNotExist: if object specified by PK doesn't exist :raises PermissionDenied: if missing *testplans.change_testplan* permission :raises ValueError: if validations fail """ test_plan = TestPlan.objects.get(pk=plan_id) form = EditPlanForm(values, instance=test_plan) if form.is_valid(): test_plan = form.save() result = model_to_dict(test_plan, exclude=["tag"]) # b/c value is set in the DB directly and if None # model_to_dict() will not return it result["create_date"] = test_plan.create_date return result raise ValueError(form_errors_to_list(form))
def update(plan_id, values): """ .. function:: RPC TestPlan.update(plan_id, values) Update the fields of the selected test plan. :param plan_id: PK of TestPlan to modify :type plan_id: int :param values: Field values for :class:`tcms.testplans.models.TestPlan` :type values: dict :return: Serialized :class:`tcms.testplans.models.TestPlan` object :rtype: dict :raises TestPlan.DoesNotExist: if object specified by PK doesn't exist :raises PermissionDenied: if missing *testplans.change_testplan* permission :raises ValueError: if validations fail """ test_plan = TestPlan.objects.get(pk=plan_id) form = EditPlanForm(values, instance=test_plan) if form.is_valid(): test_plan = form.save() else: raise ValueError(form_errors_to_list(form)) return test_plan.serialize()