Users

Users are central to the capabilities and functionality of the system. A User Object in the system should correspond to a physical person accessing the system so that the actions of that user can be tracked for auditing, and various permissions given to that user adhered to.

Users are collected in groups of Users, have multiple attributes associated with them and are authenticated upon login to the system. We have capabilities with a Cantemo App of integration with Active Directory.

Each user inherits capabilities from the groups that they belong to, such as what transcode profiles they can use, what export locations they have and what Cantemo Roles they have in the system.

The Cantemo Roles that they have correspond to the capabilities that have in the system. One Cantemo Role should be related to an action in the user interface.

The user’s information is stored in two database models. User and UserProfile:

There is a one-to-one relationship between a User and UserProfile. A User object will always have a UserProfile, upon creation of a User a related UserProfile model is created and filled with details of the user.

User and UserProfiles also have relationships to internal models to extend the capabilities:

  • Message - Internal messages framework

  • Permission - Internal permission framework

  • Group - Grouping of Users

  • Theme - Each user can be given a separate theme if they so wish.

They are also sync’d to backend MAM resources, such as Vidispine, which in turn might be integrated to a third-party user directory system.

User

class django.contrib.auth.models.User(*args, **kwargs)

Users within the Django authentication system are represented by this model.

Username and password are required. Other fields are optional.

Parameters
  • id – Id

  • password – Password

  • last_login – Last login

  • is_superuser – Designates that this user has all permissions without explicitly assigning them.

  • username – Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.

  • first_name – First name

  • last_name – Last name

  • email – Email address

  • is_staff – Designates whether the user can log into this admin site.

  • is_active – Designates whether this user should be treated as active. Unselect this instead of deleting accounts.

  • date_joined – Date joined

exception DoesNotExist
exception MultipleObjectsReturned

UserProfile

class portal.users.models.UserProfile(*args, **kwargs)

UserProfile objects are automatically created by listing to a post_save signal from the User model. UserProfile extends the User model. signals.py holds the code to this __init__.py holds a reference. UserEditProfileAdminAjaxForm in users.forms is used to allowing Admins to update this section.

>>> u = User.objects.create_user(username="doctestuser",
                                 password = "testpassword",
                                 email = "test@example.com")
>>> u.save()
>>> u.delete()
Parameters
  • id – Id

  • user_id – User

  • notes – Notes

  • create_date – Creation date

  • contact_number – Contact number

  • extra_info – Extra info

  • theme_id – Theme

  • roles – Roles

  • portal_roles – Portal roles

  • homepage – Homepage

  • default_ingest_group_id – Default ingest profile

  • default_collection_profile_id – Default collection profile

  • default_group_id – Default group

  • default_sort_list – Default sort list

  • exclude_search_table_view_columns – Columns to display when using the table view on the search page

  • _default_metadata_group_item – Default metadata group for items

  • _default_metadata_group_collection – Default metadata group for collections

  • _default_metadata_group_subclip – Default metadata group for subclips

  • default_metadata_batch_update_behaviour – Default metadata batch update behaviour

  • login_count – Login count

  • metadata_fields – Metadata fields

  • timeout – Timeout

  • default_search_panel – The panel that should be shown by default on the search page

  • portal_is_local_user – Portal is local user

  • avatar – Avatar

  • default_search_criteria_display – Default search criteria display

  • default_search_criteria_search_only – Default search criteria search only

exception DoesNotExist
exception MultipleObjectsReturned
property default_metadata_group

The users default metadata group. Note: This attribute is deprecated and is now an alias for default_metadata_group_item. Please use the more specific attributes: default_metadata_group_item, default_metadata_group_collection and default_metadata_group_subclip instead. :return: default_metadata_group_item

get_avatar(use_default_if_none=True)
Parameters

use_default_if_none – whether to return a default image when

the avatar has not been set.

Returns the names of the groups the user belongs to. It uses cache as well, as this function is called multiple times in some workflows.

Checking Roles

If you have a User object, or a UserProfile object you can check the MAM roles that are stored on the UserProfile. This is for example useful in App views.

You can get a listing of all the Cantemo Roles a user has in a view by looking at the user associated with a incoming Request:

print(self.request.user.userprofile.portal_roles)

You can check whether a user has a particular Cantemo Role:

if 'portal_ingest_import_from_storage' in self.request.user.userprofile.portal_roles:
    print("User has import role.")

The Cantemo Roles are sync’d on login by the system.