swh.web.utils.swh_templatetags module#
- swh.web.utils.swh_templatetags.docstring_display(docstring)[source]#
Utility function to htmlize reST-formatted documentation in browsable api.
- swh.web.utils.swh_templatetags.urlize_links_and_mails(text)[source]#
Utility function for decorating api links in browsable api.
- Parameters:
text – whose content matching links should be transformed into
links. (contextual API or Browse html)
- Returns
The text transformed if any link is found. The text as is otherwise.
- swh.web.utils.swh_templatetags.urlize_header_links(text)[source]#
Utility function for decorating headers links in browsable api.
- Args
text: Text whose content contains Link header value
- Returns:
The text transformed with html link if any link is found. The text as is otherwise.
- swh.web.utils.swh_templatetags.jsonify(obj)[source]#
Utility function for converting a django template variable to JSON in order to use it in script tags.
- Args
obj: Any django template context variable
- Returns:
JSON representation of the variable.
- swh.web.utils.swh_templatetags.sub(value, arg)[source]#
Django template filter for subtracting two numbers
- Parameters:
value (int/float) – the value to subtract from
arg (int/float) – the value to subtract to
- Returns:
The subtraction result
- Return type:
int/float
- swh.web.utils.swh_templatetags.mul(value, arg)[source]#
Django template filter for multiplying two numbers
- Parameters:
value (int/float) – the value to multiply from
arg (int/float) – the value to multiply with
- Returns:
The multiplication result
- Return type:
int/float
- swh.web.utils.swh_templatetags.key_value(dict, key)[source]#
Django template filter to get a value in a dictionary.
- swh.web.utils.swh_templatetags.visit_type_savable(visit_type: str) → bool[source]#
Django template filter to check if a save request can be created for a given visit type.
- Args:
visit_type: the type of visit
- Returns:
If the visit type is saveable or not