# -*- coding: utf-8 -*- from django.shortcuts import render from django.contrib.auth.decorators import login_required from products.models import Product, ProductCategory import json @login_required def pos_terminal(request): """ Tablet-friendly POS screen prototype. Shows categories and in-stock products for quick tap-to-add. """ categories_qs = ProductCategory.objects.filter(is_active=True) products_qs = Product.objects.filter(in_stock=True).prefetch_related('categories') categories = [{'id': c.id, 'name': c.name} for c in categories_qs] products = [{ 'id': p.id, 'name': p.name, 'price': str(p.actual_price), 'category_ids': [c.id for c in p.categories.all()] } for p in products_qs] context = { 'categories_json': json.dumps(categories), 'products_json': json.dumps(products), 'title': 'POS Terminal', } return render(request, 'pos/terminal.html', context)