예제 #1
0
파일: views.py 프로젝트: od-5/crm
def client_maket_update(request, pk):
    context = {}
    maket = ClientMaket.objects.get(pk=int(pk))
    success_msg = u''
    error_msg = u''
    if request.method == 'POST':
        form = ClientMaketForm(request.POST, request.FILES, instance=maket)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('client:maket', args=(maket.client.id,)))
    else:
        form = ClientMaketForm(instance=maket, initial={
            'file': maket.file
        })
    try:
        request.session['client_filtered_list']
    except:
        request.session['client_filtered_list'] = reverse('client:list')
    context.update({
        'success': success_msg,
        'error': error_msg,
        'client_maket_form': form,
        'object': maket,
        'client': maket.client,
        'back_to_list': request.session['client_filtered_list']
    })
    return render(request, 'client/client_maket_update.html', context)
예제 #2
0
파일: views.py 프로젝트: od-5/crm
def client_maket_add(request):
    if request.method == 'POST':
        form = ClientMaketForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
    return HttpResponseRedirect(request.META.get('HTTP_REFERER'))