diff --git a/paramecio2/libraries/db/corefields.py b/paramecio2/libraries/db/corefields.py index 7df6668..b8b05e3 100644 --- a/paramecio2/libraries/db/corefields.py +++ b/paramecio2/libraries/db/corefields.py @@ -216,7 +216,12 @@ class ForeignKeyField(IntegerField): """ Args: name (str): Name of field - + related_table(str): The table related with this foreign key + size (int): The size of the new field in database. By default 11. + required (bool): Boolean for define if field is required or not + identifier_field (str): The Id field name from related table + named_field (str): The field from related table used for identify the row seleted from related table + select_field (list): A series of fields names from related """ super(ForeignKeyField, self).__init__(name, size, required) @@ -258,8 +263,16 @@ class ForeignKeyField(IntegerField): class BooleanField(IntegerField): + """Field for boolean values + """ def __init__(self, name, size=1): + """ + Args: + name (str): Name of field + related_table(str): The table related with this foreign key + size (int): The size of the new field in database. By default 11. + """ required=False diff --git a/paramecio2/libraries/db/coreforms.py b/paramecio2/libraries/db/coreforms.py index 3247ddc..582070d 100644 --- a/paramecio2/libraries/db/coreforms.py +++ b/paramecio2/libraries/db/coreforms.py @@ -6,8 +6,30 @@ from html import escape #Forms para python3 class BaseForm: + """The class used by all forms classes + + BaseForm is the base class used for all form classes. + + A form class is used for generate simple html forms, how input type, text type, hidden type, etc. PhangoField classes use this forms for generate automatically forms using GenerateAdminClass and others. + """ def __init__(self, name, value): + """ + Args: + name (str): The html name for this form + value (str): The default value of this html form. + + Attributes: + label (str): Label used in functions how show_form that generate a complete html form from a form class list + name (str): Name of the html form. + default_value (mixed): The default value of the form. Equal to value in typical html form. + css (str): Used for add css classes to the html form + type (str): Variable used for conventional html forms with html tag + field (PhangoField): Field related with this form. Used in PhangoField. + required (boolean): If form is required or not, used in functions that generate forms. + name_field_id (str): The html id for the html form. Used for html things. + help (str): A string with help text, used in functions that generate forms. + """ self.label=name self.name=name @@ -21,22 +43,39 @@ class BaseForm: self.help='' def form(self): + """Method for returm the html code of the form + """ return '' def show_formatted(self, value): + """Method for show the value of form formatted + + Args: + value (mixed): The value of field form + """ return value #Method for escape value for html input. DON'T CHANGE IF YOU DON'T KNOWN WHAT ARE YOU DOING def setform(self, value): + """A method for set the value in the form for escape and other things + + Args: + value (mixed): The value of field form for set + """ value=str(value) return value.replace('"', '"').replace("'", ''') def change_name(self, new_name): + """A method for change the default form html name of the field form + + Args: + new_name (str): The new name of the form. Always is finished with _form suffix + """ self.name=new_name @@ -45,6 +84,8 @@ class BaseForm: return "" class SimpleTextForm(BaseForm): + """Form for simple text + """ def __init__(self, name, value): super().__init__(name, value) @@ -56,6 +97,8 @@ class SimpleTextForm(BaseForm): return super().form()+' '+self.after_text class TextForm(BaseForm): + """Form for simple text form + """ def __init__(self, name, value): super(TextForm, self).__init__(name, value) @@ -65,6 +108,8 @@ class TextForm(BaseForm): return '' class PasswordForm(BaseForm): + """Form for password forms + """ def __init__(self, name, value, show_password=False): super(PasswordForm, self).__init__(name, value) @@ -79,6 +124,8 @@ class PasswordForm(BaseForm): return value class HiddenForm(BaseForm): + """Form for hidden forms + """ def __init__(self, name, value): super(HiddenForm, self).__init__(name, value) @@ -86,8 +133,16 @@ class HiddenForm(BaseForm): class SelectForm(BaseForm): + """Form for select html form + """ def __init__(self, name, value, elements=OrderedDict()): + """ + Args: + ame (str): The html name for this form + value (str): The default value of this html form + elements (OrderedDict): An ordered dict with the keys(the form value) and text label. Example, if you have a OrderedDict how {'0': 'Value selected'} in a html select form you have the next result: