utils package#
Subpackages#
- utils.cgit package
- utils.management package
- utils.templatetags package
- Submodules
- utils.templatetags.cobalt_simple_tables_tags module
- utils.templatetags.cobalt_tags module
cobalt_add_days()
cobalt_bs4_field()
cobalt_credits()
cobalt_currency()
cobalt_currency_colour()
cobalt_date_dashboard()
cobalt_date_field_value()
cobalt_dev_list()
cobalt_dict_int_key()
cobalt_dict_key()
cobalt_dict_key_tag()
cobalt_hide_email()
cobalt_nice_date()
cobalt_nice_date_short()
cobalt_nice_datetime()
cobalt_nice_datetime_short()
cobalt_number()
cobalt_number_short()
cobalt_random_colour()
cobalt_suit_replace()
cobalt_time()
cobalt_trick_count()
cobalt_user_link()
cobalt_user_link_short()
get_class()
render_cobalt_datepicker()
- Module contents
- utils.views package
- Submodules
- utils.views.cobalt_batch module
- utils.views.cobalt_lock module
- utils.views.general module
- utils.views.monitoring module
admin_show_aws_app_version_htmx()
admin_show_aws_infrastructure_info()
admin_show_database_details_htmx()
admin_system_activity()
admin_system_activity_cobalt_messages_htmx()
admin_system_activity_nginx_htmx()
admin_system_activity_users_htmx()
database_view()
get_aws_environment_status_htmx()
recent_errors()
system_statistics()
system_status()
user_activity()
- utils.views.slugs module
- Module contents
Submodules#
utils.admin module#
Generated by utils/cgit/cgit_util_generate_admin_file on 2022-01-24 14:40:23.466006
utils.apps module#
utils.can_login_as module#
utils.forms module#
- class utils.forms.SystemSettingsForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)[source]#
Bases:
Form
system settings from AWS
- base_fields = {'debug_flag': <django.forms.fields.BooleanField object>, 'disable_playpen': <django.forms.fields.BooleanField object>, 'maintenance_mode': <django.forms.fields.BooleanField object>}#
- declared_fields = {'debug_flag': <django.forms.fields.BooleanField object>, 'disable_playpen': <django.forms.fields.BooleanField object>, 'maintenance_mode': <django.forms.fields.BooleanField object>}#
- property media#
Return all media required to render the widgets on this form.
utils.middleware module#
utils.models module#
Utilities.
This handles the models for general things such as batch processing.
- class utils.models.Batch(*args, **kwargs)[source]#
Bases:
Model
Batch job status
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- end_time#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_job_status_display(*, field=<django.db.models.fields.CharField: job_status>)#
- get_next_by_run_date(*, field=<django.db.models.fields.DateTimeField: run_date>, is_next=True, **kwargs)#
- get_next_by_start_time(*, field=<django.db.models.fields.DateTimeField: start_time>, is_next=True, **kwargs)#
- get_previous_by_run_date(*, field=<django.db.models.fields.DateTimeField: run_date>, is_next=False, **kwargs)#
- get_previous_by_start_time(*, field=<django.db.models.fields.DateTimeField: start_time>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- instance#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- job_status#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- node#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- run_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_time#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class utils.models.Lock(*args, **kwargs)[source]#
Bases:
Model
Equivalent of a lock file for a distributed environment
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- get_next_by_lock_created_time(*, field=<django.db.models.fields.DateTimeField: lock_created_time>, is_next=True, **kwargs)#
- get_previous_by_lock_created_time(*, field=<django.db.models.fields.DateTimeField: lock_created_time>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lock_created_time#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lock_open_time#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- owner#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- topic#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class utils.models.Seat(*values)[source]#
Bases:
TextChoices
- EAST = 'E'#
- NORTH = 'N'#
- SOUTH = 'S'#
- WEST = 'W'#
- class utils.models.Slug(*args, **kwargs)[source]#
Bases:
Model
This maps short names to redirects. e.g. localhost/my-nice-slug -> localhost/events/5
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- owner#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- owner_id#
- redirect_path#
redirect path should not have a leading /
- slug#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
utils.storage module#
- class utils.storage.ForgivingManifestStaticFilesStorage(*args, **kwargs)[source]#
Bases:
ManifestStaticFilesStorage
If we update static files such as .js or .css files then user’s browsers will still cache the old version causing problems. We could disable caching but that would make the system much slower. Instead we use ManifestStaticFilesStorage which sticks an MD5 hash on the end of the filename making it unique.
We need to do three things though to make it work properly. First we need to ignore errors if it can’t find an entry in its staticfiles.json. We do this with manifest_strict = False See https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict
Secondly we sub-class it here so we can ignore missing file references.
Thirdly, we need to use relative paths so {% static “/ddd” %} won’t work. It needs to be {% static “ddd” %}
- manifest_strict = False#
utils.urls module#
utils.utils module#
- utils.utils.cobalt_paginator(request: HttpRequest, events_list: list, items_per_page: int = 30, page_no: int = None) page [source]#
common pagination function
- Parameters:
page_no (int) – optional page number to override what is in Request
request (HTTPRequest) – standard request object
events_list (list) – list of things to paginate
items_per_page (int) – number of items on a page
Returns: list