Port the campaign management page to auto.

Also fixes the oversight in the previous commit where float options were
not saved when changed.
This commit is contained in:
Dan Albert
2021-10-21 19:15:47 -07:00
parent 7bec4c62f7
commit a618f00662
9 changed files with 212 additions and 229 deletions

View File

@@ -0,0 +1,31 @@
from dataclasses import dataclass, field
from typing import Any, Optional
from .optiondescription import OptionDescription, SETTING_DESCRIPTION_KEY
@dataclass(frozen=True)
class BoundedIntOption(OptionDescription):
min: int
max: int
def bounded_int_option(
text: str,
page: str,
section: str,
default: int,
min: int,
max: int,
detail: Optional[str] = None,
**kwargs: Any,
) -> int:
return field(
metadata={
SETTING_DESCRIPTION_KEY: BoundedIntOption(
page, section, text, detail, min, max
)
},
default=default,
**kwargs,
)