Shotgun Activity Stream Widget

Introduction

The activity stream widget is a QT widget that renders the activity stream for a given Shotgun entity. The functionality is similar to that in the activity stream found inside the Shotgun web application. Publishes and Versions show up with thumbnails, optionally with playback links. Notes show up with replies and attachments and you can reply to notes directly in the activity stream.

_images/activity_stream_1.png

In addition to an activity stream widget, this module also contains a widget for displaying notes and replies. This uses the same data backend as the activity stream and has a similar look and feel.

_images/activity_stream_2.png

Caching policy

All the content in the activity stream is cached and when you request the activity stream for an entity, the widget requests only the changes since the last update. The data is cached in a shared manner, meaning that a project, shot and task may be showing the same updates in their respective streams - and in this case, those updates are only pulled down once.

ActivityStreamWidget

class activity_stream.ActivityStreamWidget(parent)[source]

Bases: PySide.QtGui.QWidget

QT Widget that displays the Shotgun activity stream for an entity.

Signal entity_requested(str, int):
 Fires when someone clicks an entity inside the activity stream. The returned parameters are entity type and entity id.
Signal playback_requested(dict):
 Fires when someone clicks the playback url on a version. Returns a shotgun dictionary with information about the version.
Signal entity_created(object):
 Fires when a Note or Reply entity is created by an underlying widget within the activity stream. Returns a Shotgun dictionary with information about the new Entity.
Variables:reply_dialog (dialog_reply.ReplyDialog or None) – When a ReplyDialog is active it can be accessed here. If there is no ReplyDialog active, then this will be set to None.
Parameters:parent (QWidget) – QT parent object
set_bg_task_manager(task_manager)[source]

Specify the background task manager to use to pull data in the background. Data calls to Shotgun will be dispatched via this object.

Parameters:task_manager (BackgroundTaskManager) – Background task manager to use
destroy()[source]

Should be called before the widget is closed

note_threads

The currently loaded note threads, keyed by Note entity id and containing a list of Shotgun entity dictionaries. All note threads currently displayed by the activity stream widget will be returned.

Example structure containing a Note, a Reply, and an attachment:

6040: [
    {
        'addressings_cc': [],
        'addressings_to': [],
        'client_note': False,
        'content': 'This is a test note.',
        'created_at': 1466477744.0,
        'created_by': {
            'id': 39,
            'name': 'Jeff Beeland',
            'type': 'HumanUser'
        },
        'id': 6040,
        'note_links': [
            {
                'id': 1167,
                'name': '123',
                'type': 'Shot'
            },
            {
                'id': 6023,
                'name': 'Scene_v030_123',
                'type': 'Version'
            }
        ],
        'read_by_current_user': 'read',
        'subject': "Jeff's Note on Scene_v030_123, 123",
        'tasks': [
            {
                'id': 2118,
                'name': 'Comp',
                'type': 'Task'
            }
        ],
        'type': 'Note',
        'user': {
            'id': 39,
            'name': 'Jeff Beeland',
            'type': 'HumanUser'
        },
        'user.ApiUser.image': None,
        'user.ClientUser.image': None,
        'user.HumanUser.image': 'https://url_to_file'
    },
    {
        'content': 'test reply',
        'created_at': 1469221928.0,
        'id': 23,
        'type': 'Reply',
        'user': {
            'id': 39,
            'image': 'https://url_to_file',
            'name': 'Jeff Beeland',
            'type': 'HumanUser'
        }
    },
    {
        'attachment_links': [
            {
                'id': 6051,
                'name': "Jeff's Note on Scene_v030_123, 123 - testing.",
                'type': 'Note'
            }
        ],
        'created_at': 1469484693.0,
        'created_by': {
            'id': 39,
            'name': 'Jeff Beeland',
            'type': 'HumanUser'
        },
        'id': 601,
        'image': 'https://url_to_file',
        'this_file': {
            'content_type': 'image/png',
            'id': 601,
            'link_type': 'upload',
            'name': 'screencapture_vrviim.png',
            'type': 'Attachment',
            'url': 'https://url_to_file'
        },
        'type': 'Attachment'
    },
]
note_widget

Returns the NoteInputWidget contained within the ActivityStreamWidget. Note that this is the widget used for NEW note input and not Note replies. To get the NoteInputWidget used for Note replies, access can be found via ReplyDialog.note_widget().

clickable_user_icons

Whether user icons in the activity stream display as clickable. If True, a pointing hand cursor will be shown when the mouse is hovered over the icons, otherwise the default arrow cursor will be used.

pre_submit_callback

The pre-submit callback. This is None if one is not set, or a Python callable if it is. This callable is run prior to submission of a new Note or Reply. Note that the first (and only) argument passed to the callback will be the calling NoteInputWidget.

Returns:Python callable or None
allow_screenshots

Whether this activity stream is allowed to give the user access to a button that performs screenshot operations.

show_sg_stream_button

Whether the button to navigate to Shotgun is shown in the stream.

version_items_playable

Whether the label representing a created Version entity is shown as being “playable” within the UI. If True, then a play icon is visible over the thumbnail image, and no icon overlay is shown when False.

If True, lists out the parent entity as a list of clickable items for each Note entity that is represented in the activity stream.

highlight_new_arrivals

If True, highlights items in the activity stream that are new since the last time data was loaded.

attachments_filter

If set to a compiled regular expression, attachment file names that match will be filtered OUT and NOT shown.

Note

An re.match() is used, which means the regular expression must match from the start of the attachment file’s basename. See Python’s “re” module documentation for Python 2.x for more information and examples.

Example to match only ”.gif” extensions:

re.compile(r"\w+[.]gif$")
deselect_note()[source]

If a note is currently selected, it will be deselected. This will NOT trigger a note_deselected signal to be emitted, as that is only emitted when the user triggers the deselection and not via procedural means.

get_note_attachments(note_id)[source]

Gets the Attachment entities associated with the given Note entity. Only attachments from Notes currently loaded by the activity stream widget will be returned.

Note

It is possible for attachments to be added to a Note entity after the activity stream data has been cached. In this situation, those attachments will NOT be returned, as Shotgun will not be requeried for that new data unless specifically requested to do so.

Parameters:note_id (int) – The Note entity id.
load_data(sg_entity_dict)[source]

Reset the state of the widget and then load up the data for a given entity.

Parameters:sg_entity_dict (dict) – Dictionary with keys type and id
show_new_note_dialog(modal=True)[source]

Shows a dialog that allows the user to input a new note.

Note

The return value of the new note dialog is not provided, as the activity stream widget will emit an entity_created signal if the user successfully creates a new Note entity.

Parameters:modal (bool) – Whether the dialog should be shown modally or not.
rescan(force_activity_stream_update=False)[source]

Triggers a rescan of the current activity stream data.

Parameters:force_activity_stream_update (bool) – If True, will force a requery of activity stream data, even if it is already cached.
mousePressEvent(event)[source]

Overrides the default event handler in Qt.

ReplyListWidget

class activity_stream.ReplyListWidget(parent)[source]

Bases: PySide.QtGui.QWidget

QT Widget that displays a note conversation, including attachments and the ability to reply.

This will first render the body of the note, including the attachments, and then subsequent replies. This widget uses the same widgets, data backend and visual components as the activity stream.

Signal entity_requested(str, int):
 Fires when someone clicks an entity inside the activity stream. The returned parameters are entity type and entity id.
Parameters:parent (QWidget) – QT parent object
set_bg_task_manager(task_manager)[source]

Specify the background task manager to use to pull data in the background. Data calls to Shotgun will be dispatched via this object.

Parameters:task_manager (BackgroundTaskManager) – Background task manager to use
destroy()[source]

Should be called before the widget is closed

load_data(sg_entity_dict)[source]

Load replies for a given entity.

Parameters:sg_entity_dict – Shotgun link dictionary with keys type and id.