Skip to content

Commit 6601420

Browse files
authored
Merge pull request JdeRobot#3635 from Kunal-Somani/docs/add-docstrings-to-views
docs(academy): add inline docstrings to all view functions in views.py
2 parents dd54612 + 8f0b5e4 commit 6601420

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

academy/views.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
@csrf_exempt
2929
@api_view(["GET"])
3030
def save_exercise_db(request):
31+
"""
32+
Trigger a PostgreSQL dump of exercise-related tables to the repository.
33+
34+
Dumps tables: exercises, exercises_universes, exercises_tools.
35+
Output is written to RoboticsAcademy/database/exercises/db.sql.
36+
"""
3137

3238
subprocess.Popen(
3339
[
@@ -45,6 +51,12 @@ def save_exercise_db(request):
4551
@csrf_exempt
4652
@api_view(["GET"])
4753
def save_universe_db(request):
54+
"""
55+
Trigger a PostgreSQL dump of universe-related tables to a SQL file.
56+
57+
Dumps tables: universes, worlds, robots, tools.
58+
Output is written to /universes.sql inside the container.
59+
"""
4860

4961
subprocess.Popen(
5062
[
@@ -139,6 +151,11 @@ def get_exercise_list(fal, request):
139151

140152
@error_wrapper("GET", ["project", "language"])
141153
def get_helper_file_list(fal, request):
154+
"""
155+
Return the list of helper files for a given exercise and language.
156+
157+
Query params: project (str), language (str).
158+
"""
142159
project = request.GET.get("project")
143160
language = request.GET.get("language")
144161

@@ -150,6 +167,11 @@ def get_helper_file_list(fal, request):
150167

151168
@error_wrapper("GET", ["project", "language", "filename"])
152169
def get_helper_file(fal, request):
170+
"""
171+
Return the content of a specific helper file for an exercise.
172+
173+
Query params: project (str), language (str), filename (str).
174+
"""
153175
project = request.GET.get("project")
154176
language = request.GET.get("language")
155177
filename = request.GET.get("filename", None)
@@ -163,6 +185,11 @@ def get_helper_file(fal, request):
163185

164186
@error_wrapper("GET", ["project"])
165187
def get_file_list(fal, request):
188+
"""
189+
Return the list of user files for a given exercise project.
190+
191+
Query params: project (str).
192+
"""
166193
project = request.GET.get("project")
167194

168195
base_group = "Code"
@@ -176,6 +203,11 @@ def get_file_list(fal, request):
176203

177204
@error_wrapper("POST", ["project_id", ("location", -1), "file_name"])
178205
def create_file(fal, request):
206+
"""
207+
Create a new empty file inside the exercise project directory.
208+
209+
POST params: project_id (str), location (str), file_name (str).
210+
"""
179211
project_id = request.data.get("project_id")
180212
location = request.data.get("location")
181213
filename = request.data.get("file_name")
@@ -193,6 +225,11 @@ def create_file(fal, request):
193225

194226
@error_wrapper("POST", ["project_id", ("location", -1), "folder_name"])
195227
def create_folder(fal, request):
228+
"""
229+
Create a new folder inside the exercise project directory.
230+
231+
POST params: project_id (str), location (str), folder_name (str).
232+
"""
196233
project_id = request.data.get("project_id")
197234
location = request.data.get("location")
198235
folder_name = request.data.get("folder_name")
@@ -210,6 +247,11 @@ def create_folder(fal, request):
210247

211248
@error_wrapper("POST", ["project_id", "path", "rename_to"])
212249
def rename_file(fal, request):
250+
"""
251+
Rename a file inside the exercise project directory.
252+
253+
POST params: project_id (str), path (str), rename_to (str).
254+
"""
213255
project_id = request.data.get("project_id")
214256
path = request.data.get("path")
215257
rename_path = request.data.get("rename_to")
@@ -231,6 +273,11 @@ def rename_file(fal, request):
231273

232274
@error_wrapper("POST", ["project_id", "path", "rename_to"])
233275
def rename_folder(fal, request):
276+
"""
277+
Rename a folder inside the exercise project directory.
278+
279+
POST params: project_id (str), path (str), rename_to (str).
280+
"""
234281
project_id = request.data.get("project_id")
235282
path = request.data.get("path")
236283
rename_path = request.data.get("rename_to")
@@ -252,6 +299,11 @@ def rename_folder(fal, request):
252299

253300
@error_wrapper("POST", ["project_id", "path"])
254301
def delete_file(fal, request):
302+
"""
303+
Delete a file from the exercise project directory.
304+
305+
POST params: project_id (str), path (str).
306+
"""
255307
project_id = request.data.get("project_id")
256308
path = request.data.get("path")
257309

@@ -265,6 +317,11 @@ def delete_file(fal, request):
265317

266318
@error_wrapper("POST", ["project_id", "path"])
267319
def delete_folder(fal, request):
320+
"""
321+
Delete a folder and its contents from the exercise project directory.
322+
323+
POST params: project_id (str), path (str).
324+
"""
268325
project_id = request.data.get("project_id")
269326
path = request.data.get("path")
270327

@@ -278,6 +335,12 @@ def delete_folder(fal, request):
278335

279336
@error_wrapper("GET", ["project", "filename"])
280337
def get_file(fal, request):
338+
"""
339+
Return the content of a file from the exercise project directory.
340+
341+
Query params: project (str), filename (str), binary (bool, optional).
342+
Returns base64-encoded content if binary=True.
343+
"""
281344
project_id = request.GET.get("project", None)
282345
filename = request.GET.get("filename", None)
283346

@@ -300,6 +363,11 @@ def get_file(fal, request):
300363

301364
@error_wrapper("POST", ["project", "filename", ("content", -1)])
302365
def save_file(fal, request):
366+
"""
367+
Save content to a file in the exercise project directory.
368+
369+
POST params: project (str), filename (str), content (str).
370+
"""
303371
project_id = request.data.get("project")
304372
filename = request.data.get("filename")
305373
content = request.data.get("content")
@@ -415,6 +483,11 @@ def get_docker_universe_data(fal, request):
415483

416484
@error_wrapper("POST", ["project_id", "file_name", ("location", -1), "content"])
417485
def upload(fal, request):
486+
"""
487+
Upload a binary file (e.g. ONNX model) to the exercise project directory.
488+
489+
POST params: project_id (str), file_name (str), location (str), content (base64 str).
490+
"""
418491
# Get the name and the zip file from the request
419492
project_id = request.data.get("project_id")
420493
file_name = request.data.get("file_name")

0 commit comments

Comments
 (0)