added the method_routing_id and fixed the create method issue

This commit is contained in:
hongwei1 2019-09-17 12:33:38 +02:00
parent 074f4c09e7
commit 351553729c
3 changed files with 28 additions and 15 deletions

View File

@ -2,7 +2,7 @@ $(document).ready(function($) {
$('.runner button.forSave').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
method_routing_id = $(runner).find('.method_routing_id').val();
method_routing_id = $(runner).find('.method_routing_id').text();
method_name = $(runner).find('.method_name').text();
connector_name = $(runner).find('.connector_name').val();
bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val();
@ -24,7 +24,7 @@ $(document).ready(function($) {
$('.runner button.forDelete').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
method_routing_id = $(runner).find('.method_routing_id').val();
method_routing_id = $(runner).find('.method_routing_id').text();
$.post('methodrouting/delete/method', {
'method_routing_id': method_routing_id
}, function (response) {

View File

@ -19,22 +19,24 @@
<div class="col-xs-12 col-sm-2">
<label class="form-group">Connector Name:</label> <br>
</div>
<div class="col-sm-12 col-sm-2">
<label class="form-group">Bank Id Pattern:</label> <br>
<div class="col-sm-12 col-sm-1">
<label class="form-group">Pattern:</label> <br>
</div>
<div class="col-sm-12 col-sm-2">
<label class="form-group">Is Bank Id Exact Match:</label> <br>
<div class="col-sm-12 col-sm-1">
<label class="form-group">Is Match:</label> <br>
</div>
<div class="col-sm-12 col-sm-2">
<label class="form-group">Parameters:</label> <br>
</div>
<div class="col-sm-12 col-sm-2">
<label class="form-group">Method ID::</label> <br>
</div>
</div>
<form method="post">
{% csrf_token %}
{% for method_routing in method_routings %}
<div class="runner">
<div class="row">
<input type="hidden", class="method_routing_id", value="{{ method_routing.method_routing_id }}">
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1"><strong
class="method_name">{{ method_routing.method_name }}</strong></div>
@ -64,11 +66,11 @@
{% endif %}
</select>
</div>
<div class="col-xs-12 col-sm-2">
<div class="col-xs-12 col-sm-1">
<textarea class="form-control" rows="1"
name="bank_id_pattern">{{ method_routing.bank_id_pattern }}</textarea>
</div>
<div class="col-xs-12 col-sm-2" align="center">
<div class="col-xs-12 col-sm-1" align="center">
<select class="is_bank_id_exact_match form-control">
{% if method_routing.is_bank_id_exact_match == False %}
<option value="False">False</option>
@ -83,6 +85,10 @@
<textarea cols="40" rows="1" class="form-control"
name="parameters">{{ method_routing.parameters }}</textarea>
</div>
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1"><strong
class="method_routing_id">{{ method_routing.method_routing_id }}</strong></div>
</div>
<div class="col-sm-12 col-sm-2">
<div class="form-group">
<button class="btn btn-primary btn-green forSave">Save</button><span style="display: none;margin-left: 5px;background-color:#00cc00">saved.</span>

View File

@ -63,13 +63,20 @@ def methodrouting_save(request):
'method_routing_id':method_routing_id
}
if method_routing_id!="":
method_routing_id = "/"+method_routing_id
api = API(request.session.get('obp'))
urlpath = '/management/method_routings{}'.format(method_routing_id)
result = api.put(urlpath, payload=payload)
return result
try:
if(""==method_routing_id): # if method_routing_id=="". we will create a new method routing .
urlpath = '/management/method_routings'
result = api.post(urlpath, payload=payload)
else: # if method_routing_id not empty. we will update the current method routing ..
urlpath = '/management/method_routings/{}'.format(method_routing_id)
result = api.put(urlpath, payload=payload)
except APIError as err:
exception_handle(Exception("OBP-API server is not running or do not response properly. "
"Please check OBP-API server. Details: " + str(err)))
if 'code' in result and result['code'] >= 400:
exception_handle(Exception(result['message']))
@exception_handle
@csrf_exempt