Commit 15555813 authored by ASHISH KUMAR GOYAL's avatar ASHISH KUMAR GOYAL

Dynamic Homepage view

parent 52644d23
No preview for this file type
......@@ -172,15 +172,6 @@
<button type="button" class="btn btn-outline-danger">REJECT</button> </td>
</tr>
{% endfor %}
<tr>
<td>2011/04/25</td>
<td>2011/04/29</td>
<td>192302323</td>
<td>Ramesh SUresh</td>
<td>4</td>
<td><button type="button" class="btn btn-outline-success">APPROVE</button>
<button type="button" class="btn btn-outline-danger">REJECT</button> </td>
</tr>
</tbody>
</table>
</div>
......
......@@ -122,6 +122,7 @@
<h6 class="m-0 font-weight-bold text-primary"><b>STATUS OF PENDING REQUESTS</b></h6>
</div>
<div class="card-body">
{% if pending_overheads %}
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
......@@ -145,27 +146,25 @@
</tr>
</tfoot>
<tbody>
{% for overhead in pending_overheads %}
<tr>
<td>2011/04/25</td>
<td>193020012</td>
<td>Ramesh Suresh</td>
<td>L</td>
<td>3</td>
<td><button type="button" class="btn btn-outline-success">APPROVE</button>
<button type="button" class="btn btn-outline-danger">REJECT</button> </td>
</tr>
<tr>
<td>2011/04/25</td>
<td>193020011</td>
<td>SRK </td>
<td>D</td>
<td>3</td>
<td>{{ overhead.date }}</td>
<td>{{ overhead.ldap }}</td>
<td>{{ overhead.name }}</td>
<td>{{ overhead.mealType }}</td>
<td>{{ overhead.count }}</td>
<td><button type="button" class="btn btn-outline-success">APPROVE</button>
<button type="button" class="btn btn-outline-danger">REJECT</button> </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center">
<h5>No pending Overhead requests currently.</h5>
</div>
{% endif %}
</div>
</div>
<!--DATA table ends here -->
......
......@@ -134,47 +134,100 @@
<div class="container-fluid">
<!-- DataTales Example -->
<div class="row d-flex justify-content-center">
<div class="col-md-6">
<div class="col-md-8">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary"><b>STATUS OF PREVIOUS REQUESTS</b></h6>
<h6 class="m-0 font-weight-bold text-primary"><b>STATUS OF PREVIOUS OVERHEAD REQUESTS</b></h6>
</div>
<div class="card-body">
{% if prev_overheads %}
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>DATE</th>
<th>APPROVED/REJECTED</th>
<th>MEAL</th>
<th>COUNT</th>
<th>APPROVED/HOLD/REJECTED</th>
</tr>
</thead>
<tfoot>
<tr>
<th>DATE</th>
<th>APPROVED/REJECTED</th>
<th>MEAL</th>
<th>COUNT</th>
<th>APPROVED/HOLD/REJECTED</th>
</tr>
</tfoot>
<tbody>
{% for ovr in prev_overheads %}
<tr>
<td>2011/04/25</td>
<td>Y</td>
<td>{{ ovr.date }}</td>
<td>{{ ovr.meal }}</td>
<td>{{ ovr.count }}</td>
<td>{{ ovr.status }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center">
<h5>No Overhead requests history.</h5>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<!--DATA table ends here -->
<!-- DataTales Example -->
<div class="row d-flex justify-content-center">
<div class="col-md-8">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary"><b>STATUS OF PREVIOUS REBATE REQUESTS</b></h6>
</div>
<div class="card-body">
{% if prev_rebates %}
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<td>2011/07/25</td>
<td>Y</td>
<th>FROM</th>
<th>TO</th>
<th>APPROVED/HOLD/REJECTED</th>
</tr>
</thead>
<tfoot>
<tr>
<td>2009/01/12</td>
<td>N</td>
<th>FROM</th>
<th>TO</th>
<th>APPROVED/HOLD/REJECTED</th>
</tr>
</tfoot>
<tbody>
{% for reb in prev_rebates %}
<tr>
<td>{{ reb.from }}</td>
<td>{{ reb.to }}</td>
<td>{{ reb.status }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% else %}
<div class="text-center">
<h5>No Rebate requests history.</h5>
</div>
{% endif %}
</div>
<!--DATA table ends here -->
</div>
</div>
</div>
</div>
<!--DATA table ends here -->
</div>
<!-- /.container-fluid -->
......
......@@ -26,6 +26,44 @@ def generate_pending_rebates():
else:
return context
def generate_pending_overheads():
context = {'pending_overheads':[]}
for ovr in OverheadReq.objects.filter(status='W'):
context["pending_overheads"].extend([{
'date': str(ovr.date),
'ldap': ovr.student.user.username,
'name':f'{ovr.student.user.first_name+ovr.student.user.last_name}',
'mealType': ovr.mealType,
'count': ovr.count
}])
if len(context["pending_overheads"])==0:
return None
else:
return context
def generate_my_requests(user):
context = {'prev_overheads':[], 'prev_rebates':[]}
status = {'W':'HOLD', 'Y':'APPROVED', 'N':'REJECTED'}
student = Student.objects.filter(user=user)[0]
for ovr in OverheadReq.objects.filter(student=student):
context["prev_overheads"].extend([{
'date': str(ovr.date),
'meal': ovr.mealType,
'status': status[ovr.status],
'count': ovr.count
}])
for reb in RebateReq.objects.filter(student=student):
context["prev_rebates"].extend([{
'from': str(reb.fromDate),
'to': str(reb.toDate),
'status': status[reb.status]
}])
if len(context["prev_overheads"])==0:
context.pop("prev_overheads")
elif len(context["prev_rebates"])==0:
context.pop("prev_rebates")
return context
def homepage_redirect(request):
user=request.user
if is_manager(user):
......
......@@ -48,7 +48,8 @@ def logout_view(request):
@login_required
@user_passes_test(is_student)
def student_homepage_view(request):
return render(request, 'viewreq.html', context=None)
context = generate_my_requests(request.user)
return render(request, 'viewreq.html', context=context)
@login_required
@user_passes_test(is_manager)
......@@ -59,7 +60,8 @@ def manager_homepage_view(request):
@login_required
@user_passes_test(is_worker)
def worker_homepage_view(request):
return render(request, 'appreq.html', context=None)
context = generate_pending_overheads()
return render(request, 'appreq.html', context=context)
@login_required
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment