mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 14:56:47 +00:00
/feature Add Lock/Unlock button
This commit is contained in:
parent
1d77791ade
commit
7fa33153fd
@ -53,7 +53,7 @@ INSTALLED_APPS = [
|
||||
'users',
|
||||
'branches',
|
||||
'atms',
|
||||
'atmDetail',
|
||||
'atmdetail',
|
||||
'entitlementrequests',
|
||||
'customers',
|
||||
'metrics',
|
||||
|
||||
@ -39,7 +39,7 @@ urlpatterns += i18n_patterns(
|
||||
url(r'^users/', include('users.urls')),
|
||||
url(r'^branches/', include('branches.urls')),
|
||||
url(r'^atms/', include('atms.urls')),
|
||||
url(r'^atm_detail/', include('atmDetail.urls')),
|
||||
url(r'^atm-detail/', include('atmdetail.urls')),
|
||||
url(r'^customers/', include('customers.urls')),
|
||||
url(r'^metrics/', include('metrics.urls')),
|
||||
url(r'^config/', include('config.urls')),
|
||||
|
||||
@ -189,7 +189,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('ATM location'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('OBP'),
|
||||
'placeholder': 'OBP',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -1,7 +1,7 @@
|
||||
{% extends 'base.html' %} {% load static %} {% load i18n %}
|
||||
{% block page_title %} /atms_detail{% endblock page_title %} {% block content %}
|
||||
{% block page_title %} {% trans "API Manager" %}/{% trans "ATMs Detail" %}{% endblock page_title %} {% block content %}
|
||||
<div id="atms">
|
||||
<h1>{% trans "ATMs Detail" %}</h1>
|
||||
<h1>{% trans "ATMs List" %}</h1>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover tablesorter" id="atms-list" aria-describedby="atms list">
|
||||
<thead>
|
||||
@ -9,5 +9,5 @@ from .views import AtmListView
|
||||
urlpatterns = [
|
||||
url(r'^$',
|
||||
AtmListView.as_view(),
|
||||
name='atm_detail')
|
||||
name='atm-detail')
|
||||
]
|
||||
@ -16,7 +16,7 @@ from obp.api import API, APIError
|
||||
|
||||
|
||||
class AtmListView(IndexAtmsView, LoginRequiredMixin, FormView ):
|
||||
template_name = "atmsView/atm_List.html"
|
||||
template_name = "atmsView/atmdetail.html"
|
||||
success_url = '/atmsView/'
|
||||
def get_banks(self):
|
||||
api = API(self.request.session.get('obp'))
|
||||
@ -100,7 +100,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Opening Hours'),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -110,7 +110,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Monday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -120,7 +120,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Tuesday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -130,7 +130,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Wednesday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -140,7 +140,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Thursday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -150,7 +150,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Friday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -160,7 +160,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Saturday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -170,7 +170,7 @@ class CreateAtmForm(forms.Form):
|
||||
label=_('Sunday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('None'),
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
{% url "branches_list" as branches_list_url %}
|
||||
{% url "customers-create" as customers_create_url %}
|
||||
{% url "atms_list" as atms_list_url %}
|
||||
{% url "atm_detail" as atm_detail_url %}
|
||||
{% url "atm-detail" as atm_detail_url %}
|
||||
<li class="dropdown{% if customers_create_url in request.path %} active{% endif %}">
|
||||
<a href="#" data-toggle="dropdown" class="dropdown-toggle">{% trans "Resources" %}</a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
@ -36,24 +36,22 @@
|
||||
<strong>{% trans "Locked" %}</strong><br />
|
||||
<span>{{ apiuser.is_locked }}</span>
|
||||
</div>
|
||||
|
||||
|
||||
<form action="{% url 'user-status-update' apiuser.user_id apiuser.username %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="next" value="{{ request.path }}" />
|
||||
<input type="hidden" name="role_name" value="{{ entitlement.role_name }}" />
|
||||
{% if apiuser.is_deleted %}
|
||||
|
||||
|
||||
{% else %}
|
||||
<button type="submit" class="btn btn-primary btn-red" value ="Delete" name ="Delete">{% trans "Delete User" %}</button>
|
||||
{% endif %}
|
||||
|
||||
{% if apiuser.is_locked %}
|
||||
<button type="submit" class="btn btn-primary btn-green" value ="Unlock" name ="Unlock">{% trans "Unlock User" %}</button>
|
||||
{% else %}
|
||||
{% if apiuser.is_locked %}
|
||||
<button type="submit" class="btn btn-primary btn-green" value ="Unlock" name ="Unlock">{% trans "Unlock User" %}</button>
|
||||
{% else %}
|
||||
<button type="submit" class="btn btn-primary btn-green" value ="Lock" name ="Lock">{% trans "Lock User" %}</button>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@ from obp.api import API, APIError
|
||||
from .forms import AddEntitlementForm,CreateInvitationForm
|
||||
import csv
|
||||
|
||||
|
||||
class FilterRoleName(BaseFilter):
|
||||
"""Filter users by role names"""
|
||||
filter_type = 'role_name'
|
||||
@ -367,18 +366,32 @@ class UserStatusUpdateView(LoginRequiredMixin, View):
|
||||
else:
|
||||
msg = 'User with ID {} has been deleted.'.format(kwargs['user_id'])
|
||||
messages.success(request, msg)
|
||||
else:
|
||||
urlpath = '/users/{}/lock-status'.format(kwargs['username'])
|
||||
result = api.put(urlpath, None)
|
||||
elif(request.POST.get("Lock")):
|
||||
urlpath = '/users/{}/locks'.format(kwargs['username'])
|
||||
result = api.post(urlpath, None)
|
||||
if result is not None and 'code' in result and result['code'] >= 400:
|
||||
messages.error(request, result['message'])
|
||||
else:
|
||||
msg = 'User {} has been lock.'.format(kwargs['username'])
|
||||
messages.success(request, msg)
|
||||
else:
|
||||
urlpath = '/users/{}/lock-status'.format(kwargs['username'])
|
||||
result = api.put(urlpath, None)
|
||||
print("result", result)
|
||||
#if result is not None and 'code' in result and result['code'] >= 400:
|
||||
if 'code' in result and result['code'] == 404:
|
||||
msg = 'User {} has been unlocked.'.format(kwargs['username'])
|
||||
messages.success(request, msg)
|
||||
else:
|
||||
messages.error(request, result['message'])
|
||||
#else:
|
||||
# msg = 'User {} has been unlocked.'.format(kwargs['username'])
|
||||
# messages.success(request, msg)
|
||||
|
||||
except APIError as err:
|
||||
messages.error(request, err)
|
||||
except:
|
||||
messages.error(self.request, 'Unknown Error')
|
||||
except Exception as e:
|
||||
messages.error(self.request, 'Unknown Error' + str(e))
|
||||
|
||||
# from sonarcloud: Change this code to not perform redirects based on user-controlled data.
|
||||
redirect_url_from_gui = request.POST.get('next', reverse('users-index'))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user