|
4 | 4 | """ |
5 | 5 | from __future__ import annotations |
6 | 6 |
|
7 | | -from enum import Enum |
8 | 7 | from dataclasses import dataclass |
9 | | - |
| 8 | +from enum import Enum |
10 | 9 | from typing import Optional, Callable, Iterable |
11 | 10 |
|
12 | 11 |
|
@@ -44,7 +43,7 @@ def apply_func(x): |
44 | 43 |
|
45 | 44 | if apply_func(_val) == value: |
46 | 45 | return item_obj |
47 | | - |
| 46 | + |
48 | 47 | except TypeError: |
49 | 48 | pass |
50 | 49 |
|
@@ -195,3 +194,40 @@ def find(cls, value, by: str = "name", apply_func: Optional[Callable] = None) -> |
195 | 194 | def all_of(cls, attr_name: str = "name", apply_func: Optional[Callable] = None) -> Iterable: |
196 | 195 | return super().all_of(attr_name, apply_func) |
197 | 196 |
|
| 197 | + |
| 198 | +@dataclass |
| 199 | +class AlertType: |
| 200 | + id: int |
| 201 | + message: str |
| 202 | + |
| 203 | + |
| 204 | +class AlertTypes(_EnumWrapper): |
| 205 | + # Reference: https://github.com/TimMcCool/scratchattach/issues/304#issuecomment-2800110811 |
| 206 | + # NOTE: THE TEXT WITHIN THE BRACES HERE MATTERS! IF YOU WANT TO CHANGE IT, MAKE SURE TO EDIT `site.alert.EducatorAlert`! |
| 207 | + ban = AlertType(0, "{username} was banned.") |
| 208 | + unban = AlertType(1, "{username} was unbanned.") |
| 209 | + excluded_from_homepage = AlertType(2, "{username} was excluded from homepage") |
| 210 | + excluded_from_homepage2 = AlertType(3, "{username} was excluded from homepage") # for some reason there are duplicates |
| 211 | + notified = AlertType(4, "{username} was notified by a Scratch Administrator. Notification type: {notification_type}") |
| 212 | + autoban = AlertType(5, "{username} was banned automatically") |
| 213 | + autoremoved = AlertType(6, "{project} by {username} was removed automatically") |
| 214 | + project_censored2 = AlertType(7, "{project} by {username} was censored.") # <empty #7> |
| 215 | + project_censored = AlertType(20, "{project} by {username} was censored.") |
| 216 | + project_uncensored = AlertType(8, "{project} by {username} was uncensored.") |
| 217 | + project_reviewed2 = AlertType(9, "{project} by {username} was reviewed by a Scratch Administrator.") # <empty #9> |
| 218 | + project_reviewed = AlertType(10, "{project} by {username} was reviewed by a Scratch Administrator.") |
| 219 | + project_deleted = AlertType(11, "{project} by {username} was deleted by a Scratch Administrator.") |
| 220 | + user_deleted2 = AlertType(12, "{username} was deleted by a Scratch Administrator") # <empty #12> |
| 221 | + user_deleted = AlertType(17, "{username} was deleted by a Scratch Administrator") |
| 222 | + studio_reviewed2 = AlertType(13, "{studio} was reviewed by a Scratch Administrator.") # <empty #13> |
| 223 | + studio_reviewed = AlertType(14, "{studio} was reviewed by a Scratch Administrator.") |
| 224 | + studio_deleted = AlertType(15, "{studio} was deleted by a Scratch Administrator.") |
| 225 | + email_confirm2 = AlertType(16, "The email address of {username} was confirmed by a Scratch Administrator") # <empty #16> |
| 226 | + email_confirm = AlertType(18, "The email address of {username} was confirmed by a Scratch Administrator") # no '.' in HTML |
| 227 | + email_unconfirm = AlertType(19, "The email address of {username} was set as not confirmed by a Scratch Administrator") |
| 228 | + automute = AlertType(22, "{username} was automatically muted by our comment filters. The comment they tried to post was: {comment}") |
| 229 | + default = AlertType(-1, "{username} had an admin action performed.") # default case |
| 230 | + |
| 231 | + @classmethod |
| 232 | + def find(cls, value, by: str = "id", apply_func: Optional[Callable] = None) -> AlertType: |
| 233 | + return super().find(value, by, apply_func) |
0 commit comments