|
|
|
@ -673,20 +673,20 @@ def add_ticket(request, customer_id):
|
|
|
|
|
ticket.save()
|
|
|
|
|
|
|
|
|
|
ticket.departments.set(departments)
|
|
|
|
|
if request.POST.get('filePath'):
|
|
|
|
|
file_path = request.POST.get('filePath')
|
|
|
|
|
|
|
|
|
|
# Check if the file exists
|
|
|
|
|
if os.path.exists(file_path):
|
|
|
|
|
with open(file_path, 'rb') as f:
|
|
|
|
|
ticket_attachment = TicketAttachment(
|
|
|
|
|
ticket=ticket,
|
|
|
|
|
file_path=file_path
|
|
|
|
|
)
|
|
|
|
|
ticket_attachment.save()
|
|
|
|
|
else:
|
|
|
|
|
# Handle the case where the file does not exist
|
|
|
|
|
print("Error: File does not exist at the provided path:", file_path)
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
file_paths = request.POST.getlist('filePath')
|
|
|
|
|
|
|
|
|
|
for file_path in file_paths:
|
|
|
|
|
if os.path.exists(file_path):
|
|
|
|
|
with open(file_path, 'rb') as f:
|
|
|
|
|
ticket_attachment = TicketAttachment(
|
|
|
|
|
ticket=ticket,
|
|
|
|
|
file_path=file_path
|
|
|
|
|
)
|
|
|
|
|
ticket_attachment.save()
|
|
|
|
|
else:
|
|
|
|
|
print("Error: File does not exist at the provided path:", file_path)
|
|
|
|
|
|
|
|
|
|
return redirect('ticketdetails', ticket_number=ticket.ticket_number)
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
|