@@ -37,12 +37,14 @@ class RulesView(APIView):
37
37
38
38
## Routes
39
39
### GET /rules
40
- Returns a JSON array containing the server's rules:
40
+ Returns a JSON array containing the server's rules
41
+ and keywords relating to each rule.
42
+ Example response:
41
43
42
44
>>> [
43
- ... "Eat candy.",
44
- ... "Wake up at 4 AM.",
45
- ... "Take your medicine."
45
+ ... [ "Eat candy.", ["candy", "sweets"]] ,
46
+ ... [ "Wake up at 4 AM.", ["wake_up", "early", "early_bird"]] ,
47
+ ... [ "Take your medicine.", ["medicine", "health"]]
46
48
... ]
47
49
48
50
Since some of the the rules require links, this view
@@ -100,6 +102,12 @@ def _format_link(description: str, link: str, target: str) -> str:
100
102
101
103
# `format` here is the result format, we have a link format here instead.
102
104
def get (self , request , format = None ): # noqa: D102,ANN001,ANN201
105
+ """
106
+ Returns a list of our community rules coupled with their keywords.
107
+
108
+ Each item in the returned list is a tuple with the rule as first item
109
+ and a list of keywords that match that rules as second item.
110
+ """
103
111
link_format = request .query_params .get ('link_format' , 'md' )
104
112
if link_format not in ('html' , 'md' ):
105
113
raise ParseError (
@@ -124,35 +132,44 @@ def get(self, request, format=None): # noqa: D102,ANN001,ANN201
124
132
125
133
return Response ([
126
134
(
127
- f"Follow the { pydis_coc } ."
135
+ f"Follow the { pydis_coc } ." ,
136
+ ["coc" , "conduct" , "code" ]
128
137
),
129
138
(
130
- f"Follow the { discord_community_guidelines } and { discord_tos } ."
139
+ f"Follow the { discord_community_guidelines } and { discord_tos } ." ,
140
+ ["discord" , "guidelines" , "discord_tos" ]
131
141
),
132
142
(
133
- "Respect staff members and listen to their instructions."
143
+ "Respect staff members and listen to their instructions." ,
144
+ ["respect" , "staff" , "instructions" ]
134
145
),
135
146
(
136
147
"Use English to the best of your ability. "
137
- "Be polite if someone speaks English imperfectly."
148
+ "Be polite if someone speaks English imperfectly." ,
149
+ ["english" , "language" ]
138
150
),
139
151
(
140
152
"Do not provide or request help on projects that may break laws, "
141
- "breach terms of services, or are malicious or inappropriate."
153
+ "breach terms of services, or are malicious or inappropriate." ,
154
+ ["infraction" , "tos" , "breach" , "malicious" , "inappropriate" ]
142
155
),
143
156
(
144
- "Do not post unapproved advertising."
157
+ "Do not post unapproved advertising." ,
158
+ ["ad" , "ads" , "advert" , "advertising" ]
145
159
),
146
160
(
147
161
"Keep discussions relevant to the channel topic. "
148
- "Each channel's description tells you the topic."
162
+ "Each channel's description tells you the topic." ,
163
+ ["off-topic" , "topic" , "relevance" ]
149
164
),
150
165
(
151
166
"Do not help with ongoing exams. When helping with homework, "
152
- "help people learn how to do the assignment without doing it for them."
167
+ "help people learn how to do the assignment without doing it for them." ,
168
+ ["exam" , "exams" , "assignment" , "assignments" , "homework" ]
153
169
),
154
170
(
155
- "Do not offer or ask for paid work of any kind."
171
+ "Do not offer or ask for paid work of any kind." ,
172
+ ["paid" , "work" , "money" ]
156
173
),
157
174
])
158
175
0 commit comments