refactor: build dynamically readonly_variables
This commit is contained in:
parent
d6d42250a9
commit
6d1db80bb3
1 changed files with 6 additions and 18 deletions
|
|
@ -22,24 +22,6 @@ def list_parse_fallback(v):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
# todo: remove
|
|
||||||
readonly_variables = [
|
|
||||||
"host",
|
|
||||||
"port",
|
|
||||||
"debug",
|
|
||||||
"lnbits_data_folder",
|
|
||||||
"lnbits_database_url",
|
|
||||||
"lnbits_allowed_funding_sources",
|
|
||||||
"lnbits_saas_secret",
|
|
||||||
"lnbits_saas_callback",
|
|
||||||
"lnbits_saas_instance_id",
|
|
||||||
"lnbits_admin_ui",
|
|
||||||
"lnbits_commit",
|
|
||||||
"lnbits_path",
|
|
||||||
"forwarded_allow_ips",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class LNbitsSetings(BaseSettings):
|
class LNbitsSetings(BaseSettings):
|
||||||
def validate(cls, val):
|
def validate(cls, val):
|
||||||
if type(val) == str:
|
if type(val) == str:
|
||||||
|
|
@ -248,6 +230,10 @@ class ReadOnlySettings(LNbitsSetings):
|
||||||
def validate_readonly_settings(cls, val):
|
def validate_readonly_settings(cls, val):
|
||||||
return super().validate(cls, val)
|
return super().validate(cls, val)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def readonly_fields(cls):
|
||||||
|
return [f for f in inspect.signature(cls).parameters if not f.startswith("_")]
|
||||||
|
|
||||||
|
|
||||||
class Settings(EditableSetings, ReadOnlySettings):
|
class Settings(EditableSetings, ReadOnlySettings):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -265,6 +251,8 @@ class AdminSettings(EditableSetings):
|
||||||
lnbits_allowed_funding_sources: Optional[List[str]]
|
lnbits_allowed_funding_sources: Optional[List[str]]
|
||||||
|
|
||||||
|
|
||||||
|
readonly_variables = ReadOnlySettings.readonly_fields()
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
|
|
||||||
settings.lnbits_path = str(path.dirname(path.realpath(__file__)))
|
settings.lnbits_path = str(path.dirname(path.realpath(__file__)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue