Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pybossa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,13 @@ def _unauthorized(e):

@app.errorhandler(423)
def _locked(e):
short_name = request.view_args.get('short_name')
project = project_repo.get_by_shortname(short_name)
owner = project.owner.name
response = dict(template='423.html', code=423,
private_instance=app.config.get('PRIVATE_INSTANCE'),
description=LOCKED)
description=LOCKED,
owner=owner)
return handle_content_type(response)

def setup_hooks(app):
Expand Down
2 changes: 1 addition & 1 deletion pybossa/themes/default
14 changes: 12 additions & 2 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -11816,19 +11816,29 @@ def __init__(self, content):

class TestErrorHandlers(web.Helper):
@with_context
def test_locked_handler(self):
@patch('pybossa.core.project_repo.get_by_shortname')
def test_locked_handler(self, get_by_shortname):
setup_error_handlers(self.flask_app)

@self.flask_app.route("/locked")
def locked_route():
abort(423)

owner_name = "My Project Owner"
admin = UserFactory.create(admin=True, name=owner_name)
get_by_shortname.return_value = ProjectFactory.create(owner=admin)
with patch.dict(self.flask_app.config, {'PRIVATE_INSTANCE': True}):
res = self.app.get("/locked")
res_str = str(res.data)

assert res.status_code == 423
assert 'Private GIGwork' in str(res.data)
assert 'Private GIGwork' in res_str
assert owner_name in res_str

with patch.dict(self.flask_app.config, {'PRIVATE_INSTANCE': False}):
res = self.app.get("/locked")
res_str = str(res.data)

assert res.status_code == 423
assert 'Public GIGwork' in str(res.data)
assert owner_name in res_str
Loading