diff --git a/pillar/web/organizations/routes.py b/pillar/web/organizations/routes.py index 012e0797..0c4e5aa9 100644 --- a/pillar/web/organizations/routes.py +++ b/pillar/web/organizations/routes.py @@ -1,12 +1,12 @@ import logging -from flask import Blueprint, render_template, request, jsonify +from flask import Blueprint, render_template, request, url_for import flask_wtf.csrf from flask_login import current_user import pillar.flask_extra from pillar import current_app -from pillar.api.utils import authorization, str2id, gravatar +from pillar.api.utils import authorization, str2id, gravatar, jsonify from pillar.web.system_util import pillar_api from pillarsdk import Organization, User @@ -83,4 +83,9 @@ def create_new(): org_doc = current_app.org_manager.create_new_org(name, user_id, seat_count) - return jsonify({'_id': org_doc['_id']}), 201 + org_id = str(org_doc['_id']) + url = url_for('.view_embed', organization_id=org_id) + resp = jsonify({'_id': org_id, 'location': url}) + resp.headers['Location'] = url + + return resp, 201 diff --git a/src/templates/organizations/index.jade b/src/templates/organizations/index.jade index 580b5ac6..a3d29055 100644 --- a/src/templates/organizations/index.jade +++ b/src/templates/organizations/index.jade @@ -158,11 +158,11 @@ script. seat_count: 1, } ) - .done(function() { + .done(function(result) { var $p = $('

').text('organization created, reloading list.') $('#create_organization_result_panel').html($p); - window.location.reload(); + window.location.href = result.location; }) .fail(function(err) { var msg = xhrErrorResponseMessage(err); @@ -178,6 +178,7 @@ script. }) }) ; + return false; } {% endif %} | {% endblock %}