Skip to content

Commit d3811f0

Browse files
committed
feat: create enum for classroom alerts
1 parent 1a5932a commit d3811f0

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

scratchattach/utils/enums.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"""
55
from __future__ import annotations
66

7-
from enum import Enum
87
from dataclasses import dataclass
9-
8+
from enum import Enum
109
from typing import Optional, Callable, Iterable
1110

1211

@@ -44,7 +43,7 @@ def apply_func(x):
4443

4544
if apply_func(_val) == value:
4645
return item_obj
47-
46+
4847
except TypeError:
4948
pass
5049

@@ -195,3 +194,40 @@ def find(cls, value, by: str = "name", apply_func: Optional[Callable] = None) ->
195194
def all_of(cls, attr_name: str = "name", apply_func: Optional[Callable] = None) -> Iterable:
196195
return super().all_of(attr_name, apply_func)
197196

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

Comments
 (0)