physics_workload.app.models.staff

Attributes

Classes

Staff

Member of staff; not necessarily a current user.

Functions

update_staff_link(sender, instance, created, **kwargs)

Link newly created CustomUser to a staff member.

is_staff_for_user(→ bool)

Does this staff account correspond to the current user?

Module Contents

physics_workload.app.models.staff.logger: logging.Logger
physics_workload.app.models.staff.User
class physics_workload.app.models.staff.Staff

Bases: app.models.common.ModelCommon

Member of staff; not necessarily a current user.

Attribute icon:

Icon to use in the front end.

Attribute url_root:

Root URL for the model.

Attribute user:

The user account corresponding to this staff member, may be none.

Attribute account:

The active directory account name for this staff member.

Attribute name:

The name of this staff member.

DYNAMIC_FIELDS = ['load_balance_historic', 'load_balance_final', 'load_target', 'load_assigned']
icon = 'user'
url_root = 'staff'
user
account
name
academic_group
gender
load_target
load_assigned
load_external
hours_fixed
fte_fraction
load_balance_final
load_balance_historic
notes
class Meta
ordering = ['name']
verbose_name = 'Staff Member'
verbose_name_plural = 'Staff Members'
indexes
constraints
get_absolute_url() str

Gets the URL for this staff member’s page. :return: The URL.

get_absolute_url_if_permitted(user: User) str | None

Gets the URL for this staff member’s page if the user has the rights to view it. :return: The URL, or None if they don’t.

__str__()

Default rendering of a staff member shows their load balance

Returns:

Their name plus load balance.

get_instance_header(text: str | None = None) str

Creates a header for staff, without their load balance in.

Parameters:

text – Ignored, only exists to match signature.

Returns:

A header with just the name.

get_load_balance()

Gets how much under or overloaded the staff member is.

Returns:

The balance of assigned load against target load, negative if underloaded.

update_load_assigned()

Updates own assigned load by summing the load of the assignments.

Returns:

True if the total load has changed, false if not.

update_load_target()

Updates the target load from the standard load settings.

Returns:

True if the load target has changed, false if not.

Link newly created CustomUser to a staff member.

Parameters:
  • sender

  • instance

  • created

  • kwargs

Returns:

physics_workload.app.models.staff.is_staff_for_user(user: User, staff: Staff) bool

Does this staff account correspond to the current user?

Parameters:
  • user – The current user.

  • staff – The teaching staff.

Returns:

True if so.