Beispiel #1
0
def create(request):
    if request.method == 'POST':
        contacts = ContactList.post_dict(request.POST)
        form = CompanyForm(request.POST)
        if form.is_valid():
            company = form.save()
            msg = company.contact_list.update_contacts(contacts)
            if msg:
                messages.warning(request, msg)
            messages.success(request, 'Company created')
            return redirect('companies:update', company.pk)
    else:
        contacts = {}
        form = CompanyForm()

    data = {
        'contacts': contacts,
        'form': form,
    }

    return render_to_response(
        'companies/create.html',
        data,
        context_instance=RequestContext(request),
    )
Beispiel #2
0
def create(request, customer_id):
    customer = get_object_or_404(Customer, pk=customer_id)

    if request.method == 'POST':
        contacts = ContactList.post_dict(request.POST)
        form = QuotationForm(request.POST)
        if form.is_valid():
            quotation = form.save()
            msg = quotation.contact_list.update_contacts(contacts)
            if msg:
                messages.warning(request, msg)
            else:
                messages.success(request, 'Customer created')

            History.created_history(quotation, request.user)
            messages.success(request, 'Quotation created.')
            return redirect('quotations:update', quotation.pk)
    else:
        contacts = {}
        form = QuotationForm(initial={'customer': customer_id})

    data = {
        'contacts': contacts,
        'form': form,
    }

    return render_to_response(
        'quotations/create.html',
        data,
        context_instance=RequestContext(request),
    )
Beispiel #3
0
def create(request):
    if request.method == 'POST':
        contacts = ContactList.post_dict(request.POST)
        form = CustomerForm(request.POST)
        if form.is_valid():
            customer = form.save()
            msg = customer.contact_list.update_contacts(contacts)
            if msg:
                messages.warning(request, msg)
            History.created_history(customer, request.user)
            messages.success(request, 'Customer created.')
            return redirect('customers:update', customer.pk)
    else:
        contacts = {}
        form = CustomerForm()

    data = {
        'contacts': contacts,
        'form': form,
    }

    return render_to_response(
        'customers/create.html',
        data,
        context_instance=RequestContext(request),
    )
Beispiel #4
0
def create(request):
    if request.method == 'POST':
        contacts = ContactList.post_dict(request.POST)
        form = CompanyForm(request.POST)
        if form.is_valid():
            company = form.save()
            msg = company.contact_list.update_contacts(contacts)
            if msg:
                messages.warning(request, msg)
            messages.success(request, 'Company created')
            return redirect('companies:update', company.pk)
    else:
        contacts = {}
        form = CompanyForm()

    data = {
        'contacts': contacts,
        'form': form,
    }

    return render_to_response(
        'companies/create.html',
        data,
        context_instance=RequestContext(request),
    )
Beispiel #5
0
def create_foreign(request):
    if request.method == 'POST':
        contacts = ContactList.post_dict(request.POST)
        form = ForeignSupplierForm(request.POST)
        if form.is_valid():
            foreign_supplier = form.save()
            msg = foreign_supplier.contact_list.update_contacts(contacts)
            if msg:
                messages.warning(request, msg)
            History.created_history(foreign_supplier, request.user)
            messages.success(request, 'Foreign Supplier created.')
            if '_popup' in request.GET:
                popup_data = {
                    'obj': escape(foreign_supplier),
                    'pk_value': escape(foreign_supplier.id),
                }
                return render_to_response(
                    'home/close_popup.html',
                    popup_data,
                    context_instance=RequestContext(request),
                )

            return redirect('suppliers:update-foreign', foreign_supplier.pk)
    else:
        contacts = {}
        form = ForeignSupplierForm()

    data = {
        'contacts': contacts,
        'form': form,
    }

    return render_to_response(
        'suppliers/foreign/create.html',
        data,
        context_instance=RequestContext(request),
    )