utils.templatetags package#
Submodules#
utils.templatetags.cobalt_simple_tables_tags module#
utils.templatetags.cobalt_tags module#
- utils.templatetags.cobalt_tags.cobalt_bs4_field(field, no_label=False)[source]#
Format a field for a standard Bootstrap 4 form element.
Returns a form-group div with the field rendered inside Will include a label if the type of field suits it.
This is a general tag to be used for any field. It tries to work out how to format the HTML based upon the type of field.
use it per field so you can format the elements individually.
e.g.
<div class=”col-6”>{% cobalt_bs4_field form.field1 %}</div> <div class=”col-6”>{% cobalt_bs4_field form.field2 %}</div>
- utils.templatetags.cobalt_tags.cobalt_credits(credits_amt)[source]#
Return formatted bridge credit number
- utils.templatetags.cobalt_tags.cobalt_currency(dollars)[source]#
Return number formatted as currency
- utils.templatetags.cobalt_tags.cobalt_currency_colour(dollars)[source]#
Return number formatted as currency with bootstrap colours
- utils.templatetags.cobalt_tags.cobalt_date_dashboard(value)[source]#
custom filter for date to format as full date - used by dashboard to match event date format
- utils.templatetags.cobalt_tags.cobalt_date_field_value(field)[source]#
Filter to display the non-editable vlaue of a date field Value may be a str or date or datetime
- utils.templatetags.cobalt_tags.cobalt_dev_list(item)[source]#
Lists all of the attributes of a variable
- utils.templatetags.cobalt_tags.cobalt_dict_int_key(my_dict, my_keyname)[source]#
Return the doctionary value for a int key
Use this for {{ }}
- utils.templatetags.cobalt_tags.cobalt_dict_key(my_dict, my_keyname)[source]#
Return value from key for an array in a template. Django doesn’t do this out of the box
Use this for {{ }} and cobalt_dict_key_tag within {% %}
- utils.templatetags.cobalt_tags.cobalt_dict_key_tag(my_dict, my_keyname)[source]#
Return dictionary value
Use this for {% %} and cobalt_dict_key within {{ }}
- utils.templatetags.cobalt_tags.cobalt_hide_email(email)[source]#
Custom filter for email address which hides the address. Used by admin email viewer.
- utils.templatetags.cobalt_tags.cobalt_nice_date(value)[source]#
custom filter for date to format as full date
- utils.templatetags.cobalt_tags.cobalt_nice_date_short(value)[source]#
custom filter for date to format as full date
- utils.templatetags.cobalt_tags.cobalt_nice_datetime(value)[source]#
Custom filter for datetime to format as date and time
- utils.templatetags.cobalt_tags.cobalt_nice_datetime_short(value)[source]#
Custom filter for datetime to format as short date and time
- utils.templatetags.cobalt_tags.cobalt_number(dollars)[source]#
Return number formatted with commas and 2 decimals
- utils.templatetags.cobalt_tags.cobalt_number_short(dollars)[source]#
Return number formatted with commas but only shows decimal places if needed. 1.23 -> 1.23, 34.00 -> 34
- utils.templatetags.cobalt_tags.cobalt_random_colour()[source]#
Return random bootstrap colour - useful for card headers from lists.
- utils.templatetags.cobalt_tags.cobalt_suit_replace(string)[source]#
Converts H,S,D,C to suit symbol and colour
- utils.templatetags.cobalt_tags.cobalt_time(value)[source]#
Custom filter for datetime so we can get “am” amd “pm” instead of “a.m.” and “p.m.” Accepted datetime object or time object Returns e.g. 10am, 7:15pm 10:01am
- utils.templatetags.cobalt_tags.cobalt_trick_count(tricks)[source]#
Return empty string if tricks < 7 or tricks minus 6.
- utils.templatetags.cobalt_tags.cobalt_user_link(user)[source]#
Custom filter for user which includes link to public profile. Could possibly be extended to add a hover
- utils.templatetags.cobalt_tags.cobalt_user_link_short(user)[source]#
Custom filter for user which includes link to public profile. Short version - name only, no system number.
- utils.templatetags.cobalt_tags.render_cobalt_datepicker(field, add_classes=None, form_no=None)[source]#
Template tag to render a datepicker for a form field. If the form is part of a formset the form number must be provided (0 relative) otherwise teh name will not be set correctly.
- Usage:
{% render_cobalt_date_picker form.<field> %}
- Parameters:
field (Field) – the form field
add_class (str) – str of classes to add to the definition
form_no (int) – the sequence number of the form in a formset (or None)
- Returns
str: HTML for an input element named for the field, with datepicker class.