Users

Interface User

Also includes signal handlers for Vidispine Users to attach to generic changes to users from Portal.

class portal.vidispine.iuser.UserHelper(user=None, runas=None, *args, **kwargs)

The Vidispine user helper object contains functions for manipulating user objects in Vidispine

Parameters

runas (string) – The user to perform operations as. Default to the admin user

All of the functions in this class can can be accessed using the following pattern.

Create a new user
  user_helper = UserHelper() # this runs as admin
  user_helper.createUser("john", "John Doe", "secretpassword")
List all users
  user_helper = UserHelper(runas=request.user.username) # this runs as the user making the request
  user_helper.getAllUsers()
addUserToGroup(user_name, group_name)

Add a user to a group

Parameters
  • user_name (string) – The username

  • group_name (string) – The groupname

Returns

None

Signals raised:
  • Pre modify:

    sender=self.__class__, instance=username, method=”addUserToGroup”, group_name=group_name

  • Post modify:

    sender=self.__class__, instance=username, method=”addUserToGroup”, group_name=group_name

addUserToMultipleGroups(user_name, group_names, move=True)

Add a user to multiple groups at once, possibly removing the user from all other groups

Parameters
  • user_name (string) – The username

  • group_names (list of string) – A list of group names

  • move – Should the user be removed from all groups not in group_names

Returns

None

createUser(newUserName, newRealName, newPassword)

Create a new user in Vidispine

Parameters
  • newUserName (string) – The username

  • newRealName (string) – The realname of the user

  • newPassword (string) – The password

Returns

A VidiRest.objects.user.VSUser object for the new user

Signals raised:
  • Pre create:

    sender=self.__class__, instance=newUserName, method=”createUser”, newRealName=newRealName, newPassword=newPassword

  • Post create:

    sender=self.__class__, instance=newUserName, method=”createUser”

deleteUser(UserName, hard=False, remove_from_groups=False, remove_from_libraries=False)

Disable a user in Vidispine

Parameters
  • UserName (string) – The username

  • hard (Boolean) – If removing the user completely instead of just disabling it

  • remove_from_groups (Boolean) – If the user should be removed from all groups they are in

  • remove_from_libraries – If the user should be removed from all libraries they are in

Returns

None

Signals raised:
  • Pre delete:

    sender=self.__class__, instance=username, method=”deleteUser”

  • Post delete:

    sender=self.__class__, instance=username, method=”deleteUser”

getAllUsers(includeSelf=True, groupByStatus=False, includeDisabled=False, returnGroups=False, include_deleted=False, *args)

Fetch a list of users.

Parameters
  • includeSelf (bool) – includes the requested user as well

  • groupByStatus (bool) – groups the users in to enabled and disabled in a dictionary

  • includeDisabled (bool) – includes disabled users as well. Ignored if groupByStatus is True

  • returnGroups (bool) – returns the group information as well

  • include_deleted (bool) – returns permanent deleted users as well

Returns

List of VidiRest.objects.user.VSUser objects matching the criteria

Return type

list[VidiRest.objects.user.VSUser]

getUser(usertoget)

Get a particular user by username

Parameters

usertoget (string) – The username

Returns

The json object returned from vidispine

getUserGroups(username, allgroups=False, exclude_roles=False)

Get the list of groups a user belongs to

Parameters
  • username (string) – The username

  • allgroups (bool) – Get the recursive list of all groups the user is a member of, including any parent groups

  • exclude_roles (bool) – Exclude portal and vidispine roles

Returns

A list of all groups a user is member of - this is “group” of the returned dictionary

reEnableUser(UserName)

Reenable a user that has been disabled in Vidispine.

Parameters

UserName (string) – The username

Returns

None

Signals raised:
  • Pre modify:

    sender=self.__class__, instance=username, method=”reEnableUser”

  • Post modify:

    sender=self.__class__, instance=username, method=”reEnableUser”

removeUserFromGroup(user_name, group_name)

Remove a User from a Group

Parameters
  • user_name (string) – The username

  • group_name (string) – The groupname

Returns

None

Signals raised:
  • Pre modify:

    sender=self.__class__, instance=username, method=”removeUserFromGroup”, group_name=group_name

  • Post modify:

    sender=self.__class__, instance=username, method=”removeUserFromGroup”, group_name=group_name

setUserPassword(UserName, newPassword)

Change a user’s password

Parameters

UserName (string) – The username

Returns

None

Signals raised:
  • Pre modify:

    sender=self.__class__, instance=username, method=”setUserPassword”, newPassword=newPassword

  • Post modify:

    sender=self.__class__, instance=username, method=”setUserPassword”, newPassword=newPassword

setUserRealName(user_name, real_name)

Change the real name of a user

Parameters
  • user_name (string) – The username

  • real_name (string) – The new real name

Returns

None

Signals raised:
  • Pre modify:

    sender=self.__class__, instance=username, method=”setUserRealName”, real_name=real_name

  • Post modify:

    sender=self.__class__, instance=username, method=”setUserRealName”, real_name=real_name

setUserUsername(original_username, new_username)

Sets the username to the specified now. Intended just for user hard deletion. We should not use this for any other particular reason.

Parameters

new_username

Returns