Пример #1
0
def createTitleClient(request, client_id):  # from client ID
    client = get_object_or_404(Client, pk=client_id)
    if request.method == 'POST':
        form = CreateClientTitleForm(request.POST)
        if form.is_valid():
            # create a new item
            title = Title.objects.create(
                client=client,
                name=form.cleaned_data['name'],
            )
            # Always redirect after a POST
            return HttpResponseRedirect('/management/title/%s/' % title.id)
    else:
        form = CreateClientTitleForm()
    context = {'page_title': 'Add Title', 'client': client, 'form': form}
    return render(request, 'management/title_form.html', context)
Пример #2
0
def createTitleClient(request, client_id):  # from client ID
	client = get_object_or_404(Client, pk=client_id)
	if request.method == 'POST':
		form = CreateClientTitleForm(request.POST)
		if form.is_valid():
			# create a new item
			title = Title.objects.create(
				client=client,
				name=form.cleaned_data['name'],
			)
			# Always redirect after a POST
			return HttpResponseRedirect('/management/title/%s/' % title.id)
	else:        
		form = CreateClientTitleForm()
	context = {'page_title': 'Add Title', 'client': client, 'form': form}
	return render(request, 'management/title_form.html', context)
Пример #3
0
def editTitle(request, pk):
	title = Title.objects.get(pk=pk)

	if request.method == 'POST':
		form = CreateClientTitleForm(request.POST, instance=title)
		if form.is_valid():
			# create a new item
			title = form.save(commit=False)
			client = title.client
			title.save()
			# Always redirect after a POST
			return HttpResponseRedirect('/management/title/%s/' % title.id)
	else:        
		form = CreateClientTitleForm(instance=title)
	
	context = {'page_title': 'Edit Title', 'instance': title, 'form': form}
	return render(request, 'management/title_form.html', context)
Пример #4
0
def editTitle(request, pk):
    title = Title.objects.get(pk=pk)

    if request.method == 'POST':
        form = CreateClientTitleForm(request.POST, instance=title)
        if form.is_valid():
            # create a new item
            title = form.save(commit=False)
            client = title.client
            title.save()
            # Always redirect after a POST
            return HttpResponseRedirect('/management/title/%s/' % title.id)
    else:
        form = CreateClientTitleForm(instance=title)

    context = {'page_title': 'Edit Title', 'instance': title, 'form': form}
    return render(request, 'management/title_form.html', context)