Data

This module handles various external or otherwise miscellaneous data sources.

Models

class data.models.Extension(*args, **kwargs)[source]

Application registered to use the API

Parameters:
  • id (AutoField) – Id (required)
  • name (CharField) – Name (required)
  • developer (CharField) – Developer (required)
  • description (TextField) – Description (required)
  • icon (ImageField) – Icon
  • api_key (CharField) – Api key (required)
  • enabled (BooleanField) – Enabled (required)
  • registered (DateTimeField) – Registered (required)
  • last_modified (DateTimeField) – Last modified (required)
  • endpoints (ManyToManyField to Endpoint) – Endpoints (required)
  • users (ManyToManyField to User) – Users (required)
exception DoesNotExist
exception MultipleObjectsReturned
api_key

CharField(verbose_name=”API Key”, max_length=36)

description

TextField()

developer

CharField(max_length=64)

enabled

BooleanField()

endpoints

Reverse Manager for data.Extension’s endpoints

get_next_by_last_modified(*, field=<django.db.models.fields.DateTimeField: last_modified>, is_next=True, **kwargs)
get_next_by_registered(*, field=<django.db.models.fields.DateTimeField: registered>, is_next=True, **kwargs)
get_previous_by_last_modified(*, field=<django.db.models.fields.DateTimeField: last_modified>, is_next=False, **kwargs)
get_previous_by_registered(*, field=<django.db.models.fields.DateTimeField: registered>, is_next=False, **kwargs)
icon

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

last_modified

DateTimeField(auto_now=True)

name

CharField(max_length=120)

objects = <django.db.models.manager.Manager object>
registered

DateTimeField(auto_now_add=True)

users

Reverse Manager for data.Extension’s users

class data.models.GlobalPerms(id)[source]
Parameters:id (AutoField) – Id (required)
exception DoesNotExist
exception MultipleObjectsReturned
id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

objects = <django.db.models.manager.Manager object>
class data.models.Notification(*args, **kwargs)[source]

Passive site notifications - accessible through the API

Parameters:
  • id (AutoField) – Id (required)
  • title (CharField) – Title (required)
  • message (TextField) – Message (required)
  • format (CharField) – Format (required)
  • type (CharField) – Type (required)
  • dismissible (BooleanField) – Dismissible (default=False)
  • target (CharField) – To target a specific page, include the full pathname (i.e. ‘/services/lighting.html’ or ‘/events/’). To target a directory, include only the directory name (i.e. ‘events’). For a sitewide notification, enter ‘All’. (required)
  • expires (DateTimeField) – Expires (required)
exception DoesNotExist
exception MultipleObjectsReturned
dismissible

BooleanField(default=False)

expires

DateTimeField()

format

CharField(max_length=12, choices=[(‘alert’, ‘Alert’), (‘notification’, ‘Notification’)])

get_format_display(*, field=<django.db.models.fields.CharField: format>)
get_next_by_expires(*, field=<django.db.models.fields.DateTimeField: expires>, is_next=True, **kwargs)
get_previous_by_expires(*, field=<django.db.models.fields.DateTimeField: expires>, is_next=False, **kwargs)
get_type_display(*, field=<django.db.models.fields.CharField: type>)
id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

message

TextField(max_length=500)

objects = <django.db.models.manager.Manager object>
target

CharField(max_length=200, help_text=”To target a specific page, include the full pathname (i.e. ‘/services/lighting.html’ or ‘/events/’). To target a directory, include only the directory name (i.e. ‘events’). For a sitewide notification, enter ‘All’.”)

Target: To target a specific page, include the full pathname (i.e. ‘/services/lighting.html’ or ‘/events/’). To target a directory, include only the directory name (i.e. ‘events’). For a sitewide notification, enter ‘All’.

title

CharField(max_length=128)

type

CharField(max_length=8, choices=[(‘info’, ‘Info’), (‘advisory’, ‘Advisory’), (‘warning’, ‘Warning’)])

class data.models.ResizedRedirect(*args, **kwargs)[source]

Custom redirect (configured from the admin site)

Parameters:
  • id (AutoField) – Id (required)
  • name (CharField) – User friendly name
  • site (ForeignKey to Site) – Site (required)
  • old_path (CharField) – This should be an absolute path, excluding the domain name. Example: ‘/events/search/’. (required)
  • new_path (CharField) – This can be either an absolute path (as above) or a full URL starting with ‘http://’. (required)
  • sitemap (BooleanField) – Include in sitemap (default=False)
exception DoesNotExist
exception MultipleObjectsReturned
clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

name

CharField(max_length=64, blank=True, null=True, help_text=”User friendly name”)

Name: User friendly name

new_path

CharField(verbose_name=redirect to, max_length=200, blank=True, help_text=This can be either an absolute path (as above) or a full URL starting with ‘http://’.)

Redirect to: This can be either an absolute path (as above) or a full URL starting with ‘http://’.

objects = <django.db.models.manager.Manager object>
old_path

CharField(verbose_name=redirect from, max_length=190, db_index=True, help_text=This should be an absolute path, excluding the domain name. Example: ‘/events/search/’.)

Redirect from: This should be an absolute path, excluding the domain name. Example: ‘/events/search/’.

site

ForeignKey(verbose_name=site, on_delete=CASCADE(), to= Site)

site_id

Raw (integer) FK for site

sitemap

BooleanField(verbose_name=”Include in Sitemap”, default=False)

class data.models.StupidCat(*args, **kwargs)[source]

For logging when a user goes somewhere they shouldn’t be going

Parameters:
  • id (AutoField) – Id (required)
  • user (ForeignKey to User) – User
  • user_ip (GenericIPAddressField) – User ip (required)
  • requested_uri (CharField) – Requested uri (required)
  • timestamp (DateTimeField) – Timestamp (required)
exception DoesNotExist
exception MultipleObjectsReturned
get_next_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=True, **kwargs)
get_previous_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=False, **kwargs)
id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

objects = <django.db.models.manager.Manager object>
requested_uri

CharField(max_length=512)

timestamp

DateTimeField(auto_now_add=True)

user

ForeignKey(blank=True, null=True, on_delete=CASCADE(), to= User)

user_id

Raw (integer) FK for user

user_ip

GenericIPAddressField()


Views

data.views.contact_tracing_logs(request)[source]

Download csv file containing contact tracing logs

data.views.err403(request, *args, **kwargs)[source]
data.views.err404(request, *args, **kwargs)[source]
data.views.err500(request, *args, **kwargs)[source]
data.views.maintenance(request)[source]

Display maintenance page

data.views.search(request)[source]

New search tool using Watson

data.views.serve_file(request, att_file, forced_name=None)[source]
data.views.workorderwizard_findprevious(request)[source]

Checks for previous events submitted by a user in the last 18 months

Returns:A previous event; 402 status code if nothing is found; 422 status code if processing fails; 401 status code if unauthenticated
data.views.workorderwizard_load(request)[source]

Endpoint the workorder wizard uses to load initial data.

Returns:Dictionary of event locations, organizations, and user details; 401 status code if not authenticated
data.views.workorderwizard_submit(request)[source]

Handles submission of workorder from workorder wizard.

Returns:URL to event page on success; 422 status code if processing fails; 401 status code if unauthenticated

Forms

class data.forms.DynamicFieldContainer(*fields)[source]
render(form, form_style, context, template_pack=<SimpleLazyObject: 'bootstrap3'>)[source]
class data.forms.FieldAccessForm(request_user, *args, **kwargs)[source]

This class will grant or deny access to individual fields according to simple rules.

Example:

class MyForm(FieldAccessForm):
class FieldAccess:
staff = FieldAccessLevel(lambda u, i: u.is_staff,
enable = (‘field1’, ‘field2’), exclude = (‘field3’,))
base_fields = {}
declared_fields = {}
media
class data.forms.FieldAccessLevel(rule, enable=None, exclude=None)[source]

Represents an access level for a form.


Decorators

data.decorators.process_in_thread(method)[source]

Use this decorator to indicate that a method should be processed on a separate thread.

WARNING: Refrain from interacting with the database while using this decorator (i.e. no read / write). If you do access the database, be sure to call connection.close() (from django.db import connection) at the end of the method.