- Add CatalogueImage model with FK to Product - Add image resize service (strict/non-strict modes with configurable dimensions) - Add CRUD API endpoints with admin-only write permissions - Add catalogue_images field to product listing/detail endpoints - Serve media files in development via static() - 28 TDD tests covering model, API, permissions, resize, and product listing
99 lines
2.5 KiB
Python
99 lines
2.5 KiB
Python
from django.urls import path, include
|
|
from rest_framework.routers import DefaultRouter
|
|
|
|
from . import views
|
|
from .api import (
|
|
# Catalogue Images
|
|
CatalogueImageViewSet,
|
|
# Products
|
|
ProductView,
|
|
ProductsFromTrytonView,
|
|
# Customers
|
|
CustomerView,
|
|
CustomersFromTrytonView,
|
|
# Sales
|
|
SaleView,
|
|
CatalogSaleView,
|
|
SaleSummary,
|
|
CatalogSaleSummary,
|
|
SalesForTrytonView,
|
|
SalesToTrytonView,
|
|
CatalogSalesToTrytonView,
|
|
# Payments
|
|
ReconciliateJarView,
|
|
ReconciliateJarModelView,
|
|
PaymentMethodView,
|
|
SalesForReconciliationView,
|
|
# Admin
|
|
AdminCodeValidateView,
|
|
)
|
|
|
|
app_name = "don_confiao"
|
|
|
|
router = DefaultRouter()
|
|
router.register(r"sales", SaleView, basename="sale")
|
|
router.register(r"catalog_sales", CatalogSaleView, basename="catalog_sale")
|
|
router.register(r"customers", CustomerView, basename="customer")
|
|
router.register(r"products", ProductView, basename="product")
|
|
router.register(
|
|
r"catalogue_images",
|
|
CatalogueImageViewSet,
|
|
basename="catalogue_image",
|
|
)
|
|
router.register(
|
|
r"reconciliate_jar",
|
|
ReconciliateJarModelView,
|
|
basename="reconciliate_jar",
|
|
)
|
|
|
|
urlpatterns = [
|
|
path("productos", views.products, name="products"),
|
|
path(
|
|
"resumen_compra_json/<int:id>",
|
|
SaleSummary.as_view(),
|
|
name="purchase_json_summary",
|
|
),
|
|
path(
|
|
"resumen_compra_catalogo_json/<int:id>",
|
|
CatalogSaleSummary.as_view(),
|
|
name="catalog_purchase_json_summary",
|
|
),
|
|
path(
|
|
"payment_methods/all/select_format",
|
|
PaymentMethodView.as_view(),
|
|
name="payment_methods_to_select",
|
|
),
|
|
path(
|
|
"purchases/for_reconciliation",
|
|
SalesForReconciliationView.as_view(),
|
|
name="sales_for_reconciliation",
|
|
),
|
|
path("reconciliate_jar", ReconciliateJarView.as_view()),
|
|
path("api/", include(router.urls)),
|
|
path(
|
|
"api/importar_productos_de_tryton",
|
|
ProductsFromTrytonView.as_view(),
|
|
name="products_from_tryton",
|
|
),
|
|
path(
|
|
"api/importar_clientes_de_tryton",
|
|
CustomersFromTrytonView.as_view(),
|
|
name="customers_from_tryton",
|
|
),
|
|
path(
|
|
"api/enviar_ventas_a_tryton",
|
|
SalesToTrytonView.as_view(),
|
|
name="send_tryton",
|
|
),
|
|
path(
|
|
"api/enviar_catalog_sales_a_tryton",
|
|
CatalogSalesToTrytonView.as_view(),
|
|
name="send_catalog_sales_tryton",
|
|
),
|
|
path(
|
|
"api/admin_code/validate/<code>",
|
|
AdminCodeValidateView.as_view(),
|
|
),
|
|
path("api/sales/for_tryton", SalesForTrytonView.as_view()),
|
|
]
|