Skip to content

Commit

Permalink
API: Respect visibility for module and challenge listings
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Jan 10, 2024
1 parent 32baac3 commit 22a44eb
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions dojo_plugin/api/v1/dojo.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,27 @@ def post(self):
class GetDojoModules(Resource):
@dojo_route
def get(self, dojo):
modules = [{'id': module.id,
'module_index': module.module_index,
'name': module.name,
'description': module.description,
} for module in dojo.modules]

modules = [
dict(id=module.id,
module_index=module.module_index,
name=module.name,
description=module.description)
for module in dojo.modules if module.visible()
]
return {"success": True, "modules": modules}


@dojo_namespace.route("/<dojo>/<module>/challenges")
class GetDojoModuleChallenges(Resource):
@dojo_route
def get(self, dojo, module):
challenges = [{'id': challenge.id,
'challenge_id': challenge.challenge_id,
'module_index': challenge.module_index,
'challenge_index': challenge.challenge_index,
'name': challenge.name,
'description': challenge.description,
} for challenge in module.visible_challenges()]

challenges = [
dict(id=challenge.id,
challenge_id=challenge.challenge_id,
module_index=challenge.module_index,
challenge_index=challenge.challenge_index,
name=challenge.name,
description=challenge.description)
for challenge in module.visible_challenges()
]
return {"success": True, "challenges": challenges}

0 comments on commit 22a44eb

Please sign in to comment.