From c56b07718ed6445c43ea18c282345e742425e850 Mon Sep 17 00:00:00 2001 From: candifloss Date: Tue, 18 Feb 2025 16:10:27 +0530 Subject: [PATCH] Started modularizing the attribute class --- definitions/attribute.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/definitions/attribute.py b/definitions/attribute.py index f27f577..4297075 100644 --- a/definitions/attribute.py +++ b/definitions/attribute.py @@ -1,3 +1,4 @@ +""" 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, default_val="", auto_increment=False, index=False, comment="", compareto=None): self.display_name = display_name # Input label or table column header. @@ -13,4 +14,32 @@ class Attribute: self.auto_increment = auto_increment # bool: MySQL autoincrement self.index = index # bool: MySQL index self.comment = comment # Description text - self.compareto = compareto # Compare to another attribute of the item for validation: ["comparison", "referenceattrib"] \ No newline at end of file + self.compareto = compareto # Compare to another attribute of the item for validation: ["comparison", "referenceattrib"] + ##default_val: Optional[str, int, float] = None, # HTML form input "value" attribute. Sets default value. +""" + +class Attribute: + def __init__(self, + display_name: str, # Input label or table column header. + html_input_type: str = "text", # HTML form input type. Determines MySQL data type. + placeholder: str = "text", # HTML form input placeholder. + required: bool = False, # HTML form input "required" attribute and MySQL "Not Null" constraint + unique: bool = False, # MySQL "unique" constraint + primary: bool = False, # MySQL "primary key" constraint + index: bool = False, # bool: MySQL index + compareto: Optional[List[str]] = None, # Compare to another attribute of the item for validation: ["comparison", "referenceattrib"] + title: str ="" # Description text, html "title" attribute + ): + self.display_name = display_name + if not display_name: + return f"Missing display name for attribute '{attrib_name}'." + self.html_input_type = html_input_type + if not html_input_type: + return f"Missing input type for attribute '{attrib_name}'." + self.required = required + self.unique = unique + self.primary = primary + self.default_val = default_val + self.index = index + self.compareto = compareto + self.title = title \ No newline at end of file