Attribute class for config
This commit is contained in:
parent
7aeee8da47
commit
aee98cb2b6
82
config.py
82
config.py
@ -1,39 +1,47 @@
|
|||||||
|
class Attribute:
|
||||||
|
def __init__(self, display_name, html_input_type="text", required=False, unique=False, primary=False, regex=None, min=None, max=None, options=None):
|
||||||
|
self.display_name = display_name
|
||||||
|
self.html_input_type = html_input_type
|
||||||
|
self.required = required
|
||||||
|
self.unique = unique
|
||||||
|
self.primary = primary
|
||||||
|
self.regex = regex
|
||||||
|
self.min = min
|
||||||
|
self.max = max
|
||||||
|
self.options = options
|
||||||
|
|
||||||
tableitems = {
|
tableitems = {
|
||||||
"assettag": {
|
"assettag": Attribute(
|
||||||
"display_name": "Asset Tag",
|
display_name="Asset Tag",
|
||||||
"html_input_type": "text",
|
html_input_type="text",
|
||||||
"required": True,
|
required=True,
|
||||||
"unique": True,
|
unique=True,
|
||||||
"primary_key": True,
|
primary=True,
|
||||||
"regex": r"^[A-Z0-9]+$",
|
regex=r"^[A-Z0-9]+$" # Only uppercase letters and numbers
|
||||||
}
|
),
|
||||||
"hostname": {
|
"hostname": Attribute(
|
||||||
"display_name": "Host Name",
|
display_name="Host Name",
|
||||||
"html_input_type": "text",
|
html_input_type="text",
|
||||||
"required": True,
|
required=True,
|
||||||
"unique": True,
|
unique=True,
|
||||||
"regex": r"^[a-z0-9._-]+$" #
|
regex=r"^[a-z0-9._-]+$" # Lowercase letters, numbers, dots, underscores, hyphens
|
||||||
},
|
),
|
||||||
"warrantyfrom": {
|
"warrantyfrom": Attribute(
|
||||||
"display_name": "Warranty From",
|
display_name="Warranty From",
|
||||||
"html_input_type": "date",
|
html_input_type="date",
|
||||||
"required": True,
|
required=True
|
||||||
regex: r"^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$" # Date in YYYY-MM-DD
|
),
|
||||||
},
|
"status": Attribute(
|
||||||
"status": {
|
display_name="Status",
|
||||||
"display_name": "Status",
|
html_input_type="select",
|
||||||
"html_input_type": "select",
|
required=True,
|
||||||
required: True,
|
options=["Active", "Inactive"] # Allowed values
|
||||||
options: [
|
),
|
||||||
"active": "Active",
|
"staffnum": Attribute(
|
||||||
"inactive": "Inactive"
|
display_name="Staff No.",
|
||||||
]
|
html_input_type="number",
|
||||||
},
|
required=True,
|
||||||
"staffnum": {
|
min=100000, # 6 digits
|
||||||
"display_name": "Staff No.",
|
max=99999999 # 8 digits
|
||||||
"html_input_type": "number",
|
)
|
||||||
"required": True,
|
|
||||||
"min": 100000, # 6 digits
|
|
||||||
"max": 99999999 # 8 digits
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user