Previous topic

stalker.core.models.Type

Next topic

stalker.core.models.Version

This Page

stalker.core.models.User

Inheritance diagram of stalker.core.models.User

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

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 Tasks) – it is a list of Task objects which holds the tasks that this user has been assigned to
  • projects_lead (list of Projects) – 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=None, projects_lead=None, sequences_lead=None, tasks=None, last_login=None, initials='', **kwargs)[source]

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.
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.
department Department of the user
department_id
description Description of this object.
email email of the user, accepts strings or unicodes
entity_id
entity_type
first_name first name of the user, accepts string or unicode
id
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 Name of this object
nice_name Nice name of this object.
notes All the Notess attached to this entity.
password The password of the user.
permission_groups Permission groups that this users is a member of.
projects The list of Projects those the current user assigned to.
projects_lead Projects lead by this user.
reviews All the Reviews about this Entity.
sequences_lead Sequences lead by this user.
tags A list of tags attached to this object.
tasks Tasks assigned to this user.
type The type of the object.
type_id
updated_by The User who has updated this object.
updated_by_id
user_id
department

Department of the user

email

email of the user, accepts strings or unicodes

first_name

first name of the user, accepts string or unicode

last_name

The last name of the user.

It is a string and can be None or empty string

name

Name of this object

login_name

The login name of the user.

It is a synonym for the name attribute.

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

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_lead

Projects lead by this user.

It is a list of Project instances.

sequences_lead

Sequences lead by this user.

It is a list of Sequence instances.

tasks

Tasks assigned to this user.

It is a list of Task instances.

last_login

The last login time of this user.

It is an instance of datetime.datetime class.

check_password(raw_password)[source]

Checks the given raw_password.

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

projects[source]

The list of Projects 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.

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