Command

Qualified name: intranet.apps.dataimport.management.commands.import\_students.Command

class intranet.apps.dataimport.management.commands.import_students.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: BaseCommand

Methods

add_arguments

ask

find_next_available_username

Find the next available username.

generate_single_username

Generate a single username.

handle

Attributes

help

find_next_available_username(used_username: str, username_set: set | None = None) str[source]

Find the next available username.

Parameters:
  • used_username – The used username.

  • username_set – An additional set of usernames to deduplicate against. Regardless of this argument, this method will check against the database.

Returns:

A username that has not been used. Increments the digit on the end, or tacks one on if it doesn’t exist.

generate_single_username(users_properties: {}, graduating_year: int, first_name_header: str = 'First Name', last_name_header: str = 'Last Name') str[source]

Generate a single username. Ignores the presence of other users (so duplicate usernames are not handled).

Parameters:
  • users_properties – A dictionary with users’ properties, typically a SIS export.

  • graduating_year – The graduating year of the student.

  • first_name_header – The key of the ‘first name’ field in the properties.

  • last_name_header – The key of the ‘last name’ field in the properties.

Returns:

A single username.