Exemple #1
0
def job_edit(request, ids):
    status = 0
    obj = get_object(PeriodicTask, id=ids)

    if request.method == 'POST':
        form = PeriodicTaskForm(request.POST, instance=obj)
        if form.is_valid():
            form.save()
            status = 1
        else:
            status = 2
    else:
        form = PeriodicTaskForm(instance=obj)

    return render(request, 'setup/job_edit.html', locals())
Exemple #2
0
def job_add(request):
    temp_name = "setup/setup-header.html"
    if request.method == "POST":
        a_form = PeriodicTaskForm(request.POST)
        if a_form.is_valid():
            a_form.save()
            tips = u"增加成功!"
            display_control = ""
            return redirect("/setup/job/list/")
        else:
            tips = u"增加失败!"
            display_control = ""
            return render(request, "setup/job_add.html", locals())
    else:
        display_control = "none"
        a_form = PeriodicTaskForm()
        return render(request, "setup/job_add.html", locals())