More documentation

This commit is contained in:
Antonio de la Rosa 2021-06-01 11:50:24 +02:00
parent c96ed2e491
commit d88139030b
2 changed files with 38 additions and 6 deletions

View file

@ -7,8 +7,23 @@ from flask import session
from paramecio2.libraries.keyutils import create_key_encrypt
# Need unittest
"""Functions and classes for process forms"""
def pass_values_to_form(post, arr_form, yes_error=True, pass_values=True):
"""Function for pass a dict with form values for check using forms dict
Values dict and Forms dict need have the same key. A forms dict is maked of a serie of paramecio2 forms elements, used for check the value.
Args:
post (dict): Dict composed by a series of values. The keys need to be equal to keys of arr_form dict.
arr_form (dict): Dict composed by a series or forms objects. The keys need to be equal to keys of post dict.
yes_error (bool): Show errors in txt_error form variables.
pass_values (bool): Pass default values or values from post dict to arr_form dict items
Returns:
dict: Return arr_form dict with checked values from post dict.
"""
if pass_values:
def get_value(key):
@ -44,12 +59,26 @@ def pass_values_to_form(post, arr_form, yes_error=True, pass_values=True):
return arr_form
class CheckForm():
"""Simple class for make similar check to pass_values_to_form. More simple.
"""
def __init__(self):
self.error=0
def check(self, post, arr_form):
"""Simple method for pass a dict with form values for check using forms dict
Values dict and Forms dict need have the same key. A forms dict is maked of a serie of paramecio2 forms elements, used for check the value.
Args:
post (dict): Dict composed by a series of values. The keys need to be equal to keys of arr_form dict.
arr_form (dict): Dict composed by a series or forms objects. The keys need to be equal to keys of post dict.
Returns:
dict: Return arr_form dict with checked values from post dict.
"""
for k in arr_form.keys():