Skip to content

Add Task Comments widget #4

@BigRoy

Description

@BigRoy

Issue

Getting the comments for a Widget through gazu can be done. However qtazu does not expose any widget that allows to choose a Task and display the available comments.

This would be an amazingly helpful Widget as it would allow for Artists to avoid having to go to Kitsu to read up on the notes on their current scene but instead can have it right next to them in the DCC or pipeline.

Here's a very simple example, but this should be much prettier:

qtazu_task_comments

import datetime

from Qt import QtWidgets, QtCore, QtGui
import gazu

from qtazu.widgets import taskbreadcrumb


class TaskComments(QtWidgets.QWidget):
    def __init__(self, parent=None, task_id=None):
        super(TaskComments, self).__init__(parent)

        self._task = None

        breadcrumb = taskbreadcrumb.TaskBreadcrumb()
        comments = QtWidgets.QTextEdit()
        comments.setReadOnly(True)

        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(breadcrumb)
        layout.addWidget(comments)

        self.breadcrumb = breadcrumb
        self.comments = comments

        self.setWindowTitle("CG-Wire Comments")

        self.resize(250, 600)

        if task_id:
            self.set_task(task_id)

    def set_task(self, task_id):

        # todo: Remove force to `str`
        task_id = str(task_id)


        self._task = gazu.task.get_task(task_id)

        self.comments.clear()

        comments = gazu.task.all_comments_for_task(task_id)
        text = ""
        for comment in comments:

            if not comment["text"]:
                # Exclude empty comments for quick readability?
                # todo: do we want to do this by default? we could add a toggle to widget
                continue

            # Include readable date in comment for parsing
            date = datetime.datetime.strptime(comment["created_at"], '%Y-%m-%dT%H:%M:%S')
            date = date.strftime('%Y-%m-%d %I:%M %p')
            comment["date"] = date

            # Ensure new lines in comment text are parsed
            comment["text"] = comment["text"].replace(r"\\n", "<br>")

            html_start = """
            <b>{person[first_name]} {person[last_name]}</b> | {date}<br>
            <br>""".format(**comment)

            html_end = """
            <br><br>
            ----<br>
            <br>
            """

            self.comments.insertHtml(html_start)
            self.comments.insertPlainText(comment["text"])
            self.comments.insertHtml(html_end)

Then to use it:

# Get a specific task by names (purely to aid in trying out the example)
project = gazu.project.get_project_by_name("projectname")
sequence = gazu.shot.get_sequence_by_name(project, "sequencename")
shot = gazu.shot.get_shot_by_name(sequence, "shotname")
task = gazu.task.get_task_by_name(shot, gazu.task.get_task_type_by_name("taskname"))

# Use the example widget
widget = TaskComments(task_id=task["id"])
widget.show()

In the end the goal is to have a similar view as Kitsu presents:

kitsu_task_comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions