utils.views package#

Submodules#

utils.views.cobalt_batch module#

class utils.views.cobalt_batch.CobaltBatch(name, schedule, instance=None, rerun=False)[source]#

Bases: object

Class to handle batch jobs within Cobalt. We use cron (or whatever you like) to trigger the jobs which are set up using django-extensions.

Parameters:
  • name (str)

  • schedule (str)

  • instance (str)

  • rerun (bool)

Returns:

CobaltBatch

finished(status='Success')[source]#
start()[source]#
utils.views.cobalt_batch.batch(request)[source]#

utils.views.cobalt_lock module#

class utils.views.cobalt_lock.CobaltLock(topic: str, expiry: int = 15)[source]#

Bases: object

handle running one thing at a time in a multi-node environment

delete_lock()[source]#

Delete the lock record, returning success. Will only delete an expired or freed lock. COB_965

free_lock()[source]#

Release lock

get_lock()[source]#

Try to get a lock, returns True or False

utils.views.general module#

utils.views.general.download_csv(self, request, queryset)[source]#

Copied from Stack Overflow - generic CSV download

utils.views.general.geo_location(request, location)[source]#

return lat and long for a text address

utils.views.general.masterpoint_query(query)[source]#

Generic function to talk to the masterpoints server and return data

Takes in a SQLServer query e.g. “select count(*) from table”

Returns an iterable, either an empty list or the response from the server.

In case there is a problem connecting to the server, this will do everything it can to fail silently.

utils.views.general.timeout(request)[source]#

simulate a timeout for testing purposes

utils.views.monitoring module#

utils.views.monitoring.admin_show_aws_app_version_htmx(request)[source]#

Show the Elastic Beanstalk App details for a version

utils.views.monitoring.admin_show_aws_infrastructure_info(request)[source]#

Show some AWS info to check on health of system

utils.views.monitoring.admin_show_database_details_htmx(request)[source]#

Show the database info for an environment

utils.views.monitoring.admin_system_activity(request)[source]#

Show basic info about user activity

utils.views.monitoring.admin_system_activity_cobalt_messages_htmx(request)[source]#

Provide latest data from the cobalt messages log

utils.views.monitoring.admin_system_activity_nginx_htmx(request)[source]#

Provide latest data from the nginx access.log

utils.views.monitoring.admin_system_activity_users_htmx(request)[source]#

Provide latest data from user activity

utils.views.monitoring.database_view(request)[source]#

Show basic stats about the database

utils.views.monitoring.get_aws_environment_status_htmx(request)[source]#

Shows the status of the environment. Called by admin_system_settings after we make a change. Quite specific to the function it serves.

utils.views.monitoring.recent_errors(request)[source]#

Show recent errors from error log messages

utils.views.monitoring.system_statistics(request)[source]#

Basic statistics

utils.views.monitoring.system_status(request)[source]#

Basic system health

utils.views.monitoring.user_activity(request)[source]#

show user activity figures

utils.views.slugs module#

utils.views.slugs.check_slug_is_free(slug)[source]#

Check if a slug is in use or not

utils.views.slugs.create_new_slug(slug, redirect_path, owner)[source]#

create a slug if it doesn’t already exist

utils.views.slugs.validate_cobalt_slug(slug_text, redirect_path)[source]#

validate the slug text and the path.

Returns:

boolean message: str

Return type:

valid

Module contents#