feature get consumer key from settings for direct login

This commit is contained in:
Reena_Aheer 2022-04-18 12:40:45 +02:00
parent d74836200d
commit 87aee60412
9 changed files with 300 additions and 340 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ apimanager/apimanager/local_settings.py
API-Manager.iml
apimanager/.DS_Store
venv
.env

1
apimanager/.env Normal file
View File

@ -0,0 +1 @@
OAUTH_CONSUMER_KEY = dmi4bhpdjtsjka5ed5a32wawitwwfftm4xoiksnu

View File

@ -29,6 +29,7 @@ class CreateAtmForm(forms.Form):
),
choices=[],
)
name = forms.CharField(
label='Name',
widget=forms.TextInput(
@ -39,6 +40,7 @@ class CreateAtmForm(forms.Form):
),
required=True
)
address = forms.CharField(
label='Address',
widget=forms.Textarea(
@ -103,16 +105,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
"""drive_up = forms.CharField(
label='Drive Up',
widget=forms.Textarea(
attrs={
'placeholder': 'None', # noqa
'class': 'form-control',
}
),
required=False,
)"""
located_at = forms.CharField(
label='ATM location',
widget=forms.TextInput(
@ -123,6 +116,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
is_accessible = forms.ChoiceField(
label='is accessible',
widget=forms.Select(
@ -132,6 +126,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
accessibleFeatures = forms.CharField(
label='Accessible Features',
widget=forms.TextInput(
@ -142,6 +137,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
services = forms.CharField(
label='Services',
widget=forms.TextInput(
@ -152,6 +148,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
more_info = forms.CharField(
label='More information',
widget=forms.TextInput(
@ -172,6 +169,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
notes = forms.ChoiceField(
label='Write Notes',
widget=forms.Select(
@ -181,6 +179,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
location_categories = forms.ChoiceField(
label='Write location Category',
widget=forms.Select(
@ -190,6 +189,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
minimum_withdrawal = forms.CharField(
label='Minimum Withdrawal',
widget=forms.TextInput(
@ -200,6 +200,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
site_name = forms.CharField(
label='Site Name',
widget=forms.TextInput(
@ -210,6 +211,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
branch_identification = forms.CharField(
label='Branch Identification',
widget=forms.TextInput(
@ -220,6 +222,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
site_identification = forms.CharField(
label='Site Identification',
widget=forms.TextInput(
@ -251,6 +254,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
has_deposit_capability = forms.ChoiceField(
label='Deposit Capabilities',
widget=forms.Select(
@ -260,6 +264,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
cash_withdrawal_national_fee = forms.CharField(
label='Cash Withdrawal National fee',
widget=forms.TextInput(
@ -270,6 +275,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
cash_withdrawal_international_fee = forms.CharField(
label='Cash Withdrawal international fee',
widget=forms.TextInput(
@ -280,6 +286,7 @@ class CreateAtmForm(forms.Form):
),
required=False,
)
balance_inquiry_fee = forms.CharField(
label='Balance Inquiry Fee',
widget=forms.TextInput(
@ -291,7 +298,6 @@ class CreateAtmForm(forms.Form):
required=False,
)
def __init__(self, *args, **kwargs):
kwargs.setdefault('label_suffix', '')
super(CreateAtmForm, self).__init__(*args, **kwargs)

View File

@ -195,7 +195,7 @@
</div>
</div>
</div>
<div class="row">
<div class="row">
<div class="col-xs-12 col-sm-6">
{% if form.address.errors %}
<div class="alert alert-danger">{{ form.address.errors }}</div>{% endif %}
@ -210,21 +210,17 @@
{{ form.lobby.label_tag }} {{ form.lobby }}
</div>
</div>
</div>
<div class="row">
</div>
<div class="row">
<div class="col-sm-12 hidden-xs">
<div class="form-group">
<button type="submit" class="btn btn-primary btn-green">Add</button>
</div>
</div>
</div>
</form>
</div>
</form>
<div class="table-responsive">
<div class="table-responsive">
<table class="table table-hover tablesorter" id="atms-list" aria-describedby="atms list">
<thead>
<th scope="col">ATM Id</th>
@ -284,7 +280,7 @@
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %}
<link href="{% static 'atms/css/atms.css' %}" rel="stylesheet"> {% endblock extracss %}

View File

@ -1,165 +1,166 @@
{% extends 'base.html' %}
{% load static %}
{% block page_title %}{{ block.super }} / Atms{% endblock page_title %}
{% block content %}
{% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.super }} / Atms{% endblock page_title %} {% block content %}
<div id="atms">
<h1>Update atm</h1>
<h2>{{ bank_id }} : {{ atm_id }}</h2>
<form method="post">
{% csrf_token %}
{% if form.non_field_errors %}
{% csrf_token %} {% if form.non_field_errors %}
<div class="alert alert-danger">
{{ form.non_field_errors }}
</div>
{% endif %}
<div class="row" style="display: None">
<div class="col-xs-12 col-sm-4">
{% if form.bank_id.errors %}<div class="alert alert-danger">{{ form.bank_id.errors }}</div>{% endif %}
{% if form.bank_id.errors %}
<div class="alert alert-danger">{{ form.bank_id.errors }}</div>{% endif %}
<div class="form-group">
{{ form.bank_id.label_tag }}
{{ form.bank_id }}
{{ form.bank_id.label_tag }} {{ form.bank_id }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.atm_id.errors %}<div class="alert alert-danger">{{ form.atm_id.errors }}</div>{% endif %}
{% if form.atm_id.errors %}
<div class="alert alert-danger">{{ form.atm_id.errors }}</div>{% endif %}
<div class="form-group">
{{ form.atm_id.label_tag }}
{{ form.atm_id }}
{{ form.atm_id.label_tag }} {{ form.atm_id }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.name.errors %}<div class="alert alert-danger">{{ form.name.errors }}</div>{% endif %}
{% if form.name.errors %}
<div class="alert alert-danger">{{ form.name.errors }}</div>{% endif %}
<div class="form-group">
{{ form.name.label_tag }}
{{ form.name }}
{{ form.name.label_tag }} {{ form.name }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.location_latitude.errors %}<div class="alert alert-danger">{{ form.location_latitude.errors }}</div>{% endif %}
{% if form.location_latitude.errors %}
<div class="alert alert-danger">{{ form.location_latitude.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.location_latitude.label_tag }}
{{ form.location_latitude }}
{{ form.location_latitude.label_tag }} {{ form.location_latitude }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.location_longitude.errors %}<div class="alert alert-danger">{{ form.location_longitude.errors }}</div>{% endif %}
{% if form.location_longitude.errors %}
<div class="alert alert-danger">{{ form.location_longitude.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.location_longitude.label_tag }}
{{ form.location_longitude }}
{{ form.location_longitude.label_tag }} {{ form.location_longitude }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.meta_license_id.errors %}<div class="alert alert-danger">{{ form.meta_license_id.errors }}</div>{% endif %}
{% if form.meta_license_id.errors %}
<div class="alert alert-danger">{{ form.meta_license_id.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.meta_license_id.label_tag }}
{{ form.meta_license_id }}
{{ form.meta_license_id.label_tag }} {{ form.meta_license_id }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.meta_license_name.errors %}<div class="alert alert-danger">{{ form.meta_license_name.errors }}</div>{% endif %}
{% if form.meta_license_name.errors %}
<div class="alert alert-danger">{{ form.meta_license_name.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.meta_license_name.label_tag }}
{{ form.meta_license_name }}
{{ form.meta_license_name.label_tag }} {{ form.meta_license_name }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.accessibleFeatures.errors %}<div class="alert alert-danger">{{ form.accessibleFeatures.errors }}</div>{% endif %}
{% if form.accessibleFeatures.errors %}
<div class="alert alert-danger">{{ form.accessibleFeatures.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.accessibleFeatures.label_tag }}
{{ form.accessibleFeatures }}
{{ form.accessibleFeatures.label_tag }} {{ form.accessibleFeatures }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.atm_routing_scheme.errors %}<div class="alert alert-danger">{{ form.atm_routing_scheme.errors }}</div>{% endif %}
{% if form.atm_routing_scheme.errors %}
<div class="alert alert-danger">{{ form.atm_routing_scheme.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.atm_routing_scheme.label_tag }}
{{ form.atm_routing_scheme }}
{{ form.atm_routing_scheme.label_tag }} {{ form.atm_routing_scheme }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.atm_routing_address.errors %}<div class="alert alert-danger">{{ form.branch_routing_address.errors }}</div>{% endif %}
{% if form.atm_routing_address.errors %}
<div class="alert alert-danger">{{ form.branch_routing_address.errors }}</div>{% endif %}
<div class="form-group">
{{ form.atm_routing_address.label_tag }}
{{ form.atm_routing_address }}
{{ form.atm_routing_address.label_tag }} {{ form.atm_routing_address }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.is_accessible.errors %}<div class="alert alert-danger">{{ form.is_accessible.errors }}</div>{% endif %}
{% if form.is_accessible.errors %}
<div class="alert alert-danger">{{ form.is_accessible.errors }}</div>
{% endif %}
<div class="form-group">
{{ form.is_accessible.label_tag }}
{{ form.is_accessible }}
{{ form.is_accessible.label_tag }} {{ form.is_accessible }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.services.errors %}<div class="alert alert-danger">{{ form.services.errors }}</div>{% endif %}
{% if form.services.errors %}
<div class="alert alert-danger">{{ form.services.errors }}</div>{% endif %}
<div class="form-group">
{{ form.services.label_tag }}
{{ form.services }}
{{ form.services.label_tag }} {{ form.services }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.more_info.errors %}<div class="alert alert-danger">{{ form.more_info.errors }}</div>{% endif %}
{% if form.more_info.errors %}
<div class="alert alert-danger">{{ form.more_info.errors }}</div>{% endif %}
<div class="form-group">
{{ form.more_info.label_tag }}
{{ form.more_info }}
{{ form.more_info.label_tag }} {{ form.more_info }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.supported_currencies.errors %}<div class="alert alert-danger">{{ form.supported_currencies.errors }}</div>{% endif %}
{% if form.supported_currencies.errors %}
<div class="alert alert-danger">{{ form.supported_currencies.errors }}</div>{% endif %}
<div class="form-group">
{{ form.supported_currencies.label_tag }}
{{ form.supported_currencies }}
{{ form.supported_currencies.label_tag }} {{ form.supported_currencies }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.services.errors %}<div class="alert alert-danger">{{ form.services.errors }}</div>{% endif %}
{% if form.services.errors %}
<div class="alert alert-danger">{{ form.services.errors }}</div>{% endif %}
<div class="form-group">
{{ form.services.label_tag }}
{{ form.services }}
{{ form.services.label_tag }} {{ form.services }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.has_deposit_capability.errors %}<div class="alert alert-danger">{{ form.has_deposit_capability.errors }}</div>{% endif %}
{% if form.has_deposit_capability.errors %}
<div class="alert alert-danger">{{ form.has_deposit_capability.errors }}</div>{% endif %}
<div class="form-group">
{{ form.has_deposit_capability.label_tag }}
{{ form.has_deposit_capability }}
{{ form.has_deposit_capability.label_tag }} {{ form.has_deposit_capability }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.address.errors %}<div class="alert alert-danger">{{ form.address.errors }}</div>{% endif %}
{% if form.address.errors %}
<div class="alert alert-danger">{{ form.address.errors }}</div>{% endif %}
<div class="form-group">
{{ form.address.label_tag }}
{{ form.address }}
{{ form.address.label_tag }} {{ form.address }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.lobby.errors %}<div class="alert alert-danger">{{ form.lobby.errors }}</div>{% endif %}
{% if form.lobby.errors %}
<div class="alert alert-danger">{{ form.lobby.errors }}</div>{% endif %}
<div class="form-group">
{{ form.lobby.label_tag }}
{{ form.lobby }}
{{ form.lobby.label_tag }} {{ form.lobby }}
</div>
</div>
@ -175,18 +176,9 @@
<input type="submit" value="Update" class="btn btn-primary" />
</form>
</div>
{% endblock content %}
{% block extrajs %}
{% comment %}
<script type="text/javascript" src="{% static 'branches/js/branches.js' %}"></script>
<script type="text/javascript">
</script>
{% endcomment %}
{% endblock extrajs %}
{% block extracss %}
<link href="{% static 'branches/css/branches.css' %}" rel="stylesheet">
{% endblock extracss %}
{% endblock content %} {% block extrajs %} {% comment %}
<script type="text/javascript" src="{% static 'branches/js/branches.js' %}"></script>
<script type="text/javascript">
</script>
{% endcomment %} {% endblock extrajs %} {% block extracss %}
<link href="{% static 'branches/css/branches.css' %}" rel="stylesheet"> {% endblock extracss %}

View File

@ -39,37 +39,6 @@ class IndexAtmView(LoginRequiredMixin, FormView):
fields['notes'].choices = [('','Choose...'),("String1", "String1"), ("String2", "String2")]
fields['supported_currencies'].choices = [('','Choose...'),("EUR", "EUR"), ("MXN", "MXN"), ("USD", "USD")]
fields['location_categories'].choices = [('','Choose...'),("ATBI", "ATBI"), ("ATBE", "ATBE")]
"""fields['drive_up'].initial = json.dumps({
"monday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"tuesday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"wednesday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"thursday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"friday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"saturday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"sunday": {
"opening_time": "10:00",
"closing_time": "18:00"
}
}, indent=4)"""
fields['lobby'].initial = json.dumps({
"monday": [
{
@ -153,7 +122,6 @@ class IndexAtmView(LoginRequiredMixin, FormView):
}
},
"lobby": json.loads(data['lobby']),
#"drive_up": json.loads(data["drive_up"]),
"is_accessible": data["is_accessible"] if data["is_accessible"]!="" else "false",
"has_deposit_capability": data["has_deposit_capability"] if data["has_deposit_capability"]!="" else "false",
"supported_languages": data["supported_languages"] if data["supported_languages"]!="" else "false",
@ -171,7 +139,6 @@ class IndexAtmView(LoginRequiredMixin, FormView):
"branch_type": data["branch_type"] if data["branch_type"]!="" else "branch type",
"more_info": data["more_info"] if data["more_info"]!="" else "more info",
"located_at": data["located_at"] if data["located_at"]!="" else "located_at",
"phone_number": data["phone_number"] if data["phone_number"]!="" else "phone number",
"services": data["services"] if data["services"]!="" else "services",
}
result = self.api.post(urlpath, payload=payload)
@ -284,7 +251,6 @@ class UpdateAtmView(LoginRequiredMixin, FormView):
fields['located_at'].initial = result['located_at']
fields['more_info'].initial = result['more_info']
fields['located_at'].initial = result['located_at']
fields['phone_number'].initial = result['phone_number']
fields['lobby'].initial = json.dumps(result['lobby'], indent=4)
if result['supported_languages'].lower()=='en':
fields['supported_languages'].choices = [("en", "en"), ("fr", "fr"), ("de", "de")]
@ -310,7 +276,6 @@ class UpdateAtmView(LoginRequiredMixin, FormView):
else:
fields['location_categories'].choices = [("ATBE", "ATBE"),("ATBI", "ATBI")]
fields['location_categories'].initial = result['location_categories']
#fields['drive_up'].initial = json.dumps(result['drive_up'], indent=4)
except APIError as err:
messages.error(self.request, err)
except Exception as err:
@ -322,7 +287,7 @@ class UpdateAtmView(LoginRequiredMixin, FormView):
data = form.cleaned_data
urlpath = '/banks/{}/atms/{}'.format(data["bank_id"], data["atm_id"])
payload = {
#"id": data["branch_id"],
#"id": data["atm_id"],
"bank_id": data["bank_id"],
"name": data["name"],
"address": json.loads(data['address']),
@ -337,11 +302,6 @@ class UpdateAtmView(LoginRequiredMixin, FormView):
}
},
"lobby": json.loads(data["lobby"]),
#"drive_up": json.loads(data["drive_up"]),
"branch_routing": {
"scheme": data["atm_routing_scheme"] if data["atm_routing_scheme"] != "" else "license name",
"address": data["atm_routing_address"] if data["atm_routing_address"] != "" else "license name"
},
"has_deposit_capability": data["has_deposit_capability"],
"accessibleFeatures": data["accessibleFeatures"],
"minimum_withdrawal": data["minimum_withdrawal"],

View File

@ -39,10 +39,10 @@
<label for="password">Password:</label>
{{ directlogin_form.password }}
</div>
<div class="form-group"<!--style="visibility:hidden"-->
<!--<div class="form-group"style="visibility:hidden">
<label for="consumer-key">Consumer Key:</label>
{{ directlogin_form.consumer_key }}
</div>
</div>-->
<button class="btn btn-primary">Login</button>
</form>
</div>

View File

@ -5,6 +5,7 @@ DirectLogin authenticator for OBP app
import requests
from apimanager import local_settings
from django.conf import settings
@ -28,11 +29,14 @@ class DirectLoginAuthenticator(Authenticator):
data is a dict which contains keys username, password and consumer_key
"""
requestheaders['consumer_key']=local_settings.OAUTH_CONSUMER_KEY
#print("hello",local_settings.OAUTH_CONSUMER_KEY)
url = settings.API_HOST + settings.DIRECTLOGIN_PATH
authorization = 'DirectLogin username="{}",password="{}",consumer_key="{}"'.format( # noqa
requestheaders['username'],
requestheaders['password'],
requestheaders['consumer_key'])
requestheaders['consumer_key']
)
headers = {'Authorization': authorization}
try:

View File

@ -15,8 +15,8 @@ class DirectLoginForm(forms.Form):
attrs={'class': 'form-control'}))
password = forms.CharField(widget=forms.PasswordInput(
attrs={'class': 'form-control'}))
consumer_key = forms.CharField(widget=forms.TextInput(
attrs={'class': 'form-control'}))
#consumer_key = forms.CharField(widget=forms.TextInput(
#attrs={'class': 'form-control'}))
def clean(self):
"""