New Sponsorships module. Related updates.
This commit is contained in:
@@ -23,6 +23,7 @@ class Account_Cfg_Base(BaseModel):
|
||||
id: Optional[int] = Field(
|
||||
alias = 'account_cfg_id'
|
||||
)
|
||||
|
||||
account_id_random: Optional[str]
|
||||
account_id: Optional[int]
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ base_fields['post_comment_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['product_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['site_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['site_domain_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['sponsorship_cfg_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['sponsorship_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['user_id_random'] = xxx_id_random_field_schema
|
||||
base_fields['user_role_id_random'] = xxx_id_random_field_schema
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ class Event_Base(BaseModel):
|
||||
attend_phone: Optional[str]
|
||||
attend_phone_passcode: Optional[str]
|
||||
attend_text: Optional[str]
|
||||
attend_json: Optional[Union[Json, None]]
|
||||
|
||||
# NOT FINISHED YET
|
||||
|
||||
|
||||
100
app/models/sponsorship_cfg_models.py
Normal file
100
app/models/sponsorship_cfg_models.py
Normal file
@@ -0,0 +1,100 @@
|
||||
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
|
||||
|
||||
|
||||
# ### BEGIN ### API Sponsorship Cfg Models ### Sponsorship_Cfg_Base() ###
|
||||
class Sponsorship_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]
|
||||
|
||||
code: Optional[str]
|
||||
name: Optional[str]
|
||||
description: Optional[str]
|
||||
|
||||
for_type: Optional[str]
|
||||
for_id: Optional[int]
|
||||
|
||||
# For levels in a JSON object list format. A level option should contain: num, str, name, desc. Example: {"num": 1, "code": "platinum", "name": "Platinum", "desc": "Platinum Sponsorship"}
|
||||
level_li_json: Optional[Union[Json, None]]
|
||||
|
||||
# For options in a JSON object list format. An option should contain: id, code, name, desc, note. Example: {"id": 1, "code": "option_1", "name": "Option 1", "desc": "Option 1 Description", "note": "Option 1 Note"}
|
||||
option_li_json: Optional[Union[Json, None]]
|
||||
|
||||
# These are the common dates and deadlines used. They can be overridden by the deadline_li_json.
|
||||
start_datetime: Optional[datetime.datetime] = None
|
||||
end_datetime: Optional[datetime.datetime] = None
|
||||
start_deadline: Optional[datetime.datetime] = None
|
||||
end_deadline: Optional[datetime.datetime] = None
|
||||
payment_deadline: Optional[datetime.datetime] = None
|
||||
rsvp_deadline: Optional[datetime.datetime] = None
|
||||
|
||||
# For additional dates and deadlines in a JSON object list format. Example: {"early_bird": "2025-01-01", "regular": "2025-02-01", "late": "2025-03-01"}
|
||||
schedule_datetime_li_json: Optional[Union[Json, None]]
|
||||
|
||||
default_no_reply_email: Optional[str]
|
||||
default_no_reply_name: Optional[str]
|
||||
default_reply_to_email: Optional[str]
|
||||
default_reply_to_name: Optional[str]
|
||||
|
||||
# This is for a confirmation email to be sent to a staff email address
|
||||
confirm_email: Optional[str]
|
||||
confirm_name: Optional[str]
|
||||
|
||||
# For help options in a JSON object list format. Options for who to contact for help or support in a list format. A help option should contain: purpose, name, email, subject. Example: {"purpose": "sponsorship", "name": "John Doe", "email": ", "subject": "Sponsorship Help"}
|
||||
help_li_json: Optional[Union[Json, None]]
|
||||
|
||||
# For additional configuration options in a JSON object format.
|
||||
cfg_json: Optional[Union[Json, None]]
|
||||
|
||||
# The standard fields:
|
||||
enable: Optional[bool]
|
||||
hide: Optional[bool]
|
||||
priority: Optional[bool]
|
||||
sort: Optional[int]
|
||||
group: Optional[str]
|
||||
notes: Optional[str]
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
# Including other related objects
|
||||
# example_cfg: Optional[Example_Cfg_Base]
|
||||
|
||||
_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 Sponsorship Cfg Models ### Sponsorship_Cfg_Base() ###
|
||||
120
app/models/sponsorship_models.py
Normal file
120
app/models/sponsorship_models.py
Normal file
@@ -0,0 +1,120 @@
|
||||
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.sponsorship_cfg_models import Sponsorship_Cfg_Base
|
||||
|
||||
|
||||
# ### BEGIN ### API Sponsorship Models ### Sponsorship_Base() ###
|
||||
class Sponsorship_Base(BaseModel):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
**base_fields['sponsorship_id_random'],
|
||||
alias = 'sponsorship_id_random',
|
||||
)
|
||||
id: Optional[int] = Field(
|
||||
alias = 'sponsorship_id'
|
||||
)
|
||||
|
||||
account_id_random: Optional[str]
|
||||
account_id: Optional[int]
|
||||
|
||||
sponsorship_cfg_id_random: Optional[str]
|
||||
sponsorship_cfg_id: Optional[int]
|
||||
|
||||
name: Optional[str]
|
||||
description: Optional[str]
|
||||
|
||||
# This should be required for the confirmation email to be sent to the sponsor. The person's name and email address in the "To" address line.
|
||||
poc_email_name: Optional[str]
|
||||
poc_email: Optional[str]
|
||||
|
||||
# For the sponsoring organization, person, and point of contact in a JSON object format. The Aether standard field names should be used. Examples: name, given_name, family_name, full_name, full_name_override, email, phone, address_line_1, city, state_province, postal_code, country, etc.
|
||||
# Example poc_json: {"given_name": "John", "family_name": "Doe", "full_name": "John Doe", "full_name_override": "John Doe", "email": "john.doe@example.com"}
|
||||
organization_json: Optional[Union[Json, None]]
|
||||
person_json: Optional[Union[Json, None]]
|
||||
poc_json: Optional[Union[Json, None]]
|
||||
|
||||
# For the logo and image in a JSON object format. The Aether standard field names should be used. Examples: url, url_text, alt_text, width, height, etc.
|
||||
logo_li_json: Optional[Union[Json, None]]
|
||||
|
||||
# For media that have different predefined purposes in a JSON object list format. The Aether standard field names should be used. Examples: purpose, (file) type, (file) extension, (file) name, url, url_text, alt_text, width, height, size (in bytes), etc.
|
||||
media_li_json: Optional[Union[Json, None]]
|
||||
|
||||
# For social media in a JSON object format. The Aether standard field names should be used. Examples: url, url_text, icon, etc.
|
||||
social_li_json: Optional[Union[Json, None]]
|
||||
|
||||
# For a (simple and short) guest list in a JSON object list format. A guest person should contain: given_name, family_name, full_name, email, phone, etc.
|
||||
# Example: [{"given_name": "John", "family_name": "Doe", "full_name": "John Doe", "email": "john.doe@example.com"}, {"given_name": "Jane", "family_name": "Doe", "full_name": "Jane Doe", "email": "jane.doe@example.com"}]
|
||||
# Example 2: [{"full_name": "Albert Einstein", "email": "albert.einstein@example.com"}, {"full_name": "Marie Curie", "email": "marie.curie@example.com"}]
|
||||
guest_li_json: Optional[Union[Json, None]]
|
||||
|
||||
level_num: Optional[int]
|
||||
level_str: Optional[str]
|
||||
|
||||
# For their selected sponsorship level in a JSON object format. A level option should contain: num, code, name, desc. Example: {"num": 1, "code": "platinum", "name": "Platinum", "desc": "Platinum Sponsorship"}
|
||||
slct_level_json: Optional[Union[Json, None]]
|
||||
|
||||
# For their selected options in a JSON object list format. An option should contain: id, code, name, desc, note. Example: {"id": 1, "code": "option_1", "name": "Option 1", "desc": "Option 1 Description", "note": "Option 1 Note"}
|
||||
slct_option_li_json: Optional[Union[Json, None]]
|
||||
|
||||
# Amount as an integer in cents. Example: 1000 = $10.00
|
||||
amount: Optional[int]
|
||||
paid: Optional[bool]
|
||||
|
||||
access_key: Optional[str] # This is for a unique access key or passcode to be used for a sponsorship page edit access.
|
||||
|
||||
# Comments from the sponsor. Assumed to be the POC. This is for internal use only.
|
||||
comments: Optional[str]
|
||||
|
||||
cfg_json: Optional[Union[Json, None]]
|
||||
meta_data: Optional[str]
|
||||
|
||||
# The standard fields:
|
||||
enable: Optional[bool]
|
||||
hide: Optional[bool]
|
||||
priority: Optional[bool]
|
||||
sort: Optional[int]
|
||||
group: Optional[str]
|
||||
notes: Optional[str]
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
# Including other related objects
|
||||
# example_cfg: Optional[Example_Cfg_Base]
|
||||
|
||||
_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
|
||||
|
||||
@validator('sponsorship_cfg_id', always=True)
|
||||
def sponsorship_cfg_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('sponsorship_cfg_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='sponsorship_cfg')
|
||||
return None
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
fields = base_fields
|
||||
# ### END ### API Sponsorship Models ### Sponsorship_Base() ###
|
||||
Reference in New Issue
Block a user