stalker.core.models.User — Stalker v0.1.1.a9 documentation

### Navigation

- index
- next |
- previous |
- Stalker v0.1.1.a9 documentation »

# stalker.core.models.User

class `stalker.core.models.` `User`(department=None, email='', first_name='', last_name='', login_name='', password='', permission_groups=[], projects_lead=[], sequences_lead=[], tasks=[], last_login=None, initials='', **kwargs)

  Bases: `stalker.core.models.Entity`

  The user class is designed to hold data about a User in the system.

  There are a couple of points to take your attention to:

  > - The `code` attribute is derived from the `nice_name` as it is in a `SimpleEntity`, but the `nice_name` is derived from the `login_name` instead of the `name` attribute, so the `code` of a `User` and a `SimpleEntity` will be different then each other. The formatting of the `code` attribute is as follows:

  >   > - no underscore character is allowed, so while in the `SimpleEntity` class the code could have underscores, in `User` class it is not allowed.
  >   > - all the letters in the code will be converted to lower case.

  >   Other than this two new rules all the previous formatting rules from the `SimpleEntity` are still in charge.

  > - The `name` is a synonym of the `login_name`, so changing one of them will change the other.

  Parameters: | email (unicode) – holds the e-mail of the user, should be in [part1]@[part2] format login_name (unicode) – it is the login name of the user, it should be all lower case. Giving a string or unicode that has uppercase letters, it will be converted to lower case. It can not be an empty string or None and it can not contain any white space inside. login_name parameter will be copied over name if both of them is given, if one of them given they will have the same value which is the formatted login_name value. Setting the name value also sets the login_name and setting the login_name property also sets the name, while creating a User object you don’t need to specify both of them, one is enough and if the two is given login_name will be used. first_name (unicode) – it is the first name of the user, must be a string or unicode, middle name also can be added here, so it accepts white-spaces in the variable, but it will truncate the white spaces at the beginin and at the end of the variable and it can not be empty or None last_name (unicode) – it is the last name of the user, must be a string or unicode, again it can not contain any white spaces at the beggining and at the end of the variable and it can be an empty string or None department (`Department`) – it is the department of the current user. It should be a Department object. One user can only be listed in one department. A user is allowed to have no department to make it easy to create a new user and create the department and assign the user it later. password (unicode) – it is the password of the user, can contain any character. Stalker doesn’t store the raw passwords of the users. To check a stored password with a raw password use `check_password()` and to set the password you can use the `password` property directly. permission_groups (`PermissionGroup`) – it is a list of permission groups that this user is belong to tasks (list of `Task`s) – it is a list of Task objects which holds the tasks that this user has been assigned to projects_lead (list of `Project`s) – it is a list of Project objects that this user is the leader of, it is for back refefrencing purposes. sequences_lead (list of `Sequence`) – it is a list of Sequence objects that this user is the leader of, it is for back referencing purposes last_login (datetime.datetime) – it is a datetime.datetime object holds the last login date of the user (not implemented yet) initials (unicode) – it is the initials of the users name, if nothing given it will be calculated from the first and last names of the user

  `__init__`(department=None, email='', first_name='', last_name='', login_name='', password='', permission_groups=[], projects_lead=[], sequences_lead=[], tasks=[], last_login=None, initials='', **kwargs)

  Methods

  `__init__`(**kwargs[, department, email, ...]) |
  `check_password`(raw_password) | Checks the given raw_password.

  Attributes

  `code` | The code name of this object.
  `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.
  `department` | department of the user, it is a
  `description` | Description of this object.
  `email` | email of the user, accepts strings or unicodes
  `first_name` | first name of the user, accepts string or unicode
  `initials` | The initials of the user.
  `last_login` | The last login time of this user.
  `last_name` | The last name of the user.
  `login_name` | The login name of the user.
  `name` | The name of this user.
  `nice_name` | Nice name of this object.
  `notes` | All the notes about this entity.
  `password` | The password of the user.
  `permission_groups` | permission groups that this users is a member of, accepts
  `projects` | The list of `Project`s those the current user assigned to.
  `projects_lead` | projects lead by this current user, accepts
  `sequences_lead` | sequences lead by this user, accpets
  `tags` | A list of tags attached to this object.
  `tasks` | tasks assigned to the current user, accepts
  `type` | The type of the object.
  `updated_by` | The `User` who has updated this object.

  `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.

  `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 notes about this entity.

    It is a list of `Note` objects or an empty list, None will be converted to an empty list.

  `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.

  `check_password`(raw_password)

    Checks the given raw_password.

    Checks the given raw_password with the current Users objects encrypted password.

  `department`

    department of the user, it is a `Department` object

  `email`

    email of the user, accepts strings or unicodes

  `first_name`

    first name of the user, accepts string or unicode

  `initials`

    The initials of the user.

    If not spesified, it is the upper case form of first letters of the `first_name` and `last_name`

  `last_login`

    The last login time of this user.

    It is an instance of datetime.datetime class.

  `last_name`

    The last name of the user.

    It is a string and can be None or empty string

  `login_name`

    The login name of the user.

    It is a string and also sets the `name` attribute

  `name`

    The name of this user.

    It is the synonym for the `login_name`.

  `password`

    The password of the user.

    It is scrambled before it is stored.

  `permission_groups`

    permission groups that this users is a member of, accepts `PermissionGroup` object

  `projects`

    The list of `Project`s those the current user assigned to.

    returns a list of `Project` objects. It is a read-only attribute. To assign a `User` to a `Project`, you need to create a new `Task` with the `resources` is set to this `User` and assign the `Task` to the `Project` by setting the `project` attribute of the `Task` to the `Project`.

  `projects_lead`

    projects lead by this current user, accepts `Project` object

  `sequences_lead`

    sequences lead by this user, accpets `Sequence` objects

  `tasks`

    tasks assigned to the current user, accepts `Task` objects

### Navigation

- index
- next |
- previous |
- Stalker v0.1.1.a9 documentation »