Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Allocations/Resource list incorrect #577

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions coldfront/core/resource/templates/resource_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,27 @@ <h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Child

<div class="card-body">
{% if child_resources %}
<div class="table-responsive">
<table id="child_resource_table" class="table table-bordered table-sm">
<thead>
<tr>
<th scope="col">Resource Name</th>
<th scope="col">WarrantyExpire</th>
<th scope="col">ServiceEnd</th>
<th scope="col">Vendor</th>
<th scope="col">Serial #</th>
<th scope="col">Model</th>
</tr>
</thead>
<tbody>
{% for child in child_resources %}
{% if child_resources.0.Acc %}
<div class="alert alert-info" role="alert">
<i class="fas fa-info-circle" aria-hidden="true"></i>
There are no child resources to display.
</div>
{% else %}
<div class="table-responsive">
<table id="child_resource_table" class="table table-bordered table-sm">
<thead>
<tr>
<th scope="col">Resource Name</th>
<th scope="col">WarrantyExpire</th>
<th scope="col">ServiceEnd</th>
<th scope="col">Vendor</th>
<th scope="col">Serial #</th>
<th scope="col">Model</th>
</tr>
</thead>
<tbody>
{% for child in child_resources %}
{% if child.Available %}
<tr>
<td><a href="{% url 'resource-detail' child.object.pk %}">{{child.object}}</a></td>
<td>{{child.WarrantyExpirationDate}}</td>
Expand All @@ -147,10 +154,12 @@ <h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Child
<td>{{child.SerialNumber}}</td>
<td>{{child.Model}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% else %}
<div class="alert alert-info" role="alert">
<i class="fas fa-info-circle" aria-hidden="true"></i>
Expand Down
14 changes: 8 additions & 6 deletions coldfront/core/resource/templates/resource_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ <h2>Resources</h2>
</thead>
<tbody>
{% for resource in resource_list %}
<tr>
<tr>
<td><a href="/resource/{{resource.id}}/">{{ resource.id }}</a></td>
<td>{{ resource }}</td>
<td>{{ resource.parent_resource }}</td>
<td>{{ resource.resource_type.name }}</td>
{% if resource.is_available %}
<td><a href="/resource/{{resource.id}}/">{{ resource.id }}</a></td>
<td>{{ resource }}</td>
<td>{{ resource.parent_resource }}</td>
<td>{{ resource.resource_type.name }}</td>
</tr>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% if is_paginated %} Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
<ul class="pagination float-right mr-3">
Expand Down
14 changes: 10 additions & 4 deletions coldfront/core/resource/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,26 @@ def test_func(self):
def get_child_resources(self, resource_obj):
child_resources = [resource for resource in resource_obj.resource_set.all(
).order_by(Lower("name"))]

acc=True
for m in child_resources:
if(m.is_available==True):
acc=False

child_resources = [

{'object': resource,
'WarrantyExpirationDate': resource.get_attribute('WarrantyExpirationDate'),
'ServiceEnd': resource.get_attribute('ServiceEnd'),
'Vendor': resource.get_attribute('Vendor'),
'SerialNumber': resource.get_attribute('SerialNumber'),
'Model': resource.get_attribute('Model'),
'Model': resource.get_attribute('Model'),
'Available' : resource.is_available,
'Allocatable' : resource.is_allocatable,
'Acc':acc
}
for resource in child_resources

for resource in child_resources
]

return child_resources

def get_context_data(self, **kwargs):
Expand Down