Skip to content
Merged
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
Binary file modified .DS_Store
Binary file not shown.
Binary file added .github/.DS_Store
Binary file not shown.
Binary file modified FusionIIIT/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions FusionIIIT/applications/hostel_management/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
path('worker_report/', views.generate_worker_report, name='workerreport'),
path('pdf/', views.GeneratePDF.as_view(), name="pdf"),

# !! My Change
path('alloted_rooms/<str:hall_id>/', views.alloted_rooms, name="alloted_rooms"),
path('all_staff/', views.all_staff, name='all_staff')
]
73 changes: 73 additions & 0 deletions FusionIIIT/applications/hostel_management/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from .utils import render_to_pdf, save_worker_report_sheet,get_caretaker_hall
from .utils import add_to_room, remove_from_room

# //! My change
from django.http import JsonResponse

@login_required
def hostel_view(request, context={}):
"""
Expand Down Expand Up @@ -435,3 +438,73 @@ def get(self, request, *args, **kwargs):
response['Content-Disposition'] = content
return response
return HttpResponse("Not found")



# //! alloted_rooms
def alloted_rooms(request, hall_id):
"""
This function returns the allotted rooms in a particular hall.

@param:
request - HttpRequest object containing metadata about the user request.
hall_id - Hall ID for which the allotted rooms need to be retrieved.

@variables:
allotted_rooms - stores all the rooms allotted in the given hall.
"""
# Query the hall by hall_id
hall = Hall.objects.get(hall_id=hall_id)

# Query all rooms allotted in the given hall
allotted_rooms = HallRoom.objects.filter(hall=hall, room_occupied__gt=0)

# Prepare a list of room details to be returned
room_details = []
for room in allotted_rooms:
room_details.append({
'hall': room.hall.hall_name,
'room_no': room.room_no,
'block_no': room.block_no,
'room_cap': room.room_cap,
'room_occupied': room.room_occupied
})

# Return the room_details as JSON response
# return JsonResponse(room_details, safe=False)
return render(request, 'hostelmanagement/alloted_rooms.html', {'allotted_rooms': allotted_rooms})



# //! all_staff
def all_staff(request):
"""
This function returns all staff information.

@param:
request - HttpRequest object containing metadata about the user request.

@variables:
all_staff - stores all staff information.
"""
# Query all staff information
all_staff = StaffSchedule.objects.all()

print(all_staff)

# Prepare a list of staff details to be returned
staff_details = []
for staff in all_staff:
staff_details.append({
'type': staff.staff_type,
'staff_id': staff.staff_id_id,
'hall_id': staff.hall_id,
'day': staff.day,
'start_time': staff.start_time,
'end_time': staff.end_time
})

# Return the staff_details as JSON response
return JsonResponse(staff_details, safe=False)


27 changes: 27 additions & 0 deletions FusionIIIT/templates/hostelmanagement/alloted_rooms.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% load static %}

<div>
<table border="1">
<thead>
<tr>
<th>Hall</th>
<th>Room Number</th>
<th>Block Number</th>
<th>Room Capacity</th>
<th>Occupancy</th>
</tr>
</thead>
<tbody>
{% for room in allotted_rooms %}
<tr>
<td>{{ room.hall }}</td>
<td>{{ room.room_no }}</td>
<td>{{ room.block_no }}</td>
<td>{{ room.room_cap }}</td>
<td>{{ room.room_occupied }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>