Beispiel #1
0
def process_add_client_form(request):
    form = AddClientForm(request.POST or None)
    if form.is_valid():
        client = form.create_client(request.user)
        return {'success': True, 'client_id': client.id}
    form_html = render_crispy_form(form, helper=add_client_form_modal_helper)
    return {'success': False, 'form_html': form_html}
Beispiel #2
0
def process_edit_client_form(request, pk):
    client = get_object_or_404(Client, pk=pk)
    form = AddClientForm(request.POST or None, instance=client)
    if form.is_valid(
    ) and request.user.userprofile.customer == client.customer:
        form.save()
        return {'success': True, 'client_id': client.id}
    form_html = render_crispy_form(form, helper=edit_client_form_modal_helper)
    return {'success': False, 'form_html': form_html}
Beispiel #3
0
def process_add_client_form(request):
    form = AddClientForm(request.POST or None)
    if form.is_valid():
        client = form.create_client(request.user)
        return {
            'success': True,
            'client_id': client.id
        }
    form_html = render_crispy_form(form, helper=add_client_form_modal_helper)
    return {'success': False, 'form_html': form_html}
Beispiel #4
0
def process_edit_client_form(request, pk):
    client = get_object_or_404(Client, pk=pk)
    form = AddClientForm(request.POST or None, instance=client)
    if form.is_valid() and request.user.userprofile.customer == client.customer:
        form.save()
        return {
            'success': True,
            'client_id': client.id
        }
    form_html = render_crispy_form(form, helper=edit_client_form_modal_helper)
    return {'success': False, 'form_html': form_html}