Ejemplo n.º 1
0
def newdepartment(request):
    if request.method == 'POST':
        form = DepartmentForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/admin/department', {'success': 'Department Added'})
        else:
            return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})
    else:
        form = DepartmentForm()
        return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})
Ejemplo n.º 2
0
def editdepartment(request, id=None):
    department = Department.objects.get(id=id)
    if request.method == 'POST':
        form = DepartmentForm(request.POST, instance=department)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/admin/department', {'success': 'Department edited'})
        else:
            return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})
    else:
        form = DepartmentForm(instance=department)
        return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})
Ejemplo n.º 3
0
def newdepartment(request):
    if not request.user.is_superuser:
        return HttpResponseRedirect('/department')

    if request.method == 'POST':
        form = DepartmentForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/admin/department', {'success': 'Department Added'})
        else:
            return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})
    else:
        form = DepartmentForm()
        return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})
Ejemplo n.º 4
0
def editdepartment(request, id=None):
    if not request.user.is_superuser:
        return HttpResponseRedirect('/department')

    department = Department.objects.get(id=id)
    if request.method == 'POST':
        form = DepartmentForm(request.POST, instance=department)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/admin/department', {'success': 'Department edited'})
        else:
            return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})
    else:
        form = DepartmentForm(instance=department)
        return render(request,'mapping/newdepartment.html', {'title': 'Department', 'form': form})