Skip to content

data_models

ActivityData dataclass

Simple dataclass to cache representation data.

Source code in client/ayon_ui_qt/data_models.py
167
168
169
170
171
172
173
174
175
176
177
178
179
@dataclass
class ActivityData:
    """Simple dataclass to cache representation data."""

    representation_id: str = ""
    hash: int = field(init=False)
    activity_list: list[
        CommentModel | VersionPublishModel | StatusChangeModel
    ] = field(default_factory=list)

    def __post_init__(self):
        """Compute the hash of the activity list."""
        self.hash = hash(tuple(self.activity_list))

__post_init__()

Compute the hash of the activity list.

Source code in client/ayon_ui_qt/data_models.py
177
178
179
def __post_init__(self):
    """Compute the hash of the activity list."""
    self.hash = hash(tuple(self.activity_list))

CommentCategory dataclass

Model for powerpack activity_categories settings

Source code in client/ayon_ui_qt/data_models.py
200
201
202
203
204
205
206
@dataclass
class CommentCategory:
    """Model for powerpack `activity_categories` settings"""

    name: str
    color: str
    access: dict[str, Any]

CommentModel dataclass

Source code in client/ayon_ui_qt/data_models.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@dataclass(unsafe_hash=True)
class CommentModel:
    activity_id: str = ""
    user_full_name: str = ""
    user_name: str = ""
    user_src: str = ""
    comment: str = ""  # type: ignore
    category: str = ""
    category_color: str = ""
    comment_date: str = ""
    short_date: str = field(init=False, hash=False)
    type: ActivityCategory = field(
        init=False, default=ActivityCategory.COMMENT, hash=False
    )
    files: list[FileModel] = field(default_factory=list, hash=False)
    annotations: list[AnnotationModel] = field(
        default_factory=list, hash=False
    )
    _comment: str = field(init=False, repr=False)

    def __post_init__(self):
        """Set the date if not set and compute the short date."""
        if not self.comment_date:
            self.comment_date = datetime.now(timezone.utc).isoformat()

        self.short_date = short_date(self.comment_date)

    @property
    def comment(self):  # noqa: F811
        return self._comment

    @comment.setter
    def comment(self, value: str):
        """Check if the comment contains a checklist."""
        if re.search(RE_HAS_CHECKLIST, str(value)):
            self.type = ActivityCategory.COMMENT | ActivityCategory.CHECKLIST
        self._comment = value

__post_init__()

Set the date if not set and compute the short date.

Source code in client/ayon_ui_qt/data_models.py
143
144
145
146
147
148
def __post_init__(self):
    """Set the date if not set and compute the short date."""
    if not self.comment_date:
        self.comment_date = datetime.now(timezone.utc).isoformat()

    self.short_date = short_date(self.comment_date)

FileModel dataclass

Model for activity attached files.

Attachments could be images, there could be also preview available for them.

Source code in client/ayon_ui_qt/data_models.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@dataclass
class FileModel:
    """Model for activity attached files.

    Attachments could be images, there could be also preview available for
    them.
    """

    id: str
    mime: str
    local_path: str = ""
    thumb_local_path: str = ""
    frame: int = 0
    start_frame: int = 0  # for sequences, to compute the actual frame number

ProjectData dataclass

Model to pass project data - anatomy, users, teams

Source code in client/ayon_ui_qt/data_models.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
@dataclass
class ProjectData:
    """Model to pass project data - anatomy, users, teams"""

    project_name: str
    users: List[User]
    teams: List[Team]
    anatomy: dict[str, Any]
    comment_category: List[CommentCategory]
    current_user: Optional[User]

    @staticmethod
    def not_set():
        ns = "PROJECT NOT SET"
        return ProjectData(
            project_name=ns,
            users=[],
            teams=[],
            anatomy={},
            comment_category=[],
            current_user=None,
        )

User dataclass

Data model for user

Source code in client/ayon_ui_qt/data_models.py
182
183
184
185
186
187
188
189
190
191
@dataclass
class User:
    """Data model for user"""

    name: str
    short_name: str
    full_name: str
    email: str
    avatar_url: str = ""
    avatar_local_path: str = ""

VersionData dataclass

Model to pass enhanced version data

Source code in client/ayon_ui_qt/data_models.py
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
@dataclass
class VersionData:
    """Model to pass enhanced version data"""

    id: str
    name: str
    author: str
    tags: list[str]
    status: str
    product_name: str
    task_name: str
    priority: str
    folder_path: str
    assignees: list[str]
    attrib: dict[str, str]
    thumbnail_id: str = ""
    thumbnail_local_path: str = ""

    @staticmethod
    def not_set():
        ns = "VERSION NOT SET"
        return VersionData(
            id=ns,
            name=ns,
            author=ns,
            tags=[],
            status=ns,
            product_name=ns,
            task_name=ns,
            priority=ns,
            folder_path=ns,
            assignees=[],
            attrib={},
            thumbnail_id="",
            thumbnail_local_path="",
        )