Added documentation to functions in adminutils.py

This commit is contained in:
Antonio de la Rosa 2017-02-19 17:16:14 +01:00
parent 79958914fd
commit 126b323556

View file

@ -21,13 +21,40 @@ except:
class config_admin:
modules_admin=[]
#Function for get an admin url
def make_admin_url(url, query_args={}):
"""Function for get an admin url
A special function based in make_url for get admin urls. You can use only the module admin part in the url and get a real url for use in your templates or other functions.
Args:
url (str): The url without admin part for use how base. Example: with 'pages' as url value you get http://localhost:8080/admin/pages
query_args (dict): A serie of dictionary values where you get a url query result as it: {'key1': 'value1', 'key2': 'value2'} -> key1=value1&key2=value2
Returns:
str: A new url valid for use in href links directing to admin site
"""
return make_url('%s/%s' % (config.admin_folder, url), query_args)
def get_language(s):
"""Function for get language from a session
With this function you gan get easily the language of session
Args:
s (session): A session object where the language value is stored
Returns:
str: The language string
"""
s['lang']=s.get('lang', None)
lang_selected=None
@ -43,6 +70,18 @@ def get_language(s):
def get_menu(modules_admin):
"""Function for get a ordered dict with modules admin
With this method you get a menu ordered dict for use internally in admin module.
Args:
modules_admin (OrderedDict): The ordereddict used get it from admin configuration of Paramecio system
Returns:
OrderedDict: A new dict prepared for use in admin module.
"""
menu=OrderedDict()
for mod in modules_admin:
@ -61,6 +100,11 @@ def get_menu(modules_admin):
def check_login():
"""Function for check if correct login in admin module
With this function you can check if the online user is login or not
"""
s=get_session()
if 'login' in s: