diff --git a/osinaweb/billing/__pycache__/models.cpython-310.pyc b/osinaweb/billing/__pycache__/models.cpython-310.pyc index b5c56e7e..9ea9c697 100644 Binary files a/osinaweb/billing/__pycache__/models.cpython-310.pyc and b/osinaweb/billing/__pycache__/models.cpython-310.pyc differ diff --git a/osinaweb/billing/models.py b/osinaweb/billing/models.py index 3956c37d..1e3a4488 100644 --- a/osinaweb/billing/models.py +++ b/osinaweb/billing/models.py @@ -47,7 +47,6 @@ class Order(models.Model): if first_orderitem: return first_orderitem.purchased_at return None - def save(self, *args, **kwargs): if not self.order_id: order_count = Order.objects.filter(customer=self.customer).count() diff --git a/osinaweb/customercore/__pycache__/views.cpython-310.pyc b/osinaweb/customercore/__pycache__/views.cpython-310.pyc index fa986c57..014ffd42 100644 Binary files a/osinaweb/customercore/__pycache__/views.cpython-310.pyc and b/osinaweb/customercore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/customercore/views.py b/osinaweb/customercore/views.py index 83f46002..516a813a 100644 --- a/osinaweb/customercore/views.py +++ b/osinaweb/customercore/views.py @@ -33,7 +33,10 @@ def redirect_osicard(request): # ADD @customer_login_required def customer_add_ticket(request, *args, **kwargs): - customer_products = OrderItem.objects.filter(active__in=[True, None], item__type = 'Product', order__customer = request.user.customerprofile) + customer_orders = Order.objects.filter(customer=request.user.customerprofile) + customer_orders_with_last_status = customer_orders.annotate(max_status_date=Max('orderstatus__date')) + customer_orders_completed = customer_orders_with_last_status.filter(orderstatus__status='Completed',orderstatus__date=F('max_status_date')) + customer_products = OrderItem.objects.filter(active__in=[True, None], item__type = 'Product', order__customer = request.user.customerprofile, order__in=customer_orders_completed ) customer_projects = Project.objects.filter(customer=request.user.customerprofile) support_department = get_object_or_404(Department, name='Support') diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index a076d8e7..d2639dc3 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc index a05b2db2..a3f7b407 100644 Binary files a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/views.py b/osinaweb/osinacore/add/views.py index ef3a5f0c..ab75e8d3 100644 --- a/osinaweb/osinacore/add/views.py +++ b/osinaweb/osinacore/add/views.py @@ -654,7 +654,10 @@ def add_reaction(request, status_id, emoji): @staff_login_required def add_ticket(request, customer_id): customer= get_object_or_404(CustomerProfile, id=customer_id) - customer_products = OrderItem.objects.filter(order__status='Completed', active__in=[True, None], item__type='Product', order__customer=customer) + customer_orders = Order.objects.filter(customer=customer) + customer_orders_with_last_status = customer_orders.annotate(max_status_date=Max('orderstatus__date')) + customer_orders_completed = customer_orders_with_last_status.filter(orderstatus__status='Completed',orderstatus__date=F('max_status_date')) + customer_products = OrderItem.objects.filter(active__in=[True, None], item__type = 'Product', order__customer = customer, order__in=customer_orders_completed) customer_projects = Project.objects.filter(customer=customer) departments = Department.objects.all().order_by('name') if request.method == 'POST': @@ -686,7 +689,7 @@ def add_ticket(request, customer_id): opened_date = datetime.now() ) ticket.save() - ticket_status_update = TicketStatusUpdate( + ticket_status_update = TicketUpdate( ticket = ticket, status = 'Open', added_by = request.user,