functions
utilities.functions
¤
Attributes¤
menu_item_divider_html = '<div class="dropdown-divider"></div>'
module-attribute
¤
menu_item_html = '<a class="dropdown-item" href="{url}">{name}</a>'
module-attribute
¤
menu_tab_html = '\n<li class="nav-item dropdown">\n <a class="nav-link dropdown-toggle" href="#" id="navbarInfoRed" role="button"\n data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n {tab}\n </a>\n <div class="dropdown-menu" aria-labelledby="navbarDropdown">\n {items}\n </div>\n</li>\n'
module-attribute
¤
Classes¤
objdict
¤
Bases: dict
Dictionary whose content can be manipulated as attributes.
NOTE: Might be a better option to do this. Needs deeper analysis. NOTE: To be moved to a separates 'utilities' module.
Functions¤
dictfetchall(cursor)
¤
Return all rows from a cursor as a list of dict.
TODO: This is used to process low level SQL requests, so chances are it will not be needed once we are done with this. NOTE: To be moved to a separates 'utilities' module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cursor
|
?
|
? |
required |
Returns:
Type | Description |
---|---|
list[dict]
|
List[Dict]: ? |
Source code in utilities/functions.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
get_menu(user)
¤
Generate the user menu in HTML, depending on its permissions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user
|
User
|
The user to generate the menu for. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
An HTML string with the menu items. |
Source code in utilities/functions.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
menu_struct(filename=None)
cached
¤
Returns the menu structure.
As the function is cached, it will be called only once when the webapp is launched.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
Name of the file to load |
None
|
Returns:
Type | Description |
---|---|
list[Tab]
|
List[Tab]: A list of tabs to include. |
Source code in utilities/frontend_menu/constants.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
modelo_a_tabla_html(modelo, col_extra)
¤
Extracts the entries in a query as an HTML table.
NOTE: To be moved to a separates 'utilities' module. NOTE: There's no need to do this manually, we should use django-tables2 for this: https://django-tables2.readthedocs.io/en/latest/
Parameters:
Name | Type | Description | Default |
---|---|---|---|
modelo
|
QuerySet
|
Objects to extract as HTML |
required |
col_extra
|
bool
|
If an extra column need to be included at the end. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Table in HTML with the contents of a model |
Source code in utilities/functions.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|