emile 1 year ago
parent 2ab9337c0c
commit bdbb378ccc

@ -173,7 +173,7 @@ def add_invoice_pdf(request, order_id):
response['Content-Disposition'] = 'attachment; filename="my_pdf.pdf"'
return response

Binary file not shown.

@ -39,18 +39,12 @@ def add_status_modal(request, *args, **kwargs):
@staff_login_required
def add_customer(request):
businesses = Business.objects.all().order_by('-id')
references = Reference.objects.all().order_by('-id')
business_types = BusinessType.objects.all().order_by('-id')
if request.method == 'POST':
email = request.POST.get('email').lower()
first_name = request.POST.get('first_name')
last_name = request.POST.get('last_name')
business_id = request.POST.get('business')
business = get_object_or_404(Business, id=business_id)
username = f"{first_name.lower()}{last_name.lower()}"
user = User.objects.create_user(
username=email,
@ -61,9 +55,11 @@ def add_customer(request):
user.last_name = last_name.lower().capitalize()
user.save()
referenceid = request.POST.get('referenceid')
reference = get_object_or_404(Reference, id=referenceid)
if request.POST.get('referenceid'):
reference_id = request.POST.get('referenceid')
reference = get_object_or_404(Reference, id=reference_id)
else:
reference = None
CustomerProfile.objects.create(
user=user,
@ -71,14 +67,11 @@ def add_customer(request):
personal_website = request.POST.get('personal_website'),
status = request.POST.get('status'),
reference = reference,
business = business,
)
return redirect('customers')
context = {
'businesses' : businesses,
'references' :references,
'business_types' : business_types
}
return render(request, 'add_templates/add-customer.html', context)
@ -87,14 +80,19 @@ def add_customer(request):
@staff_login_required
def add_business(request):
customers = CustomerProfile.objects.all().order_by('-id')
business_types = BusinessType.objects.all().order_by('-id')
if request.method == 'POST':
customer_id = request.POST.get('type')
customer = get_object_or_404(CustomerProfile, id=customer_id)
name = request.POST.get('name')
email= request.POST.get('email')
financial_number = request.POST.get('financial_number')
phone_number = request.POST.get('phone_number')
vat = request.POST.get('vat')
if vat == 'true':
if vat:
vat = True
else:
vat = False
@ -103,10 +101,10 @@ def add_business(request):
logo = request.FILES.get('logo')
business_type_id = request.POST.get('type')
business_type = get_object_or_404(BusinessType, id=business_type_id)
business = Business(
customer = customer,
name = name,
email = email,
financial_number = financial_number,
@ -122,6 +120,7 @@ def add_business(request):
return redirect('businesses')
context = {
'customers': customers,
'business_types': business_types,
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save