Work on person methods and related and event badge everything
This commit is contained in:
@@ -35,6 +35,7 @@ base_fields['event_file_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['event_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['event_abstract_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['event_badge_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['event_badge_template_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['event_cfg_id_random'] = xxx_id_random_field_schema # Not really ready yet
|
||||
base_fields['event_device_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['event_location_id_random'] = xxx_id_random_field_schema
|
||||
|
||||
@@ -56,6 +56,8 @@ class Event_Badge_Base(BaseModel):
|
||||
country: Optional[str]
|
||||
location_name: Optional[str] # Actual location name shown on badge and other "public" areas
|
||||
|
||||
full_address: Optional[str]
|
||||
|
||||
# NOTE: More badge fields need to be added here once things are cleaned up
|
||||
|
||||
priority: Optional[bool]
|
||||
|
||||
97
app/models/event_badge_template_models.py
Normal file
97
app/models/event_badge_template_models.py
Normal file
@@ -0,0 +1,97 @@
|
||||
from __future__ import annotations
|
||||
import datetime, hashlib, logging, os, pytz, redis, secrets
|
||||
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, 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.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
**base_fields['event_badge_template_id_random'],
|
||||
alias = 'event_badge_template_id_random',
|
||||
default_factory = lambda:secrets.token_urlsafe(default_num_bytes),
|
||||
)
|
||||
id: Optional[int] = Field(
|
||||
alias = 'event_badge_template_id'
|
||||
)
|
||||
|
||||
# account_id_random: Optional[str]
|
||||
# account_id: Optional[int]
|
||||
|
||||
event_id_random: Optional[str]
|
||||
event_id: Optional[int]
|
||||
|
||||
name: Optional[str]
|
||||
description: Optional[str]
|
||||
|
||||
logo_filename: Optional[str]
|
||||
header_row_1: Optional[str]
|
||||
header_row_2: Optional[str]
|
||||
header_background: Optional[str]
|
||||
|
||||
footer_title: Optional[str]
|
||||
footer_left: Optional[str]
|
||||
footer_right: Optional[str]
|
||||
footer_background: Optional[str]
|
||||
|
||||
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]
|
||||
|
||||
style_filename: Optional[str]
|
||||
passcode: Optional[str]
|
||||
|
||||
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)
|
||||
|
||||
#@validator('event_badge_template_id_random', always=True)
|
||||
def event_badge_template_id_random_copy(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values['id_random']:
|
||||
return values['id_random']
|
||||
return None
|
||||
|
||||
@validator('id', always=True)
|
||||
def event_badge_template_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values['id_random']:
|
||||
log.debug(values['id_random'])
|
||||
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='event_badge_template')
|
||||
return None
|
||||
|
||||
@validator('event_id', always=True)
|
||||
def event_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values['event_id_random']:
|
||||
return redis_lookup_id_random(record_id_random=values['event_id_random'], table_name='event')
|
||||
return None
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
fields = base_fields
|
||||
Reference in New Issue
Block a user