Inventory

This module provides tools to help users view and manage LNL’s equipment inventory.

Models

class inventory.models.AccessRecord(*args, **kwargs)[source]

Contact tracing log for LNL storage spaces

Parameters:
  • id (AutoField) – Id (required)
  • location (ForeignKey to Location) – Location (required)
  • timestamp (DateTimeField) – Timestamp (default=<function now at 0x7f6463fb18c0>)
  • reason (CharField) – Reason (required)
  • users (ManyToManyField to User) – Users (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)

location

ForeignKey(related_name=”access_logs”, on_delete=CASCADE(), to= Location)

location_id

Raw (integer) FK for location

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

CharField(max_length=120)

timestamp

DateTimeField(default=now())

users

Reverse Manager for inventory.AccessRecord’s users

class inventory.models.EquipmentCategory(id, name, usual_place, parent)[source]
Parameters:
  • id (AutoField) – Id (required)
  • name (CharField) – Name (required)
  • usual_place (ForeignKey to Location) – Default place for items of this category. Inherits from parent categories.
  • parent (TreeForeignKey to EquipmentCategory) – If this is a subcategory, the parent is what this is a subcategory of. Choose ‘—’ if not.
  • lft (PositiveIntegerField) – Lft (required)
  • rght (PositiveIntegerField) – Rght (required)
  • tree_id (PositiveIntegerField) – Tree id (required)
  • level (PositiveIntegerField) – Level (required)
exception DoesNotExist
exception MultipleObjectsReturned
breadcrumbs
children

Reverse Manager for inventory.EquipmentCategory’s parent

default_location
equipmentclass_set

Reverse Manager for inventory.EquipmentClass’s category

get_ancestors_inclusive
get_descendants_inclusive
id

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

level

PositiveIntegerField(editable=False)

lft

PositiveIntegerField(editable=False)

name

CharField(max_length=64)

parent

TreeForeignKey(blank=True, null=True, help_text=”If this is a subcategory, the parent is what this is a subcategory of. Choose ‘—’ if not.”, related_name=”children”, on_delete=CASCADE(), to= EquipmentCategory)

Parent: If this is a subcategory, the parent is what this is a subcategory of. Choose ‘—’ if not.

parent_id

Raw (integer) FK for parent

classmethod possible_locations()[source]
rght

PositiveIntegerField(editable=False)

tree_id

PositiveIntegerField(db_index=True, editable=False)

usual_place

ForeignKey(blank=True, null=True, help_text=”Default place for items of this category. Inherits from parent categories.”, on_delete=PROTECT(), to= Location)

Usual place: Default place for items of this category. Inherits from parent categories.

usual_place_id

Raw (integer) FK for usual_place

class inventory.models.EquipmentClass(id, name, category, description, value, model_number, manufacturer, url, holds_items, length, width, height, weight, wiki_text)[source]
Parameters:
  • id (AutoField) – Id (required)
  • name (CharField) – Name (required)
  • category (TreeForeignKey to EquipmentCategory) – Category (required)
  • description (TextField) – Function, appearance, and included acessories
  • value (DecimalField) – Estimated purchase value
  • model_number (CharField) – Model number
  • manufacturer (CharField) – Manufacturer
  • url (URLField) – Url
  • holds_items (BooleanField) – Can hold other items (default=False)
  • length (DecimalField) – Length in inches
  • width (DecimalField) – Width in inches
  • height (DecimalField) – Height in inches
  • weight (DecimalField) – Weight in lbs.
  • wiki_text (TextField) – How to use this item
exception DoesNotExist
exception MultipleObjectsReturned
breadcrumbs
category

TreeForeignKey(on_delete=CASCADE(), to= EquipmentCategory)

category_id

Raw (integer) FK for category

description

TextField(blank=True, null=True, help_text=”Function, appearance, and included acessories”)

Description: Function, appearance, and included acessories

height

DecimalField(blank=True, null=True, help_text=”Height in inches”, max_digits=6, decimal_places=2)

Height: Height in inches

holds_items

BooleanField(default=False, help_text=”Can hold other items”)

Holds items: Can hold other items

id

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

items

Reverse Manager for inventory.EquipmentItem’s item_type

length

DecimalField(blank=True, null=True, help_text=”Length in inches”, max_digits=6, decimal_places=2)

Length: Length in inches

manufacturer

CharField(max_length=128, blank=True, null=True)

model_number

CharField(max_length=190, blank=True, null=True)

name

CharField(max_length=190)

objects = <django.db.models.manager.Manager object>
size()[source]
url

CharField(blank=True, null=True)

value

DecimalField(blank=True, null=True, help_text=”Estimated purchase value”, max_digits=9, decimal_places=2)

Value: Estimated purchase value

weight

DecimalField(blank=True, null=True, help_text=”Weight in lbs.”, max_digits=6, decimal_places=2)

Weight: Weight in lbs.

width

DecimalField(blank=True, null=True, help_text=”Width in inches”, max_digits=6, decimal_places=2)

Width: Width in inches

wiki_text

TextField(blank=True, null=True, help_text=”How to use this item”)

Wiki text: How to use this item

class inventory.models.EquipmentItem(id, item_type, serial_number, case, barcode, purchase_date, home, features)[source]
Parameters:
  • id (AutoField) – Id (required)
  • item_type (ForeignKey to EquipmentClass) – Item type (required)
  • serial_number (CharField) – Serial number
  • case (TreeForeignKey to EquipmentItem) – Case or item that contains this item
  • barcode (BigIntegerField) – Barcode
  • purchase_date (DateField) – Purchase date (required)
  • home (ForeignKey to Location) – Place where this item typically resides.
  • features (CharField) – Identifying features
  • lft (PositiveIntegerField) – Lft (required)
  • rght (PositiveIntegerField) – Rght (required)
  • tree_id (PositiveIntegerField) – Tree id (required)
  • level (PositiveIntegerField) – Level (required)
exception DoesNotExist
exception MultipleObjectsReturned
barcode

BigIntegerField(unique=True, blank=True, null=True)

breadcrumbs
case

TreeForeignKey(blank=True, null=True, help_text=”Case or item that contains this item”, related_name=”contents”, on_delete=CASCADE(), to= EquipmentItem)

Case: Case or item that contains this item

case_id

Raw (integer) FK for case

contents

Reverse Manager for inventory.EquipmentItem’s case

features

CharField(verbose_name=”Identifying Features”, max_length=128, blank=True, null=True)

get_next_by_purchase_date(*, field=<django.db.models.fields.DateField: purchase_date>, is_next=True, **kwargs)
get_previous_by_purchase_date(*, field=<django.db.models.fields.DateField: purchase_date>, is_next=False, **kwargs)
home

ForeignKey(blank=True, null=True, help_text=”Place where this item typically resides.”, on_delete=PROTECT(), to= Location)

Home: Place where this item typically resides.

home_id

Raw (integer) FK for home

id

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

item_type

ForeignKey(related_name=”items”, on_delete=CASCADE(), to= EquipmentClass)

item_type_id

Raw (integer) FK for item_type

level

PositiveIntegerField(editable=False)

lft

PositiveIntegerField(editable=False)

location
maintenance

Reverse Manager for inventory.EquipmentMaintEntry’s equipment

objects = <inventory.models.EquipmentItemManager object>
purchase_date

DateField(blank=True)

rght

PositiveIntegerField(editable=False)

save(*args, **kwargs)[source]

If this is a new node, sets tree fields up before it is inserted into the database, making room in the tree structure as neccessary, defaulting to making the new node the last child of its parent.

It the node’s left and right edge indicators already been set, we take this as indication that the node has already been set up for insertion, so its tree fields are left untouched.

If this is an existing node and its parent has been changed, performs reparenting in the tree structure, defaulting to making the node the last child of its new parent.

In either case, if the node’s class has its order_insertion_by tree option set, the node will be inserted or moved to the appropriate position to maintain ordering by the specified field.

serial_number

CharField(max_length=190, blank=True, null=True)

status
tree_id

PositiveIntegerField(db_index=True, editable=False)

unsafe_to_delete
class inventory.models.EquipmentItemManager[source]
bulk_add_helper(item_type, num_to_add, put_into=None)[source]
class inventory.models.EquipmentMaintEntry(id, date, user, title, entry, equipment, status)[source]
Parameters:
  • id (AutoField) – Id (required)
  • date (DateTimeField) – Date (required)
  • user (ForeignKey to User) – User (required)
  • title (CharField) – Title (required)
  • entry (TextField) – Entry
  • equipment (ForeignKey to EquipmentItem) – Equipment (required)
  • status (ForeignKey to EquipmentStatus) – Status (required)
exception DoesNotExist
exception MultipleObjectsReturned
date

DateTimeField(auto_now_add=True)

entry

TextField(blank=True, null=True)

equipment

ForeignKey(related_name=”maintenance”, on_delete=CASCADE(), to= EquipmentItem)

equipment_id

Raw (integer) FK for equipment

get_next_by_date(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)
get_previous_by_date(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)
id

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

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

ForeignKey(on_delete=PROTECT(), to= EquipmentStatus)

status_id

Raw (integer) FK for status

title

CharField(max_length=32)

user

ForeignKey(on_delete=PROTECT(), to= User)

user_id

Raw (integer) FK for user

class inventory.models.EquipmentStatus(id, name, glyphicon)[source]
Parameters:
  • id (AutoField) – Id (required)
  • name (CharField) – Name (required)
  • glyphicon (CharField) – Glyphicon (required)
exception DoesNotExist
exception MultipleObjectsReturned
equipmentmaintentry_set

Reverse Manager for inventory.EquipmentMaintEntry’s status

glyphicon

CharField(max_length=32)

id

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

name

CharField(max_length=32)

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

Views

inventory.views.cat(request, category_id)[source]

List items by category

Parameters:category_id – The primary key value of the equipment category
inventory.views.item_detail(request, item_id)[source]

Detail page for a specific item

inventory.views.log_access(request, location=None, reason=None)[source]

Checkin form used by LNL members when accessing a storage location (contact tracing)

Parameters:
  • location – The name of the location (must match a location that contains equipment)
  • reason – Should be set to “OUT” if user is checking out of a location (None otherwise)
inventory.views.snipe_checkin(request)[source]

Equipment inventory checkin form. Communicates with Snipe via their API.

inventory.views.snipe_checkout(request)[source]

Equipment inventory checkout form. Communicates with Snipe via their API.

inventory.views.snipe_credentials(request)[source]
inventory.views.type_detail(request, type_id)[source]

Detail page for a group of items

inventory.views.view_all(request)[source]

Lists all items in LNL’s inventory (no longer maintained - read-only)

inventory.views.view_logs(request)[source]

View contact tracing logs for LNL storage spaces


Forms

class inventory.forms.AccessForm(*args, **kwargs)[source]
class Meta[source]
fields = ('users', 'reason')
model

alias of inventory.models.AccessRecord

base_fields = {'reason': <django.forms.fields.CharField object>, 'users': <ajax_select.fields.AutoCompleteSelectMultipleField object>}
declared_fields = {'reason': <django.forms.fields.CharField object>, 'users': <ajax_select.fields.AutoCompleteSelectMultipleField object>}
media
class inventory.forms.SnipeCheckinForm(checkin_from_choices, *args, **kwargs)[source]
base_fields = {'asset_tags': <django.forms.fields.CharField object>}
declared_fields = {'asset_tags': <django.forms.fields.CharField object>}
media
class inventory.forms.SnipeCheckoutForm(checkout_to_choices, *args, **kwargs)[source]
base_fields = {'asset_tags': <django.forms.fields.CharField object>}
declared_fields = {'asset_tags': <django.forms.fields.CharField object>}
media