tcms.rpc.api.user module

tcms.rpc.api.user.add_attachment(filename, b64content, **kwargs)[source]
RPC User.add_attachment(filename, b64content)

Attach a file under the currently logged-in user!

This method is meant to be used by SimpleMDE combined with post_save processing for various models like TestPlan and TestCase. While files uploaded by this method will be attached and available (if you know their URL), there is no UI to see all of the files uploaded by a certain user or manage them!

Parameters:
  • filename (str) – File name of attachment, e.g. ‘logs.txt’

  • b64content (str) – Base64 encoded content

  • **kwargs – Dict providing access to the current request, protocol, entry point name and handler instance from the rpc method

Returns:

Information about the attachment

Return type:

dict

tcms.rpc.api.user.deactivate(query)[source]
RPC User.deactivate(query)

Deactivate the selected user(s) so that they cannot login again!

Parameters:

query (dict) – Field lookups for django.contrib.auth.models.User

Returns:

Serialized list of django.contrib.auth.models.User objects

Return type:

list(dict)

Raises:

PermissionDenied – if missing the auth.change_user permission when updating another user or when passwords don’t match.

Specify by user ID:

>>> User.deactivate({'pk': 123})

Specify multiple users by ID:

>>> User.deactivate({'pk__in': [123, 456]})

Specify by username:

>>> User.deactivate({'username': 'john-doe'})

Specify by email:

>>> User.deactivate({'email__icontains': '@example.com'})
>>> User.deactivate({'email__startswith': 'mia@'})
tcms.rpc.api.user.filter(query=None, **kwargs)[source]
RPC User.filter(query)

Search and return the resulting list of users.

Parameters:
  • query (dict) – Field lookups for django.contrib.auth.models.User

  • **kwargs – Dict providing access to the current request, protocol, entry point name and handler instance from the rpc method

Returns:

Serialized list of django.contrib.auth.models.User objects without the password field

Return type:

list(dict)

Raises:

PermissionDenied – if missing the auth.view_user permission

Note

If query is None will return the user issuing the RPC request.

tcms.rpc.api.user.join_group(username, groupname)[source]
RPC User.join_group(username, groupname)

Add user to a group specified by name.

Parameters:
  • username (str) – Username to modify

  • groupname (str) – Name of group to join, must exist!

Raises:

PermissionDenied – if missing auth.change_user permission

tcms.rpc.api.user.update(user_id, values, **kwargs)[source]
RPC User.update(user_id, values)

Updates the fields of the selected user. Can be used to update password as well!

Parameters:
  • user_id (int) – PK of user to update

  • values (dict) – Field values for django.contrib.auth.models.User

  • **kwargs – Dict providing access to the current request, protocol, entry point name and handler instance from the rpc method

Returns:

Serialized django.contrib.auth.models.User object

Return type:

dict

Raises:

PermissionDenied – if missing the auth.change_user permission when updating another user or when passwords don’t match.

Note

If user_id is None will update the user issuing the RPC request.

Warning

Changing the password for another user via RPC is not allowed!