Orgs: fixed "Create New Organization" button

It now actually creates the new org and shows it.
This commit is contained in:
Sybren A. Stüvel 2017-08-24 10:45:56 +02:00
parent 5f607fa2cf
commit d41e2bbce4
2 changed files with 11 additions and 5 deletions

View File

@ -1,12 +1,12 @@
import logging import logging
from flask import Blueprint, render_template, request, jsonify from flask import Blueprint, render_template, request, url_for
import flask_wtf.csrf import flask_wtf.csrf
from flask_login import current_user from flask_login import current_user
import pillar.flask_extra import pillar.flask_extra
from pillar import current_app 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 pillar.web.system_util import pillar_api
from pillarsdk import Organization, User 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) 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

View File

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