Exemple #1
0
def create_node_value(attributes):
    try:
        exam_node_value_form = ExamNodeForm(attributes)
        if exam_node_value_form.is_valid():
            exam_node_value = exam_node_value_form.save(commit=False)
            return True, exam_node_value
        else:
            errors = ""
            for field, error in exam_node_value_form.errors.items():
                errors += "\n%s\n" % error
            return False, errors
    except Exception, e:
        return False, e
Exemple #2
0
def edit_node_value(node_id, attributes):
    try:
        exam_node_value = NodeValue.objects.get(pk=node_id)
        exam_node_value_form = ExamNodeForm(attributes, instance=exam_node_value)
        if exam_node_value_form.is_valid():
            exam_node_value = exam_node_value_form.save(commit=False)
            return True, exam_node_value
        else:
            errors = ""
            for field, error in exam_node_value_form.errors.items():
                errors += "\n%s\n" % error
            return False, errors
    except Exception, e:
        return False, e