Previous topic

stalker.core.models.Status

Next topic

stalker.core.models.Structure

This Page

stalker.core.models.StatusList

Inheritance diagram of stalker.core.models.StatusList

class stalker.core.models.StatusList(statuses=None, target_entity_type='', **kwargs)[source]

Bases: stalker.core.models.Entity

Type specific list of Status instances.

Holds multiple Statuses to be used as a choice list for several other classes.

A StatusList can only be assigned to only one entity type. So a Project can only have a suitable StatusList object which is designed for Project entities.

The list of statuses in StatusList can be accessed by using a list like indexing and it also supports string indexes only for getting the item, you can not set an item with string indices:

>>> from stalker.core.models import Status, StatusList
>>> status1 = Status(name="Complete", code="CMPLT")
>>> status2 = Status(name="Work in Progress", code="WIP")
>>> status3 = Status(name="Pending Review", code="PRev")
>>> a_status_list = StatusList(name="Asset Status List",
                               statuses=[status1, status2, status3],
                               target_entity_type="Asset")
>>> a_status_list[0]
<Status (Complete, CMPLT)>
>>> a_status_list["complete"]
<Status (Complete, CMPLT)>
>>> a_status_list["wip"]
<Status (Work in Progress, WIP)>
Parameters:
  • statuses – this is a list of status objects, so you can prepare different StatusList objects for different kind of entities
  • target_entity_type

    use this parameter to specify the target entity type that this StatusList is designed for. It accepts classes or names of classes.

    For example:

    from stalker.core.models import Status, StatusList, Project
    
    status_list = [
        Status(name="Waiting To Start", code="WTS"),
        Status(name="On Hold", code="OH"),
        Status(name="In Progress", code="WIP"),
        Status(name="Waiting Review", code="WREV"),
        Status(name="Approved", code="APP"),
        Status(name="Completed", code="CMPLT"),
    ]
    
    project_status_list = StatusList(
        name="Project Status List",
        statuses=status_list,
        target_entity_type="Project"
    )
    
    # or
    project_status_list = StatusList(
        name="Project Status List",
        statuses=status_list,
        target_entity_type=Project
    )
    

    now with the code above you can not assign the project_status_list object to any other class than a Project object.

    The StatusList instance can be empty, means it may not have anything in its statuses. But it is useless. The validation for empty statuses list is left to the SOM user.

__init__(statuses=None, target_entity_type='', **kwargs)[source]

Methods

__init__(**kwargs[, statuses, ...])

Attributes

code The code name of this object.
created_by The User who has created this object.
created_by_id
date_created A datetime.datetime instance showing the creation date and time of this object.
date_updated A datetime.datetime instance showing the update date and time of this object.
description Description of this object.
entity_id
entity_type
id
name Name of this object
nice_name Nice name of this object.
notes All the Notess attached to this entity.
reviews All the Reviews about this Entity.
statusList_id
statuses list of Status objects, showing the possible statuses
tags A list of tags attached to this object.
target_entity_type The entity type which this StatusList is valid for.
type The type of the object.
type_id
updated_by The User who has updated this object.
updated_by_id
statuses

list of Status objects, showing the possible statuses

target_entity_type[source]

The entity type which this StatusList is valid for.

Usally it is set to the TargetClass directly:

from stalker.core.models import Status, StatusList, Asset

# create a StatusList valid only for Asset class
asset_status_list = StatusList(
    name="Asset Statuses",
    statuses = [
        Status(name="Waiting To Start", code="WTS"),
        Status(name="Work In Progress", code="WIP"),
        Status(name="Complete", code="CMPLT")
    ],
    target_entity_type=Asset # or "Asset" is also valid
)
code

The code name of this object.

It accepts string or unicode values and any other kind of objects will be converted to string. In any update to the name attribute the code also will be updated. If the code is not initialized or given as None, it will be set to the uppercase version of the nice_name attribute. Setting the code attribute to None will reset it to the default value. The default value is the upper case form of the nice_name.

created_by

The User who has created this object.

date_created

A datetime.datetime instance showing the creation date and time of this object.

date_updated

A datetime.datetime instance showing the update date and time of this object.

description

Description of this object.

name

Name of this object

nice_name

Nice name of this object.

It has the same value with the name (contextually) but with a different format like, all the white spaces replaced by underscores (“_”), all the CamelCase form will be expanded by underscore (_) characters and it is always lower case.

There is also the code attribute which is simply the upper case form of nice_name if it is not defined differently (i.e set to another value).

notes

All the Notess attached to this entity.

It is a list of Note instances or an empty list, setting it None will raise a TypeError.

reviews

All the Reviews about this Entity.

It is a list of Review instances or an empty list, setting it None will raise a TypeError.

tags

A list of tags attached to this object.

It is a list of Tag instances which shows the tags of this object

type

The type of the object.

It is an instance of Type with a proper target_entity_type.

updated_by

The User who has updated this object.