Address critical data visibility issues for Event Files and enhance frontend documentation.
This commit resolves the persistent problem where top-level hosted file convenience fields
(e.g., , , ) were
returning as in V3 Event File API responses, even when .
Key changes include:
- Refactored Pydantic model:
- Removed redundant definitions from top-level hosted file convenience fields,
allowing direct mapping from SQL view columns.
- Simplified to focus solely on conditionally loading the nested
object, as top-level fields are now populated directly by Pydantic
from the view.
- Added comprehensive comments to clarify data flow, Pydantic's behavior, and the
expected origin of these convenience fields from SQL views.
- Updated :
- Introduced a new section detailing how to retrieve Event File data, including the
use of to get both top-level convenience fields and a nested
object.
- Clarified all ID references as random string IDs.
- Renumbered the troubleshooting section.
- Copied updated guide to .
- Continued ID Vision compliance audit, ensuring consistent handling of random string IDs
across various core and event models (Account, Address, Contact, DataStore, Event Badge Template).
- Consolidated ID Vision E2E tests and updated related documentation.
- Minor updates to and
to support Event File data retrieval with .
137 lines
4.1 KiB
Python
137 lines
4.1 KiB
Python
import datetime, pytz
|
|
|
|
from typing import Dict, List, Optional, Set, Union, ClassVar
|
|
from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, validator, root_validator
|
|
|
|
from app.db_sql import redis_lookup_id_random
|
|
from app.lib_general import log, logging
|
|
|
|
from app.models.common_field_schema import base_fields, default_num_bytes
|
|
|
|
|
|
class Event_Badge_Template_Base(BaseModel):
|
|
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
|
log.debug(locals())
|
|
|
|
# log.info('Using base template')
|
|
|
|
# --- Standardized Vision IDs (Strings) ---
|
|
id: Optional[str] = Field(None, **base_fields['event_badge_template_id_random'])
|
|
event_badge_template_id: Optional[str] = Field(None, **base_fields['event_badge_template_id_random'])
|
|
event_id: Optional[str] = Field(None, **base_fields['event_id_random'])
|
|
|
|
# --- Standardized Legacy / Internal IDs (Excluded) ---
|
|
id_random: Optional[str] = Field(None, alias='event_badge_template_id_random', exclude=True)
|
|
event_id_random: Optional[str] = Field(None, exclude=True)
|
|
|
|
name: Optional[str]
|
|
description: Optional[str]
|
|
|
|
logo_filename: Optional[str]
|
|
logo_path: Optional[str]
|
|
header_path: Optional[str] # Path to image file
|
|
header_row_1: Optional[str]
|
|
header_row_2: Optional[str]
|
|
header_background: Optional[str]
|
|
|
|
secondary_header_path: Optional[str] # Path to image file for back of badge and other sections
|
|
|
|
footer_path: Optional[str] # Path to image file
|
|
footer_title: Optional[str]
|
|
footer_left: Optional[str]
|
|
footer_right: Optional[str]
|
|
footer_background: Optional[str]
|
|
|
|
badge_type_list: Optional[Json]
|
|
|
|
ticket_list: Optional[Json]
|
|
ticket_1_text: Optional[str]
|
|
ticket_2_text: Optional[str]
|
|
ticket_3_text: Optional[str]
|
|
ticket_4_text: Optional[str]
|
|
ticket_5_text: Optional[str]
|
|
ticket_6_text: Optional[str]
|
|
ticket_7_text: Optional[str]
|
|
ticket_8_text: Optional[str]
|
|
|
|
wireless_ssid: Optional[str]
|
|
wireless_password: Optional[str]
|
|
|
|
show_qr_front: Optional[bool]
|
|
show_qr_back: Optional[bool]
|
|
|
|
# Layouts:
|
|
# 4x3_pcnametag_N2TIC_tickets, 4.25x6_pcnametag_NS2VWB_badge_only
|
|
# 4x3_custom_receipt_tickets, 4.25x6_custom_receipt_tickets
|
|
layout: Optional[str]
|
|
style_filename: Optional[str]
|
|
style_href: Optional[str]
|
|
script_src: Optional[str]
|
|
passcode: Optional[str]
|
|
|
|
other_json: Optional[str]
|
|
|
|
enable: Optional[bool]
|
|
notes: Optional[str]
|
|
created_on: Optional[datetime.datetime] = None
|
|
updated_on: Optional[datetime.datetime] = None
|
|
|
|
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
|
|
|
@root_validator(pre=True)
|
|
def map_v3_ids(cls, values):
|
|
"""
|
|
Vision Transformer:
|
|
Map DB keys to clean API keys and strip internal integers.
|
|
"""
|
|
# 1. Map Random Strings to Clean Names
|
|
if rid := values.get('id_random') or values.get('event_badge_template_id_random'):
|
|
values['id'] = rid
|
|
values['event_badge_template_id'] = rid
|
|
|
|
if e_rid := values.get('event_id_random'):
|
|
values['event_id'] = e_rid
|
|
|
|
# 2. Prevent "Collision Population" (ensure no integers leak into the clean string fields)
|
|
for k in ['id', 'event_badge_template_id', 'event_id']:
|
|
if k in values and not isinstance(values[k], str) and values[k] is not None:
|
|
del values[k]
|
|
|
|
return values
|
|
|
|
class Config:
|
|
underscore_attrs_are_private = True
|
|
allow_population_by_field_name = False
|
|
fields = base_fields
|
|
|
|
|
|
class Event_Badge_Template_Base_In(Event_Badge_Template_Base):
|
|
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
|
log.debug(locals())
|
|
|
|
# log.info('Using In template')
|
|
|
|
badge_type_list: Optional[str]
|
|
|
|
|
|
class Event_Badge_Template_Base_Out(Event_Badge_Template_Base):
|
|
|
|
|
|
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
|
|
|
|
|
log.debug(locals())
|
|
|
|
|
|
|
|
|
|
|
|
# log.info('Using Out template')
|
|
|
|
|
|
|
|
|
|
|
|
# badge_type_list: Optional[Json]
|
|
|