api.services.model_sheet ======================== .. py:module:: api.services.model_sheet .. autoapi-nested-parse:: An Airtable Model as the commercial team reviews it: everything its sheet says (identity, descriptions, dimensions, photos, documents, its variations with their specifications and units in stock), and the fields they may correct from the app (specifications included). Edits are explicit (one "Enregistrer" in the app) and checked against the values the app showed: a field changed in Airtable meanwhile is refused (409), never overwritten. Attributes ---------- .. autoapisummary:: api.services.model_sheet.MODEL_TABLE api.services.model_sheet.VARIATION_TABLE api.services.model_sheet.SPEC_TABLE api.services.model_sheet.TEXT_FIELDS api.services.model_sheet.NUMBER_FIELDS api.services.model_sheet.FLAG_FIELDS api.services.model_sheet.CHOICE_FIELDS api.services.model_sheet.EDITABLE api.services.model_sheet.DOCUMENT_FIELDS api.services.model_sheet.MAX_ATTACHMENT_BYTES api.services.model_sheet.VERIFIED_FIELD api.services.model_sheet.STOCK_FORMULA api.services.model_sheet.UNIT_PHOTOS_FIELD api.services.model_sheet.UNIT_CHUNK Functions --------- .. autoapisummary:: api.services.model_sheet.read_sheet api.services.model_sheet.clean_value api.services.model_sheet.update_model api.services.model_sheet.attach_pdf api.services.model_sheet.attach_document api.services.model_sheet.add_spec api.services.model_sheet.update_spec api.services.model_sheet.delete_spec Module Contents --------------- .. py:data:: MODEL_TABLE :value: 'Model' .. py:data:: VARIATION_TABLE :value: 'Variation' .. py:data:: SPEC_TABLE :value: 'Specification' .. py:data:: TEXT_FIELDS .. py:data:: NUMBER_FIELDS .. py:data:: FLAG_FIELDS .. py:data:: CHOICE_FIELDS .. py:data:: EDITABLE .. py:data:: DOCUMENT_FIELDS .. py:data:: MAX_ATTACHMENT_BYTES :value: 5242880 .. py:data:: VERIFIED_FIELD :value: 'Vérification pour site' .. py:data:: STOCK_FORMULA :value: '{Statut commercial} != "Vendu"' .. py:data:: UNIT_PHOTOS_FIELD :value: 'Photos interne' .. py:data:: UNIT_CHUNK :value: 50 .. py:function:: read_sheet(at: api.services.catalog_sync.AirtableGateway, model_id: str, variation_id: str | None, options: dict[str, Any], all_variations: bool = False) -> dict[str, Any] The Model's sheet; ``options`` is catalog_lookup.load_options() (names of brands, types and specification keys). ``all_variations`` adds every variation with its specifications and its units in stock (the review). .. py:function:: clean_value(key: str, value: Any) -> Any The value to write, or ValueError with a message for the user. .. py:function:: update_model(at: api.services.catalog_sync.AirtableGateway, model_id: str, changes: dict[str, Any], expected: dict[str, Any]) -> dict[str, Any] Write ``changes`` (app keys) when Airtable still holds ``expected`` (the values the app showed) for each of them. .. py:function:: attach_pdf(at: api.services.catalog_sync.AttachmentGateway, model_id: str, data: bytes, filename: str) -> dict[str, Any] Upload a PDF file to the Model's « Documentation » (Airtable's content API: 5 MB max), unless a file of the same name is already there. .. py:function:: attach_document(at: api.services.catalog_sync.AirtableGateway, model_id: str, field_key: str, url: str, filename: str) -> dict[str, Any] Add a document (by URL: Airtable downloads it) to one of the Model's document fields, keeping those already there; a file of the same name is not added twice. .. py:function:: add_spec(at: api.services.catalog_sync.AirtableGateway, variation_id: str, spec_type_id: str, valeur: Any, unite: Any) -> dict[str, Any] A new specification (an existing key) on the variation. .. py:function:: update_spec(at: api.services.catalog_sync.AirtableGateway, spec_id: str, valeur: Any, unite: Any) -> dict[str, Any] .. py:function:: delete_spec(at: api.services.catalog_sync.AirtableGateway, spec_id: str) -> None Refused (409 ``variant_axis``) for the spec that tells a variant apart.