示例#1
0
def add_tree_block(request):
    if request.method == 'POST':
        form = AddProblemForm(request.POST)
        if form.is_valid():
            path = norm(form.cleaned_data['path'])
            return {
                'form': form,
                'paths': import_tree(path),
            }
    else:
        form = AddProblemForm()
    return {'form': form}
示例#2
0
def add_problem_block(request):
    is_success, is_error = False, False
    if request.method == 'POST':
        form = AddProblemForm(request.POST)
        if form.is_valid():
            path = norm(form.cleaned_data['path'])
            if is_problem_path(path):
                problem = Problem(path=path)
                problem.save()
                import_to_database(problem)
                problem.save()
                is_success = True
            else:
                is_error = True
    else:
        form = AddProblemForm()
    return {
        'form': form,
        'is_success': is_success,
        'is_error': is_error,
    }