Skip to content

Commit 7527683

Browse files
authored
Merge pull request #15 from aniruddha2002das/hmweb-anni-fine3
Frontend for Fine features
2 parents e87da90 + 13672d2 commit 7527683

File tree

4 files changed

+61
-27
lines changed

4 files changed

+61
-27
lines changed

FusionIIIT/applications/hostel_management/views.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ def hostel_view(request, context={}):
243243

244244
add_hostel_form = HallForm()
245245
warden_ids=Faculty.objects.all().select_related('id__user')
246+
247+
#//! My change for imposing fines
248+
user_id = request.user
249+
staff_fine_caretaker=user_id.extrainfo.id
250+
students = Student.objects.all();
251+
252+
fine_user=request.user
253+
254+
255+
caretaker_fine_id = HallCaretaker.objects.get(staff_id=staff_fine_caretaker)
256+
hall_fine_id = caretaker_fine_id.hall_id
257+
hostel_fines = HostelFine.objects.filter(hall_id=hall_fine_id).order_by('fine_id')
258+
246259
context = {
247260

248261
'all_hall': all_hall,
@@ -274,6 +287,10 @@ def hostel_view(request, context={}):
274287
'my_leaves': my_leaves,
275288
'all_leaves': all_leaves,
276289
'all_complaints': all_complaints,
290+
291+
'staff_fine_caretaker':staff_fine_caretaker,
292+
'students':students,
293+
'hostel_fines':hostel_fines,
277294
**context
278295
}
279296

@@ -1500,7 +1517,7 @@ def post(self, request):
15001517

15011518
# Extract data from the request
15021519
student_id = request.data.get('student_id')
1503-
student_name = request.data.get('student_name')
1520+
student_name = request.data.get('student_fine_name')
15041521
amount = request.data.get('amount')
15051522
reason = request.data.get('reason')
15061523

FusionIIIT/templates/hostelmanagement/hostel.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@
156156
</a>
157157
{% endif %}
158158

159+
{% if user in hall_caretaker%}
160+
<a class="item" data-tab="fine1">
161+
Impose Fine
162+
<i class="right floated chevron right icon"></i>
163+
</a>
164+
{% endif %}
165+
166+
{% if user in hall_caretaker%}
167+
<a class="item" data-tab="fine2">
168+
All Fines
169+
<i class="right floated chevron right icon"></i>
170+
</a>
171+
{% endif %}
159172
</div>
160173

161174
</div>
@@ -291,6 +304,22 @@
291304
</div>
292305
{% endif %}
293306

307+
{% if user in hall_caretaker%}
308+
<div class="ui tab segment" data-tab="fine1">
309+
{% block Impose_fine %}
310+
{% include 'hostelmanagement/impose_fine.html' %}
311+
{% endblock %}
312+
</div>
313+
{% endif %}
314+
315+
{% if user in hall_caretaker%}
316+
<div class="ui tab segment" data-tab="fine2">
317+
{% block fine_list %}
318+
{% include 'hostelmanagement/hostel_fine_list.html' %}
319+
{% endblock %}
320+
</div>
321+
{% endif %}
322+
294323
</div>
295324

296325
</div>

FusionIIIT/templates/hostelmanagement/hostel_fine_list.html

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Hostel Fine List</title>
7-
</head>
8-
<body>
9-
<h1>Hostel Fine List</h1>
10-
<table border="1">
1+
{% block fine_list %}
2+
<h1 align ="center">Hostel Fine List</h1>
3+
<table class= "ui form">
114
<thead>
125
<tr>
136
<th>Fine ID</th>
@@ -95,5 +88,7 @@ <h1>Hostel Fine List</h1>
9588
});
9689
}
9790
</script>
98-
</body>
99-
</html>
91+
92+
{% endblock %}
93+
94+

FusionIIIT/templates/hostelmanagement/impose_fine.html

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Hostel Fine Form</title>
7-
</head>
8-
<body>
1+
{% block Impose_fine %}
92
<h1>Hostel Fine Form</h1>
10-
<form id="fineForm" action="/hostelmanagement/fine/impose/" method="POST">
3+
<form class="ui form" id="fineForm" action="/hostelmanagement/fine/impose/" method="POST">
114
{% csrf_token %}
125
<label for="student_id">Student ID:</label>
136

@@ -19,7 +12,7 @@ <h1>Hostel Fine Form</h1>
1912
</select><br /><br />
2013

2114
<label for="student_name">Student Name:</label>
22-
<input type="text" id="student_name" name="student_name" required readonly /><br /><br />
15+
<input type="text" id="student_fine_name" name="student_fine_name" required readonly /><br /><br />
2316

2417
<label for="amount">Amount:</label>
2518
<input type="number" id="amount" name="amount" min="0" step="1" required /><br />
@@ -46,7 +39,8 @@ <h1>Hostel Fine Form</h1>
4639
fetch(`/hostelmanagement/student/${studentId}/name/`)
4740
.then(response => response.json())
4841
.then(data => {
49-
document.getElementById("student_name").value = data.name;
42+
console.log(data.name);
43+
document.getElementById("student_fine_name").value = data.name;
5044
})
5145
.catch(error => {
5246
console.error("Error fetching student name:", error);
@@ -68,7 +62,7 @@ <h1>Hostel Fine Form</h1>
6862
})
6963
.then(response => {
7064
if (response.ok) {
71-
window.location.href = "impose/list/";
65+
window.location.href = "/hostelmanagement/";
7266
} else {
7367
console.error("Error updating status");
7468
}
@@ -78,5 +72,4 @@ <h1>Hostel Fine Form</h1>
7872
});
7973
});
8074
</script>
81-
</body>
82-
</html>
75+
{% endblock %}

0 commit comments

Comments
 (0)