import datetime, pytz 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 from app.models.fundraising_cfg_models import Fundraising_Cfg_Base from app.models.membership_cfg_models import Membership_Cfg_Base # ### BEGIN ### API Account Cfg Models ### Account_Cfg_Base() ### class Account_Cfg_Base(BaseModel): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) id_random: Optional[str] = Field( # **base_fields['account_cfg_id_random'], alias = 'account_cfg_id_random', ) id: Optional[int] = Field( alias = 'account_cfg_id' ) account_id_random: Optional[str] account_id: Optional[int] account_code: Optional[str] account_name: Optional[str] account_short_name: Optional[str] account_description: Optional[str] account_enable: Optional[bool] account_enable_from: Optional[datetime.datetime] = None account_enable_to: Optional[datetime.datetime] = None modules_enabled: Optional[Json] = None show_user_availability: Optional[bool] show_person_create: Optional[bool] person_create_label: Optional[str] show_person_view: Optional[bool] person_view_label: Optional[str] show_person_load: Optional[bool] person_load_label: Optional[str] show_cart: Optional[bool] cart_label: Optional[str] default_no_reply_email: Optional[str] default_no_reply_name: Optional[str] default_reply_to_email: Optional[str] default_reply_to_name: Optional[str] confirm_email: Optional[str] confirm_name: Optional[str] # For general event help (attendees and registration) help_event_email: Optional[str] help_event_name: Optional[str] # For event exhibit help help_event_exhibit_email: Optional[str] help_event_exhibit_name: Optional[str] # For event presentation management help (chairs, organizers, persenters) help_event_presenter_email: Optional[str] help_event_presenter_name: Optional[str] # General catch all help help_general_email: Optional[str] help_general_name: Optional[str] # For contacting the organizations leadership (board, council, committee) help_leadership_email: Optional[str] help_leadership_name: Optional[str] # For general membership help help_member_email: Optional[str] help_member_name: Optional[str] # For general technical support help_tech_email: Optional[str] help_tech_name: Optional[str] order_header: Optional[str] order_thanks: Optional[str] order_message: Optional[str] order_footer: Optional[str] order_fundraising_thanks: Optional[str] order_fundraising_message: Optional[str] fundraising_message: Optional[str] post_rules: Optional[str] post_comment_rules: Optional[str] show_post_title: Optional[bool] show_post_comment_title: Optional[bool] hide_posts_after: Optional[int] # Should posts be singular? delete_posts_after: Optional[int] # Should posts be singular? stripe_api_key: Optional[str] # Secret/Private stripe_publishable_key: Optional[str] # Publish/Sharable stripe_account_id: Optional[str] # Connected Stripe Account ID created_on: Optional[datetime.datetime] = None updated_on: Optional[datetime.datetime] = None # Including other related objects fundraising_cfg: Optional[Fundraising_Cfg_Base] # Priority l2 membership_cfg: Optional[Membership_Cfg_Base] # Priority l2 _processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now) @validator('id', always=True) def account_cfg_id_lookup(cls, v, values, **kwargs): if isinstance(v, int) and v > 0: return v elif id_random := values.get('id_random'): return redis_lookup_id_random(record_id_random=id_random, table_name='account_cfg') return None @validator('account_id', always=True) def account_id_lookup(cls, v, values, **kwargs): if isinstance(v, int) and v > 0: return v elif id_random := values.get('account_id_random'): return redis_lookup_id_random(record_id_random=id_random, table_name='account') return None class Config: underscore_attrs_are_private = True allow_population_by_field_name = True fields = base_fields # ### END ### API Account Cfg Models ### Account_Cfg_Base() ###