You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
4.3 KiB
Python

from django.shortcuts import render, redirect, get_object_or_404
from osinacore.models import *
from django.contrib.auth.decorators import login_required
from django.urls import reverse
from django.http import HttpResponseRedirect
from osinacore.decorators import *
from customercore.models import *
@staff_login_required
def delete_customer_modal(request, customer_id):
customer = get_object_or_404(CustomerProfile, id=customer_id)
if request.method == 'POST':
customer.delete()
return redirect('customers')
context = {
'customer': customer,
}
return render(request, "delete_templates/delete-customer-modal.html", context)
@staff_login_required
def delete_business_modal(request, business_id):
business = get_object_or_404(Business, id=business_id)
if request.method == 'POST':
business.delete()
return redirect('businesses')
context = {
'business': business,
}
return render(request, "delete_templates/delete-business-modal.html", context)
@staff_login_required
def delete_staff_modal(request, staff_id):
staff = get_object_or_404(StaffProfile, id=staff_id)
if request.method == 'POST':
staff.delete()
return redirect('users')
context = {
'staff': staff,
}
return render(request, "delete_templates/delete-staff-modal.html", context)
@staff_login_required
def delete_project_modal(request, project_id):
project = get_object_or_404(Project, id=project_id)
if request.method == 'POST':
project.delete()
return redirect('my-projects')
context = {
'project': project,
}
return render(request, "delete_templates/delete-project-modal.html", context)
@staff_login_required
def delete_project_note_modal(request, note_id):
note = get_object_or_404(Note, id=note_id)
if request.method == 'POST':
project_id = note.project_id
project = get_object_or_404(Project, id=project_id)
note.delete()
return redirect('detailed-project', project_id=project.project_id)
context = {
'note': note,
}
return render(request, "delete_templates/delete-project-note-modal.html", context)
@staff_login_required
def delete_task_modal(request, task_id):
task = get_object_or_404(Task, id=task_id)
if request.method == 'POST':
task.delete()
return redirect('my-tasks')
context = {
'task': task,
}
return render(request, "delete_templates/delete-task-modal.html", context)
@staff_login_required
def delete_ticket_modal(request, ticket_id):
ticket = get_object_or_404(Ticket, id=ticket_id)
if request.method == 'POST':
ticket.delete()
return redirect('tickets')
context = {
'ticket': ticket,
}
return render(request, "delete_templates/delete-ticket-modal.html", context)
@staff_login_required
def delete_point_modal(request, point_id, task_id):
task = get_object_or_404(Task, id=task_id)
point = get_object_or_404(Point, id=point_id)
if request.method == 'POST':
point.delete()
task_id_str = task.task_id
showpoints_url = reverse('showpoints', args=[task_id_str])
return HttpResponseRedirect(showpoints_url)
@staff_login_required
def delete_task_point_modal(request, point_id, task_id):
task = get_object_or_404(Task, id=task_id)
point = get_object_or_404(Point, id=point_id)
if request.method == 'POST':
point.delete()
task_id_str = task.task_id
task_details_url = reverse('detailed-task', args=[task_id_str])
return HttpResponseRedirect(task_details_url)
@staff_login_required
def delete_note_modal(request, note_id):
note = get_object_or_404(Note, id=note_id)
if request.method == 'POST':
note.delete()
return redirect('my-notes')
context = {
'note': note,
}
return render(request, "delete_templates/delete-note-modal.html", context)
@staff_login_required
def delete_payment_modal(request):
context = {
}
return render(request, "delete_templates/delete-payment-modal.html", context)
@staff_login_required
def delete_payment_method_modal(request):
context = {
}
return render(request, "delete_templates/delete-payment-method-modal.html", context)