Exemplo n.º 1
0
def department_add(request, template_name='departments/department_add.html'):
    form = DepartmentForm(request.POST or None)
    username = request.session['username']
    print username
    if form.is_valid():
        print form
        form.save()
        return redirect('department_list')

    return render(request, template_name, {
        'form': form,
        'username': username,
        'var3': 'active',
    })
Exemplo n.º 2
0
def add_department_view(request):
	from forms import DepartmentForm
	form = None
	if request.method == 'POST':
		form = DepartmentForm(request.POST)
		if form.is_valid():
			form.save()
	else:
		form = DepartmentForm()
		
	deps = main_utils.get_all_departments()
	
	from django.template import RequestContext

	return render_to_response('maitenance/department.html', RequestContext(request, {'form': form, 'deps': deps}))
Exemplo n.º 3
0
def departments(request):

    if request.POST:
        form = DepartmentForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/departments/')
    else:
        form = DepartmentForm()

    title = "Departments"
    types = Department.objects.all()
    url = "departments"

    return render(request, 'add.html', locals())
Exemplo n.º 4
0
def department_edit(request,
                    pk,
                    template_name='departments/department_add.html'):
    username = request.session['username']
    deps = get_object_or_404(Department, pk=pk)
    form = DepartmentForm(request.POST or None, instance=deps)
    if form.is_valid():
        form.save()
        return redirect('department_list')

    return render(request, template_name, {
        'form': form,
        'username': username,
        'var3': 'active',
        'deps': deps,
    })
Exemplo n.º 5
0
def editdepartments(request, type_id):
    types = get_object_or_404(Department, pk=type_id)
    t = "Edit"

    if request.POST:
        form = DepartmentForm(request.POST, instance=types)
        if form.is_valid():
            form.save()

            return HttpResponseRedirect('/departments/')

    else:
        form = DepartmentForm(instance=types)

    types = Department.objects.all()
    title = "Edit Departments"
    url = "departments"

    return render_to_response("edit.html", {
            'form': form,
            't': t,
    }, context_instance=RequestContext(request, locals()))