Fixes in documentation
This commit is contained in:
parent
cfb70403c1
commit
dc58175760
13 changed files with 119 additions and 113 deletions
|
|
@ -16,6 +16,9 @@ except:
|
|||
#sys.exit(1)
|
||||
pass
|
||||
|
||||
"""Command line utility for extract I18n.lang strings from html templates and .py files
|
||||
"""
|
||||
|
||||
pattern=re.compile('^\w+\.(py|html|phtml|js)$')
|
||||
|
||||
ignored=re.compile('^[__|\.].*$')
|
||||
|
|
@ -26,6 +29,8 @@ lang_t=re.compile("\${lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)\}")
|
|||
tmp_lang={}
|
||||
|
||||
def start():
|
||||
"""Function for extract I18n.lang strings from html templates and .py files using regular expressions
|
||||
"""
|
||||
|
||||
global lang_p
|
||||
global lang_t
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
|
||||
# Variable base for admin modules
|
||||
|
||||
"""Variables for control admin modules for admin module
|
||||
"""
|
||||
|
||||
config_admin=[]
|
||||
"""list: List for save the differente admin configurations from paramecio2 modules
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ def format_timedata(time):
|
|||
time (str): A YYYYMMDDHHmmss string for get datetime components from there.
|
||||
|
||||
Returns:
|
||||
list: A dict with datetime components (year, month, day, hour, minute, second).
|
||||
list (list): A dict with datetime components (year, month, day, hour, minute, second).
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ def checkdatetime(y, m, d, h, mi, s):
|
|||
s (int): seconds
|
||||
|
||||
Returns:
|
||||
bool: If values are correct, return True, otherwise return False
|
||||
bool (bool): If values are correct, return True, otherwise return False
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ def now(utc=False, tz=''):
|
|||
tz (str, optional): Timezone name, example: Europe/Madrid. If set the datetime is returned in the timezone selected
|
||||
|
||||
Returns:
|
||||
str: Return actual datetime
|
||||
datetime (str): Return actual datetime
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ def today(utc=False,tz=''):
|
|||
tz (str, optional): Timezone name, example: Europe/Madrid. If set the date is returned in the timezone selected
|
||||
|
||||
Returns:
|
||||
str: Return actual date with 00:00:00 how time
|
||||
datetime (str): Return actual date with 00:00:00 how time
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ def obtain_timestamp(timeform):
|
|||
|
||||
Returns:
|
||||
|
||||
int: datetime in timestamp format
|
||||
Timestamp (int): datetime in timestamp format
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ def timestamp_to_datetime(timestamp, sql_format_time=sql_format_time):
|
|||
timestamp (int): The timestamp for convert
|
||||
|
||||
Returns:
|
||||
str: Datetime in YYYYMMDDHHmmss format
|
||||
datetime (str): Datetime in YYYYMMDDHHmmss format
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ def timestamp_to_datetime_local(timestamp, tz='', sql_format_time=sql_format_tim
|
|||
|
||||
Returns:
|
||||
|
||||
str: Datetime in YYYYMMDDHHmmss format in selected timezone datetime
|
||||
datetime (str): Datetime in YYYYMMDDHHmmss format in selected timezone datetime
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ def format_datetime(format_time, timeform, func_utc_return):
|
|||
func_utc_return (function): A function used for get the datetime.
|
||||
|
||||
Returns:
|
||||
If timestamp is False, return False, if timestamp is valid, return the datetime formatted
|
||||
datetime (str): If timestamp is False, return False, if timestamp is valid, return the datetime formatted
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -293,7 +293,7 @@ def local_to_gmt(timeform, sql_format_time=sql_format_time):
|
|||
sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ def gmt_to_local(timeform, sql_format_time=sql_format_time):
|
|||
sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ def format_time(timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ def format_date(timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
"""
|
||||
|
||||
return format_datetime(format_date_txt, timeform, sum_utc)
|
||||
|
|
@ -353,7 +353,7 @@ def format_fulldate(timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
"""
|
||||
|
||||
return format_datetime(format_date_txt+' '+format_time_txt, timeform, sum_utc)
|
||||
|
|
@ -366,7 +366,7 @@ def format_local_time(timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
"""
|
||||
|
||||
return format_datetime(format_time_txt, timeform, no_utc)
|
||||
|
|
@ -379,7 +379,7 @@ def format_local_date(timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
"""
|
||||
|
||||
return format_datetime(format_date_txt, timeform, no_utc)
|
||||
|
|
@ -392,7 +392,7 @@ def format_local_fulldate(timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
"""
|
||||
|
||||
return format_datetime(format_date_txt+' '+format_time_txt, timeform, no_utc)
|
||||
|
|
@ -405,7 +405,7 @@ def format_strtime(strtime, timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
|
||||
"""
|
||||
|
||||
return format_datetime(strtime, timeform, sum_utc)
|
||||
|
|
@ -418,7 +418,7 @@ def format_local_strtime(strtime, timeform):
|
|||
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
|
||||
|
||||
Returns:
|
||||
If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
|
||||
"""
|
||||
|
||||
return format_datetime(strtime, timeform, no_utc)
|
||||
|
|
@ -434,7 +434,7 @@ def sum_utc(timestamp, tz=''):
|
|||
tz (str): Timezone of timestamp
|
||||
|
||||
Returns:
|
||||
Return arrow object with new timezone selected
|
||||
datetime (str): Return arrow object with new timezone selected
|
||||
"""
|
||||
|
||||
#offset=time.altzone
|
||||
|
|
@ -459,7 +459,7 @@ def substract_utc(timestamp, tz=''):
|
|||
tz (str): Timezone of timestamp
|
||||
|
||||
Returns:
|
||||
Return arrow object with UTC timezone selected
|
||||
datetime (str): Return arrow object with UTC timezone selected
|
||||
"""
|
||||
|
||||
#offset=time.altzone
|
||||
|
|
@ -487,7 +487,7 @@ def no_utc(timestamp):
|
|||
timestamp (int): The timestamp for convert in UTC timezone
|
||||
|
||||
Returns:
|
||||
Return arrow object based in timestamp value
|
||||
datetime (str): Return arrow object based in timestamp value
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -550,7 +550,7 @@ class TimeClass:
|
|||
num_months (int): Number of months to add
|
||||
|
||||
Returns:
|
||||
New added datetime
|
||||
datetime (str): New added datetime
|
||||
"""
|
||||
|
||||
m=self.t.shift(months=+num_months)
|
||||
|
|
@ -564,7 +564,7 @@ class TimeClass:
|
|||
num_months (int): Number of months to substract
|
||||
|
||||
Returns:
|
||||
New substracted datetime
|
||||
datetime (str): New substracted datetime
|
||||
"""
|
||||
|
||||
m=self.t.shift(months=-num_months)
|
||||
|
|
@ -578,7 +578,7 @@ class TimeClass:
|
|||
num_days (int): Number of days to add
|
||||
|
||||
Returns:
|
||||
New added datetime
|
||||
datetime (str): New added datetime
|
||||
"""
|
||||
|
||||
m=self.t.shift(days=+num_days)
|
||||
|
|
@ -592,7 +592,7 @@ class TimeClass:
|
|||
num_days (int): Number of days to substract
|
||||
|
||||
Returns:
|
||||
New substracted datetime
|
||||
datetime (str): New substracted datetime
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -607,7 +607,7 @@ class TimeClass:
|
|||
num_years (int): Number of years to add
|
||||
|
||||
Returns:
|
||||
New added datetime
|
||||
datetime (str): New added datetime
|
||||
"""
|
||||
|
||||
m=self.t.shift(years=+num_years)
|
||||
|
|
@ -621,7 +621,7 @@ class TimeClass:
|
|||
num_years (int): Number of years to substract
|
||||
|
||||
Returns:
|
||||
New substracted datetime
|
||||
datetime (str): New substracted datetime
|
||||
"""
|
||||
|
||||
m=self.t.shift(years=-num_years)
|
||||
|
|
@ -635,7 +635,7 @@ class TimeClass:
|
|||
num_hours (int): Number of hours to add
|
||||
|
||||
Returns:
|
||||
New added datetime
|
||||
datetime (str): New added datetime
|
||||
"""
|
||||
|
||||
m=self.t.shift(hours=+num_hours)
|
||||
|
|
@ -649,7 +649,7 @@ class TimeClass:
|
|||
num_hours (int): Number of hours to substract
|
||||
|
||||
Returns:
|
||||
New substracted datetime
|
||||
datetime (str): New substracted datetime
|
||||
"""
|
||||
|
||||
m=self.t.shift(hours=-num_hours)
|
||||
|
|
@ -660,7 +660,7 @@ class TimeClass:
|
|||
"""Method for get datetime formatted using format_date_full attribute
|
||||
|
||||
Returns:
|
||||
Datetime formatted with format_date_full attribute
|
||||
datetime (str): Datetime formatted with format_date_full attribute
|
||||
"""
|
||||
|
||||
return self.t.format(self.format_date_full)
|
||||
|
|
@ -669,7 +669,7 @@ class TimeClass:
|
|||
"""Method for get datetime formatted using format_time attribute
|
||||
|
||||
Returns:
|
||||
Datetime formatted with format_time attribute
|
||||
datetime (str): Datetime formatted with format_time attribute
|
||||
"""
|
||||
|
||||
return self.t.format(self.format_time)
|
||||
|
|
@ -699,7 +699,7 @@ class TimeClass:
|
|||
|
||||
Returns:
|
||||
|
||||
Actual datetime formatted in YYYYMMDDHHmmss format.
|
||||
datetime (str): Actual datetime formatted in YYYYMMDDHHmmss format.
|
||||
"""
|
||||
|
||||
if not utc:
|
||||
|
|
@ -719,7 +719,7 @@ class TimeClass:
|
|||
|
||||
Returns:
|
||||
|
||||
Actual datetime formatted in YYYYMMDD000000 format.
|
||||
datetime (str): Actual datetime formatted in YYYYMMDD000000 format.
|
||||
"""
|
||||
|
||||
if utc:
|
||||
|
|
@ -738,7 +738,7 @@ class TimeClass:
|
|||
|
||||
Returns:
|
||||
|
||||
Datetime in YYYYMMDDHHmmss format.
|
||||
datetime (str): Datetime in YYYYMMDDHHmmss format.
|
||||
"""
|
||||
|
||||
return arrow.get(timestamp).format(sql_format_time)
|
||||
|
|
@ -752,7 +752,7 @@ class TimeClass:
|
|||
|
||||
Returns:
|
||||
|
||||
Datetime in YYYYMMDDHHmmss format.If timeform is incorrect, return False
|
||||
datetime (str): Datetime in YYYYMMDDHHmmss format.If timeform is incorrect, return False
|
||||
"""
|
||||
|
||||
y, m, d, h, mi, s=format_timedata(timeform)
|
||||
|
|
@ -776,7 +776,7 @@ class TimeClass:
|
|||
|
||||
Returns:
|
||||
|
||||
Datetime in strtime format.If timeform is incorrect, return False
|
||||
datetime (str): Datetime in strtime format.If timeform is incorrect, return False
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class DoubleField(FloatField):
|
|||
return 'DOUBLE NOT NULL DEFAULT "0"'
|
||||
|
||||
class CharField(PhangoField):
|
||||
"""Simple alias for PhangoField for clarify that """
|
||||
"""Simple alias for PhangoField"""
|
||||
|
||||
pass
|
||||
|
||||
|
|
@ -238,12 +238,12 @@ class ForeignKeyField(IntegerField):
|
|||
"""
|
||||
Args:
|
||||
name (str): Name of field
|
||||
related_table(WebModel): The table-model related with this foreign key
|
||||
related_table (WebModel): The table-model 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
|
||||
select_fields (list): A series of fields names from related
|
||||
"""
|
||||
|
||||
super(ForeignKeyField, self).__init__(name, size, required)
|
||||
|
|
@ -292,7 +292,6 @@ class BooleanField(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.
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class SelectForm(BaseForm):
|
|||
def __init__(self, name, value, elements=OrderedDict()):
|
||||
"""
|
||||
Args:
|
||||
ame (str): The html name for this form
|
||||
name (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: <select name="name"><option value="0">Value selected</option></selected>
|
||||
"""
|
||||
|
|
@ -172,7 +172,6 @@ class SelectModelForm(SelectForm):
|
|||
Args:
|
||||
name (str): The html name for this form
|
||||
value (str): The default value of this html form.
|
||||
arr_select (OrderedDict): Used for save the data from the webmodel
|
||||
model (WebModel): The webmodel used for get the data for arr_select
|
||||
field_name (str): The field used for get the name of every option in select
|
||||
field_value (str): The field used for get the value of every option in select
|
||||
|
|
|
|||
|
|
@ -741,7 +741,8 @@ class WebModel:
|
|||
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
|
||||
|
||||
Returns:
|
||||
Return cursor db for get data using loops or other if operation is successful, if not, return False.
|
||||
false (bool): If return false, the db connection is down.
|
||||
sql_cursor (cursor): Return cursor db for get data using loops or other if operation is successful, if not, return False.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -865,7 +866,7 @@ class WebModel:
|
|||
cursor (Db cursor): A typical db cursor of python sql interface standard.
|
||||
|
||||
Returns:
|
||||
dict: Return a dictionary with the row selected.
|
||||
row (dict): Return a dictionary with the row selected.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -906,7 +907,7 @@ class WebModel:
|
|||
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
|
||||
|
||||
Returns:
|
||||
dict: Returns dict with the row values.
|
||||
row (dict): Returns dict with the row values.
|
||||
"""
|
||||
|
||||
self.conditions=['WHERE `'+self.name+'`.`'+self.name_field_id+'`=%s', [id]]
|
||||
|
|
@ -936,7 +937,7 @@ class WebModel:
|
|||
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
|
||||
|
||||
Returns:
|
||||
dict: Returns dict with the row values.
|
||||
row (dict): Returns dict with the row values.
|
||||
"""
|
||||
|
||||
self.limit="limit "+str(begin)+", 1"
|
||||
|
|
@ -963,7 +964,7 @@ class WebModel:
|
|||
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
|
||||
|
||||
Returns:
|
||||
dict: Returns dict with the row values.
|
||||
row_values (dict): Returns dict with the row values.
|
||||
"""
|
||||
|
||||
|
||||
|
|
@ -1013,7 +1014,7 @@ class WebModel:
|
|||
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
|
||||
|
||||
Returns:
|
||||
dict: Returns dict with the row values.
|
||||
row (dict): Returns dict with the row values.
|
||||
"""
|
||||
|
||||
if integer:
|
||||
|
|
@ -1064,12 +1065,11 @@ class WebModel:
|
|||
"""Method for get a typical sql count using conditions
|
||||
|
||||
Args:
|
||||
Args:
|
||||
fields_selected (dict): A list with the name of the fields how defined in PhangoField.
|
||||
field_to_count (str): The field
|
||||
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
|
||||
|
||||
Returns:
|
||||
int: Returns the number of elements selected.
|
||||
num_elecments (int): Returns the number of elements selected.
|
||||
"""
|
||||
|
||||
# Connect to db
|
||||
|
|
@ -1120,7 +1120,7 @@ class WebModel:
|
|||
"""Method for delete a series of rows using conditions
|
||||
|
||||
Returns:
|
||||
bool: If delete is successfully, return True, if not, return False.
|
||||
bool (bool): If delete is successfully, return True, if not, return False.
|
||||
"""
|
||||
|
||||
#self.connect_to_db()
|
||||
|
|
@ -1166,7 +1166,7 @@ class WebModel:
|
|||
in_list (list): List with numbers items.
|
||||
|
||||
Returns:
|
||||
string with (1,2,3) sql sentence filtered.
|
||||
sql_filtered (str): with (1,2,3) sql sentence filtered.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -1185,7 +1185,7 @@ class WebModel:
|
|||
in_list (list): List with value items.
|
||||
|
||||
Returns:
|
||||
string with (value1, value2, value3) sql sentence filtered.
|
||||
sql_filtered (str): (value1, value2, value3) sql sentence filtered.
|
||||
"""
|
||||
|
||||
for x in range(0, len(in_list)):
|
||||
|
|
@ -1359,7 +1359,7 @@ class WebModel:
|
|||
"""Method for drop a table based in this model
|
||||
|
||||
Returns:
|
||||
Return True if table was dropped successfully, false if table can't be dropped.
|
||||
sql_str (str): Return the sql query for drop the table represented by this model
|
||||
"""
|
||||
|
||||
return self.query('DROP TABLE '+self.name, [], self.connection_id)
|
||||
|
|
@ -1381,8 +1381,10 @@ class WebModel:
|
|||
errors_set (str): If insert value, the errors are set for insert sql statement, if update value, then the errors are set for update sql statement.
|
||||
|
||||
Returns:
|
||||
Return False if checking is wrong. If not False returns a tuple with fields filtered, original values as values and values filtered how update_values
|
||||
return (fields, values, update_values)
|
||||
wrong (bool): Return False if checking is wrong. If not False returns a tuple with fields filtered, original values as values and values filtered how update_values
|
||||
fields (list): list with fields
|
||||
values (dict): dict with values
|
||||
update_values (dict): dict with updated values with checking
|
||||
"""
|
||||
|
||||
fields=[]
|
||||
|
|
@ -1579,7 +1581,7 @@ class WebModel:
|
|||
"""Get all errors of model last operation.
|
||||
|
||||
Returns:
|
||||
str: A string with all errors.
|
||||
error_txt (str): A string with all errors.
|
||||
"""
|
||||
|
||||
arr_error=[]
|
||||
|
|
@ -1604,7 +1606,7 @@ class WebModel:
|
|||
"""Get all errors and save in dictionary
|
||||
|
||||
Returns:
|
||||
dict: Return a dict where the key is the field where the error exists and value is the error text.
|
||||
errors (dict): Return a dict where the key is the field where the error exists and value is the error text.
|
||||
"""
|
||||
|
||||
arr_error= {}
|
||||
|
|
@ -1666,7 +1668,7 @@ class WebModel:
|
|||
"""Prepare a dict with values using fields keys how base
|
||||
|
||||
Returns:
|
||||
dict: Return a dict with values without checking anything.
|
||||
post (dict): Return a dict with values without checking anything.
|
||||
"""
|
||||
|
||||
for k in self.fields.keys():
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def pass_values_to_form(post, arr_form, yes_error=True, pass_values=True):
|
|||
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.
|
||||
arr_form (dict): Return arr_form dict with checked values from post dict.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -76,7 +76,8 @@ class CheckForm():
|
|||
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.
|
||||
post (dict): Return post dict with values checked
|
||||
arr_form (dict): Return arr_form with errors and values.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -104,10 +105,10 @@ def check_form(post, arr_form, sufix_form='_error'):
|
|||
sufix_form (str): Define the sufix of error_form keys
|
||||
|
||||
Returns:
|
||||
bool: Return False if not errors in checking, if errors return True
|
||||
dict: A dict containing the errors in form fields.
|
||||
post: Sanitized values
|
||||
arr_form: arr_form with errors and values.
|
||||
error (bool): Return False if not errors in checking, if errors return True
|
||||
error_form (dict): A dict containing the errors in form fields.
|
||||
post (dict): Sanitized values
|
||||
arr_form (dict): arr_form with errors and values.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -143,7 +144,7 @@ def show_form(post, arr_form, t, yes_error=True, pass_values=True, modelform_tpl
|
|||
|
||||
Returns:
|
||||
|
||||
An html string with the generated form.
|
||||
template (str): An html string with the generated form.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -187,7 +188,7 @@ def csrf_token(token_id='csrf_token'):
|
|||
token_id (str): Name of the html hide form
|
||||
|
||||
Returns:
|
||||
Return html input hidden with csrf token saved in session
|
||||
html (str): Return html input hidden with csrf token saved in session
|
||||
"""
|
||||
|
||||
#s=get_session()
|
||||
|
|
@ -202,7 +203,7 @@ def generate_csrf():
|
|||
"""Function for generate a csrf token in a variable
|
||||
|
||||
Returns:
|
||||
csrf token value
|
||||
csrf_token (str): csrf token value
|
||||
"""
|
||||
|
||||
if not 'csrf_token' in session:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class GenerateAdminClass:
|
|||
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
|
||||
|
||||
Attributes:
|
||||
model (WebModel) The webmodel used for generate the admin model form
|
||||
model (WebModel): The webmodel used for generate the admin model form
|
||||
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
|
||||
list (SimpleList): A SimpleList class used for generate the listing
|
||||
arr_fields_edit (list): A list with the fields that the user can edit
|
||||
|
|
@ -83,7 +83,8 @@ class GenerateAdminClass:
|
|||
|
||||
Depending of op_admin arg, you have the different sections of a simple administrator
|
||||
|
||||
|
||||
Returns:
|
||||
html (str): The html content of the admin page, can be, items list, forms for create items, etc...
|
||||
"""
|
||||
|
||||
op_admin=request.args.get('op_admin', '0')
|
||||
|
|
@ -251,7 +252,7 @@ class GenerateConfigClass:
|
|||
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
|
||||
|
||||
Attributes:
|
||||
model (WebModel) The webmodel used for generatre the admin model form
|
||||
model (WebModel): The webmodel used for generatre the admin model form
|
||||
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
|
||||
url (str): Base url used by GenerateConfigClass for different sections of update configuration model
|
||||
url_redirect (str): The url where user is redirect when an operation is done
|
||||
|
|
|
|||
|
|
@ -1,13 +1,4 @@
|
|||
"""
|
||||
from settings import config
|
||||
|
||||
wsgi_gateway='flask'
|
||||
|
||||
if hasattr(config, 'wsgi_gateway'):
|
||||
wsgi_gateway=config.wsgi_gateway
|
||||
|
||||
if wsgi_gateway=='flask':
|
||||
"""
|
||||
from flask import request
|
||||
|
||||
def get_query_args(key, default_value=''):
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class SimpleList:
|
|||
"""Method for join options list returns with jln attributte separator
|
||||
|
||||
Returns:
|
||||
str: Return a string with joined options
|
||||
options (str): Return a string with joined options
|
||||
"""
|
||||
#SimpleList.standard_options(arr_row)
|
||||
return self.jln.join(options_func(self.url, arr_row[self.model.name_field_id], arr_row))
|
||||
|
|
@ -213,7 +213,7 @@ class SimpleList:
|
|||
"""Static method for get standar options for make things with the items row.
|
||||
|
||||
Returns:
|
||||
list: Return a list of basic options for items row
|
||||
options (list): Return a list of basic options for items row
|
||||
"""
|
||||
options=[]
|
||||
options.append('<a href="'+add_get_parameters(url, op_admin=1, id=id)+'">'+I18n.lang('common', 'edit', 'Edit')+'</a>')
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def env_theme(module, cache_enabled=True, cache_impl='', cache_args={}, module_d
|
|||
|
||||
Returns:
|
||||
|
||||
TemplateLookup: Return TemplateLookup object
|
||||
template (TemplateLookup): Return TemplateLookup object
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ class PTemplate:
|
|||
module (str): Optional. Where is saved the js file.
|
||||
|
||||
Returns:
|
||||
None: Dummy return necessary because mako expect return something
|
||||
dummy (str): Dummy return necessary because mako expect return something
|
||||
"""
|
||||
if not js in self.js:
|
||||
self.js[js]='<script language="Javascript" src="{}"></script>'.format(make_media_url('js/'+js, module))
|
||||
|
|
@ -140,7 +140,7 @@ class PTemplate:
|
|||
**arguments (mixed): Extra arguments with variables passed to template
|
||||
|
||||
Returns:
|
||||
Return a template rendered using mako class from self.env
|
||||
template (str): Return a template rendered using mako class from self.env
|
||||
"""
|
||||
|
||||
"""
|
||||
|
|
@ -182,11 +182,11 @@ class PTemplate:
|
|||
Experimental method for parse a template, similar to load_template but try cache the template loaded
|
||||
|
||||
Args:
|
||||
js (str): The name of js file. Normally you save the file in media/js folder in module or theme
|
||||
module (str): Optional. Where is saved the js file.
|
||||
template_file (str): The name of template file. The template is searched using configuration defined in self.env
|
||||
**arguments (mixed): Extra arguments with variables passed to template
|
||||
|
||||
Returns:
|
||||
None: Dummy return necessary because mako expect return something
|
||||
dummy (str): Dummy return necessary because mako expect return something
|
||||
"""
|
||||
|
||||
if not str(self.env.directories)+'/'+template_file in PTemplate.templates_loaded:
|
||||
|
|
|
|||
|
|
@ -6,22 +6,23 @@ login_name='login'
|
|||
login_url='.login'
|
||||
|
||||
def db(f):
|
||||
"""Wrapper function for add db connection to your flask function
|
||||
|
||||
Wrapper function for add db connection to your flask function. Also close the connection if error or function exection is finished.
|
||||
|
||||
Args:
|
||||
*args : The args of function
|
||||
**kwds : Standard python extra arguments of function
|
||||
|
||||
Returns:
|
||||
wrapper (function): Return the wrapper.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
|
||||
def wrapper(*args, **kwds):
|
||||
|
||||
"""Wrapper function for add db connection to your flask function
|
||||
|
||||
Wrapper function for add db connection to your flask function. Also close the connection if error or function exection is finished.
|
||||
|
||||
Args:
|
||||
*args (mixed): The args of function
|
||||
**kwds (mixed): Standard python extra arguments of function
|
||||
|
||||
Returns:
|
||||
wrapper (function): Return the wrapper.
|
||||
"""
|
||||
|
||||
g.connection=WebModel.connection()
|
||||
|
||||
try:
|
||||
|
|
@ -41,22 +42,24 @@ def db(f):
|
|||
return wrapper
|
||||
|
||||
def login_site(f):
|
||||
"""Wrapper function for check login in your flask function
|
||||
|
||||
Wrapper function for check a login session in your flask function. If
|
||||
|
||||
Args:
|
||||
*args : The args of function
|
||||
**kwds : Standard python extra arguments of function
|
||||
|
||||
Returns:
|
||||
wrapper (function): Return the wrapper.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
|
||||
def wrapper(*args, **kwds):
|
||||
|
||||
"""Wrapper function for check login in your flask function
|
||||
|
||||
Wrapper function for check a login session in your flask function. If
|
||||
|
||||
Args:
|
||||
*args : The args of function
|
||||
**kwds : Standard python extra arguments of function
|
||||
|
||||
Returns:
|
||||
wrapper (function): Return the wrapper.
|
||||
"""
|
||||
|
||||
|
||||
if not login_name in session:
|
||||
|
||||
return redirect(url_for(login_url))
|
||||
|
|
|
|||
|
|
@ -115,12 +115,12 @@ class SendMail:
|
|||
With this method you can send email to multiple address, html, and add attachments to email
|
||||
|
||||
Args:
|
||||
from_adress (str): The adress used for send the email
|
||||
from_address (str): The adress used for send the email
|
||||
to_address (list): A list of emails where the email will be sended.
|
||||
subject (str): The subject of the email
|
||||
message (str): The content of the message
|
||||
content_type (str): The type of mail content, can be plain or html.
|
||||
attatchments (list): A list with a serie of file paths for attach to the email.
|
||||
attachments (list): A list with a serie of file paths for attach to the email.
|
||||
"""
|
||||
|
||||
if self.smtp==None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue