Skip to content

Commit

Permalink
Merge pull request OpenBankProject#25 from Jianwei-Tesobe/master
Browse files Browse the repository at this point in the history
after clicking Save button, reload the window
  • Loading branch information
simonredfern authored Dec 21, 2018
2 parents 37b2124 + 0ab62c6 commit 4c0d526
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apitester/apitester/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

Expand Down Expand Up @@ -211,3 +210,4 @@

# Settings here might use parts overwritten in local settings
API_ROOT = API_HOST + API_BASE_PATH + API_VERSION
BASE_URL='http://127.0.0.1:8000'
5 changes: 3 additions & 2 deletions apitester/obp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.contrib.auth.models import User
from django.urls import reverse
from django.views.generic import RedirectView, FormView
from django.conf import settings

from .api import API, APIError
from .authenticator import AuthenticatorError
Expand Down Expand Up @@ -50,8 +51,8 @@ def get_callback_uri(self, request):
Gets the callback URI to where the user shall be returned after
initiation at OAuth server
"""
base_url = '{}://{}'.format(
request.scheme, request.environ['HTTP_HOST'])
#base_url = '{}://{}'.format(request.scheme, request.environ['HTTP_HOST'])
base_url = settings.BASE_URL
uri = base_url + reverse('oauth-authorize')
if 'next' in request.GET:
uri = '{}?next={}'.format(uri, request.GET['next'])
Expand Down
2 changes: 1 addition & 1 deletion apitester/runtests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ class Meta:
verbose_name_plural = 'Test Profile Operation'

def __str__(self):
return self.name
return "profile_id:\t{}\noperationid:\t{}\n".format(self.profile_id,self.operation_id)
4 changes: 4 additions & 0 deletions apitester/runtests/static/runtests/js/runtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ $(function() {
runTest(runner);
});
$('.runner button.forSave').click(function() {

var t = $(this)
var runner = $(this).parent().parent().parent();
jsonBody = $(runner).find('textarea').val();
operationId = $(runner).find('input[type="hidden"]').val();
order = $(runner).find('input[name="order"]').val();
urlpath = $(runner).find('input[name="urlpath"]').val();

$.post('/runtests/save/json_body', {
'json_body': jsonBody,
'operation_id': operationId,
Expand All @@ -66,6 +68,8 @@ $(function() {
}, function (response) {
t.next().show().fadeOut(1000);
});

setTimeout("window.location.reload()",1000);
});

$('#checkNone').click(function() {
Expand Down
8 changes: 6 additions & 2 deletions apitester/runtests/templates/runtests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ <h2>{{ config.name }}</h2>
</div>
<div class="col-xs-3">
{% if call.method == "post" or call.method == 'put' %}
<textarea class="form-control" name="" id="" cols="30" rows="5">{{ call.params }}</textarea>
<textarea class="form-control" name="" id="" cols="30" rows="5">
{{call.params}}
</textarea>
{% endif %}
</div>
<div class="col-xs-1"><input class="form-control" type="text" name="order" size="1" value="{{ call.order }}" /></div>
<div class="col-xs-1"><input class="form-control" type="text" name="order" size="1" value="{{ call.order }}" /></div>
<div class="col-xs-1">{{ call.method |upper}}</div>

<div class="col-xs-2 col-sm-1">
<button class="btn btn-default forTest">Test</button>
<button class="btn btn-success forSave">Save</button><span style="display: none;margin-left: 5px;background-color:#00cc00">saved.</span>
Expand Down
3 changes: 2 additions & 1 deletion apitester/runtests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def get_context_data(self, **kwargs):
call = self.get_post_or_update('delete', testconfigs, testconfig_pk, path, data, swagger)
calls.append(call)

calls = sorted(calls, key=lambda call: call['order'], reverse=True)
calls = sorted(calls, key=lambda item: item['order'], reverse=False)

context.update({
'calls': calls,
'testconfigs': testconfigs,
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Django==1.11.7
#Django==1.11.7
Django==2.0.7
psycopg2==2.7.3.1
oauthlib==2.0.0
requests==2.11.1
Expand Down

0 comments on commit 4c0d526

Please sign in to comment.