From d41e2bbce4ea08ffa7c8a3dfe381be271df2d56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 24 Aug 2017 10:45:56 +0200 Subject: [PATCH] Orgs: fixed "Create New Organization" button It now actually creates the new org and shows it. --- pillar/web/organizations/routes.py | 11 ++++++++--- src/templates/organizations/index.jade | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) 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 %}