Skip to content

Commit 8da0ffb

Browse files
Acception and rejection of user applications (#112)
* Added the accept_application function. It's broken * update: accept_application * Fixed the acception of applications. * Added the denial functionality.
1 parent 88482aa commit 8da0ffb

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

pythorhead/admin.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,35 @@ def list_applications(
2222
dict: list applications
2323
"""
2424
params: dict[str, Any] = {key: value for key, value in locals().items() if value is not None and key != "self"}
25-
return self._requestor.api(Request.GET, "/admin/registration_application/list", params=params)
25+
return self._requestor.api(Request.GET, "/admin/registration_application/list", params=params)
26+
27+
def process_application(
28+
self,
29+
user_id: int,
30+
approve: Optional[bool] = True,
31+
deny_reason: Optional[str] = None
32+
) -> Optional[dict]:
33+
"""
34+
Accept or deny a specific user application. Note user must be admin.
35+
36+
Args:
37+
user_id (int): The user id.
38+
approve (Optional[bool], optional): Defaults to True.
39+
deny_reason (Optional[str]): Defaults to None.
40+
Returns:
41+
Optional[dict]: application data if successful
42+
"""
43+
44+
process_application = {
45+
"id": user_id,
46+
"approve": approve,
47+
}
48+
49+
if deny_reason is not None:
50+
process_application["deny_reason"] = deny_reason
51+
52+
return self._requestor.api(
53+
Request.PUT,
54+
"/admin/registration_application/approve",
55+
json=process_application
56+
)

0 commit comments

Comments
 (0)