Allocation

Bases: TimeStampedModel

An allocation provides users access to a resource.

Attributes:
  • project (Project) –

    links the project the allocation falls under

  • resources (Resource) –

    links resources that this allocation allocates

  • status (AllocationStatusChoice) –

    represents the status of the allocation

  • quantity (int) –

    indicates the quantity of the resource for the allocation, if applicable

  • start_date (Date) –

    indicates the start date of the allocation

  • end_date (Date) –

    indicates the end/ expiry date of the allocation

  • justification (str) –

    text input from the user containing the justification for why the resource is being allocated

  • description (str) –

    description of the allocation

  • is_locked (bool) –

    indicates whether or not the allocation is locked

  • is_changeable (bool) –

    indicates whether or not the allocation is changeable

expires_in property

Returns:
  • int

    the number of days until the allocation expires

get_information property

Returns:
  • SafeString( SafeString ) –

    the allocation's attribute type, usage out of total value, and usage out of total value as a percentage

get_parent_resource property

Returns:
  • Resource

    the parent resource for the allocation

get_resources_as_list property

Returns:
  • list[Resource]: the resources for the allocation

get_resources_as_string property

Returns:
  • str

    the resources for the allocation

add_user

Adds a user to the allocation.

If EULAs are enabled and this allocation has an associated EULA, marks the user as "PendingEULA" and sends the user an email asking them to agree to the EULA. Otherwise, marks the user as "Active." Also sends the allocation_activate_user signal if the allocation status is "Active."

Parameters:
  • user (User) –

    User to add.

  • signal_sender (str, default: None ) –

    Sender for the allocation_activate_user signal.

clean

Validates the allocation and raises errors if the allocation is invalid.

expire

Sets the allocation status to "Expired" and expires all active allocations.

get_attribute

Parameters:
  • name (str) –

    name of the allocation attribute type

  • expand (bool, default: True ) –

    indicates whether or not to return the expanded value with attributes/parameters for attributes with a base type of 'Attribute Expanded Text'

  • typed (bool, default: True ) –

    indicates whether or not to convert the attribute value to an int/ float/ str based on the base AttributeType name

  • extra_allocations (list[Allocation], default: [] ) –

    allocations which are available to reference in the attribute list in addition to those associated with this AllocationAttribute

Returns:
  • str

    the value of the first attribute found for this allocation with the specified name

get_attribute_list

Parameters:
  • name (str) –

    name of the allocation

  • expand (bool, default: True ) –

    indicates whether or not to return the expanded value with attributes/parameters for attributes with a base type of 'Attribute Expanded Text'

  • typed (bool, default: True ) –

    indicates whether or not to convert the attribute value to an int/ float/ str based on the base AttributeType name

  • extra_allocations (list[Allocation], default: [] ) –

    allocations which are available to reference in the attribute list in addition to those associated with this AllocationAttribute

Returns:
  • list

    the list of values of the attributes found with specified name

get_attribute_set

Parameters:
  • user (User) –

    user for whom to return attributes

Returns:
  • list[AllocationAttribute]: returns the set of attributes the user is allowed to see (if superuser, then all allocation attributes; else, only non-private ones)

get_user_emails

Gets a set of user emails for notifications.

Parameters:
  • status_name (str, default: 'Active' ) –

    The name of the AllocationUserStatus to filter on. Defaults to "Active".

  • ignore_disabled_notifications (bool, default: False ) –

    If True, include project users that have enable_notifications off.

Returns:
  • set( set[str] ) –

    A set of user emails for notifications.

has_perm

Parameters:
  • user (User) –

    user to check permissions for

  • perm (AllocationPermission) –

    permission to check for in user's list

Returns:
  • bool

    whether or not the user has the specified permission

remove_user

Marks an AllocationUser as 'Removed' and sends the allocation_remove_user signal.

Parameters:
  • user (User | AllocationUser) –

    User to remove.

  • signal_sender (str, default: None ) –

    Sender for the allocation_remove_user signal.

  • ignore_user_not_found (bool, default: True ) –

    If enabled, logs a warning that the allocation user for the provded user couldn't be found and returns. Otherwise, raises AllocationUser.DoesNotExist.

save

Saves the project.

set_usage

Parameters:
  • name (str) –

    allocation attribute type whose usage to set

  • value (float) –

    value to set usage to

user_permissions

Parameters:
  • user (User) –

    user for whom to return permissions

Returns:
  • list[AllocationPermission]: list of user permissions for the allocation

AllocationAccount

Bases: TimeStampedModel

An allocation account

come back to

Attributes:
  • user (User) –

    represents the User object of the project user

  • name (str) –

AllocationAdminNote

Bases: TimeStampedModel

An allocation admin note is a note that an admin makes on an allocation.

Attributes:
  • allocation (Allocation) –

    links the allocation to the note

  • author (User) –

    represents the User class of the admin who authored the note

  • note (str) –

    text input from the user containing the note

AllocationAttribute

Bases: TimeStampedModel

An allocation attribute class links an allocation attribute type and an allocation.

Attributes:
  • allocation_attribute_type (AllocationAttributeType) –

    attribute type to link

  • allocation (Allocation) –

    allocation to link

  • value (str) –

    value of the allocation attribute

clean

Validates the allocation attribute and raises errors if the allocation attribute is invalid.

expanded_value

Parameters:
  • typed (bool, default: True ) –

    indicates whether or not to convert the attribute value to an int/ float/ str based on the base AttributeType name (unrecognized values not converted, so will return str)

  • extra_allocations (list[Allocation], default: [] ) –

    allocations which are available to reference in the attribute list in addition to those associated with this ResourceAttribute

Returns:
  • int, float, str: the value of the attribute after attribute expansion

For attributes with attribute type of 'Attribute Expanded Text' we look for an attribute with same name suffixed with '_attriblist' (this should be ResourceAttribute of the Resource associated with the attribute). If the attriblist attribute is found, we use it to generate a dictionary to use to expand the attribute value, and the expanded value is returned.

If the expansion fails, or if no attriblist attribute is found, or if the attribute type is not 'Attribute Expanded Text', we just return the raw value.

save

Saves the allocation attribute.

typed_value

Returns:
  • int, float, str: the value of the attribute with proper type and is used for computing expanded_value() (coerced into int or float for attributes with Int or Float types; if it fails or the attribute is of any other type, it is coerced into a str)

AllocationAttributeChangeRequest

Bases: TimeStampedModel

An allocation attribute change request represents a request from a PI/ manager to change their allocation attribute.

Attributes:
  • allocation_change_request (AllocationChangeRequest) –

    links the change request from which this attribute change is derived

  • allocation_attribute (AllocationAttribute) –

    represents the allocation_attribute to change

  • new_value (str) –

    new value of allocation attribute

AllocationAttributeType

Bases: TimeStampedModel

An allocation attribute type indicates the type of the attribute. Examples include Cloud Account Name and Core Usage (Hours).

Attributes:
  • attribute_type (AttributeType) –

    indicates the data type of the attribute

  • name (str) –

    name of allocation attribute type

  • has_usage (bool) –

    indicates whether or not the attribute type has usage

  • is_required (bool) –

    indicates whether or not the attribute is required

  • is_unique (bool) –

    indicates whether or not the value is unique

  • is_private (bool) –

    indicates whether or not the attribute type is private

  • is_changeable (bool) –

    indicates whether or not the attribute type is changeable

AllocationAttributeUsage

Bases: TimeStampedModel

Allocation attribute usage indicates the usage of an allocation attribute.

Attributes:
  • allocation_attribute (AllocationAttribute) –

    links the usage to its allocation attribute

  • value (float) –

    usage value of the allocation attribute

AllocationChangeRequest

Bases: TimeStampedModel

An allocation change request represents a request from a PI or manager to change their allocation.

Attributes:
  • allocation (Allocation) –

    represents the allocation to change

  • status (AllocationStatusChoice) –

    represents the allocation status of the changed allocation

  • end_date_extension (int) –

    represents the number of days to extend the allocation's end date

  • justification (str) –

    represents input from the user justifying why they want to change the allocation

  • notes (str) –

    represents notes for users changing allocations

get_parent_resource property

Returns:
  • Resource

    the parent resource for the allocation

AllocationChangeStatusChoice

Bases: TimeStampedModel

An allocation change status choice represents statuses displayed when a user changes their allocation status (for allocations that have their is_changeable attribute set to True). Examples include Expired and Payment Pending.

Attributes:
  • name (str) –

    status name

AllocationPermission

Bases: Enum

An allocation permission stores the user and manager fields of a project.

AllocationStatusChoice

Bases: TimeStampedModel

A project status choice indicates the status of the project. Examples include Active, Archived, and New.

Attributes:
  • name (str) –

    name of project status choice

AllocationUser

Bases: TimeStampedModel

An allocation user represents a user on the allocation.

Attributes:
  • allocation (Allocation) –

    links user to its allocation

  • user (User) –

    represents the User object of the allocation user

  • status (ProjectUserStatus) –

    links the project user status choice to the user

is_active

Helper function returns True if allocation user status == Active and allocation status is one of the accepted active states where users should be considered active and have actions taken on them (i.e. groups added, accounts created in other systems, etc.)

AllocationUserNote

Bases: TimeStampedModel

An allocation user note is a note that an user makes on an allocation.

Attributes:
  • allocation (Allocation) –

    links the allocation to the note

  • author (User) –

    represents the User class of the user who authored the note

  • is_private (bool) –

    indicates whether or not the note is private

  • note (str) –

    text input from the user containing the note

AllocationUserStatusChoice

Bases: TimeStampedModel

An allocation user status choice indicates the status of an allocation user. Examples include Active, Error, and Removed.

Attributes:
  • name (str) –

    name of the allocation user status choice

AttributeType

Bases: TimeStampedModel

An attribute type indicates the data type of the attribute. Examples include Date, Float, Int, Text, and Yes/No.

Attributes:
  • name (str) –

    name of attribute data type