Создано приложение POS с планшетным интерфейсом терминала продаж

This commit is contained in:
2025-11-16 13:38:28 +03:00
parent a073b1aa77
commit 139ac431ee
14 changed files with 406 additions and 3 deletions

30
myproject/pos/views.py Normal file
View File

@@ -0,0 +1,30 @@
# -*- 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)