An area is a list of postcodes, a shape drawn on a map or a circle around a point. The fee engine (both copies, byte-identical) matches a shape only by the customer's pin, then postcodes; point-in-polygon (edges inside) and haversine circles; shared cases in fee_cases.json. - Alembic 0053: delivery_areas.kind / geometry, orders.online_lat / lng - /api/connect/fees: areas with kind + geometry (validated: 3-200 corners, 50 m - 50 km), the venue's place (PUT /venue-point, setting venue.location, sent to the cloud as fees.venue_point), preview by lat / lng - manager: DeliveryMap (Leaflet + OpenStreetMap tiles): draw / move / remove corners, circles, the venue on the map, an overview, test an order by a point - pulled online orders keep the pin; the site re-checks the fee with it; the counter links the pin to a map - tests: backend (shapes, venue point, pinned orders), manager logic, e2e manager.mjs and order_app.mjs 6R.G blocks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
"""Delivery areas drawn on a map (owner 2026-11-20, plan 6R.G, services/fees.py).
|
|
|
|
- delivery_areas.kind: postcodes (the list, as before) | polygon | circle;
|
|
delivery_areas.geometry: JSON, [[lat, lng], …] for a polygon, {center: [lat, lng], radius_m} for a circle.
|
|
- orders.online_lat / online_lng: where the customer pinned the delivery (online orders).
|
|
|
|
Additive: every existing area stays a postcode list.
|
|
|
|
Revision ID: 0053_delivery_shapes
|
|
Revises: 0052_day_auto
|
|
Create Date: 2026-11-23 23:50:00
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = '0053_delivery_shapes'
|
|
down_revision = '0052_day_auto'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
with op.batch_alter_table('delivery_areas') as b:
|
|
b.add_column(sa.Column('kind', sa.String(), nullable=False, server_default='postcodes'))
|
|
b.add_column(sa.Column('geometry', sa.Text(), nullable=True))
|
|
with op.batch_alter_table('orders') as b:
|
|
b.add_column(sa.Column('online_lat', sa.Float(), nullable=True))
|
|
b.add_column(sa.Column('online_lng', sa.Float(), nullable=True))
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table('orders') as b:
|
|
b.drop_column('online_lng')
|
|
b.drop_column('online_lat')
|
|
with op.batch_alter_table('delivery_areas') as b:
|
|
b.drop_column('geometry')
|
|
b.drop_column('kind')
|