Added Entitlement Requests - 2nd part

This commit is contained in:
constantine2nd 2018-01-23 16:05:33 +01:00
parent 81ffa13ab8
commit 42819b2b9c
4 changed files with 40 additions and 17 deletions

View File

@ -1,20 +1,7 @@
.entitlementrequests #entitlementrequests-list {
.table-responsive {
margin-top: 20px;
}
#entitlementrequests .btn-group-vertical.filter-enabled,
#entitlementrequests .btn-group-vertical.filter-apptype {
margin-top: 10px;
}
#entitlementrequests-detail div {
margin: 5px 0;
}
#entitlementrequests .filter a {
font-size: 12px;
}
#entitlementrequests .actions .btn {
margin-bottom: 2px;
}

View File

@ -0,0 +1,6 @@
<a href="?time=hour&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_hour %} active{% endif %}">Last Hour</a>
<a href="?time=day&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_day %} active{% endif %}">Last Day</a>
<a href="?time=week&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_week %} active{% endif %}">Last Week</a>
<a href="?time=month&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_month %} active{% endif %}">Last Month</a>
<a href="?time=year&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_year %} active{% endif %}">Last Year</a>
<a href="?time=All&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_all %} active{% endif %}">All</a>

View File

@ -7,13 +7,28 @@
<div id="entitlementrequests">
<h1>Entitlement Requests</h1>
<div class="row">
<div class="col-xs-12 col-md-6">
<div id="filter-time" class="filter">
<div class="btn-group hidden-sm hidden-xs filter-time" role="group" aria-label="filter-time">
{% include "entitlementrequests/includes/filter_time.html" %}
</div>
<div class="btn-group-vertical visible-sm visible-xs filter-time" role="group" aria-label="filter-time">
{% include "entitlementrequests/includes/filter_time.html" %}
</div>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover tablesorter" id="consumer-list">
<table class="table table-hover tablesorter" id="entitementrequests-list">
<thead>
<th>Entitlement Request ID</th>
<th>Role Name</th>
<th>User ID</th>
<th>Bank ID</th>
<th>Created</th>
</thead>
<tbody>
@ -23,6 +38,7 @@
<td class="select">{{ entitlementrequest.role_name }}</td>
<td><a href="{{ url_users_detail }}">{{ entitlementrequest.user_id }}</a></td>
<td class="select">{{ entitlementrequest.bank_id }}</td>
<td class="select">{{ entitlementrequest.created|naturaltime }}</td>
</tr>
{% endfor %}
</tbody>

View File

@ -7,12 +7,23 @@ from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView, RedirectView
from obp.api import API, APIError
from base.filters import BaseFilter, FilterTime
from datetime import datetime
from django.conf import settings
class IndexView(LoginRequiredMixin, TemplateView):
"""Index view for entitlement requests"""
template_name = "entitlementrequests/index.html"
def scrub(self, entitlement_requests):
"""Scrubs data in the given consumers to adher to certain formats"""
for entitlement_request in entitlement_requests:
entitlement_request['created'] = datetime.strptime(
entitlement_request['created'], settings.API_DATETIMEFORMAT)
return entitlement_requests
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
entitlement_requests = []
@ -20,11 +31,14 @@ class IndexView(LoginRequiredMixin, TemplateView):
try:
urlpath = '/entitlement-requests'
entitlement_requests = api.get(urlpath)
entitlement_requests = entitlement_requests['entitlement_requests']
entitlement_requests = FilterTime(context, self.request.GET, 'created') \
.apply(entitlement_requests)
entitlement_requests = self.scrub(entitlement_requests)
except APIError as err:
messages.error(self.request, err)
sorted_entitlement_requests = entitlement_requests['entitlement_requests']
context.update({
'entitlementrequests': sorted_entitlement_requests,
'entitlementrequests': entitlement_requests,
})
return context