Skip to content

Commit f37eb05

Browse files
feat: enable public project view (#549)
1 parent 3609ae5 commit f37eb05

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

api_docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,10 @@ paths:
25552555
name: project_id
25562556
required: true
25572557
type: string
2558+
- in: query
2559+
name: public_view
2560+
type: string
2561+
description: True if project is being viewed by other users
25582562

25592563
responses:
25602564
200:

app/controllers/project.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ def get(self, project_id):
363363
current_user_id = get_jwt_identity()
364364
current_user_roles = get_jwt_claims()['roles']
365365

366+
public_view = request.args.get('public_view', False)
367+
366368
project_schema = ProjectSchema()
367369

368370
project = Project.get_by_id(project_id)
@@ -373,9 +375,16 @@ def get(self, project_id):
373375
message=f'project {project_id} not found'
374376
), 404
375377

378+
if public_view:
379+
project_data, errors = project_schema.dumps(project)
380+
if errors:
381+
return dict(status='fail', message=errors), 500
382+
return dict(status='success', data=dict(project=json.loads(project_data))), 200
383+
376384
if not is_owner_or_admin(project, current_user_id, current_user_roles):
377385
if not is_authorised_project_user(project, current_user_id, 'member'):
378386
return dict(status='fail', message='unauthorised'), 403
387+
379388

380389
project_data, errors = project_schema.dumps(project)
381390
if errors:

0 commit comments

Comments
 (0)