From 0c3b5260f95da933faa153d96b925cc6355b4cb0 Mon Sep 17 00:00:00 2001 From: Anishwar Sharma <81948807+anishwar-007@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:46:53 +0530 Subject: [PATCH 001/158] GAD-2:ALL WEEKS: OVERALL CHANGES (#1092) --- FusionIIIT/applications/iwdModuleV2/views.py | 101 ++++++++++++------ FusionIIIT/templates/iwdModuleV2/Page1.html | 5 +- FusionIIIT/templates/iwdModuleV2/Page2.html | 31 ++++-- FusionIIIT/templates/iwdModuleV2/Page3.html | 8 +- .../templates/iwdModuleV2/createWork.html | 13 +-- .../iwdModuleV2/page1_support_1_aes.html | 3 +- .../page2_support_1_corrigendum.html | 2 +- .../templates/iwdModuleV2/viewWork.html | 3 +- 8 files changed, 105 insertions(+), 61 deletions(-) diff --git a/FusionIIIT/applications/iwdModuleV2/views.py b/FusionIIIT/applications/iwdModuleV2/views.py index 2b36550fc..7cc9cf67c 100644 --- a/FusionIIIT/applications/iwdModuleV2/views.py +++ b/FusionIIIT/applications/iwdModuleV2/views.py @@ -18,7 +18,7 @@ # in conjunction with SRS. After that, everything will become easier. def dashboard(request): - eligible = False + eligible = True userObj = request.user userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) for p in userDesignationObjects: @@ -107,7 +107,8 @@ def page2_1(request): def corrigendumInput(request): if request.method == 'POST': - existingObject = CorrigendumTable.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = CorrigendumTable.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = CorrigendumTable() @@ -128,7 +129,8 @@ def corrigendumInput(request): def addendumInput(request): if request.method == 'POST': - existingObject = Addendum.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = Addendum.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = Addendum() @@ -145,7 +147,8 @@ def addendumInput(request): def PreBidForm(request): if request.method == 'POST': - existingObject = PreBidDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = PreBidDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = PreBidDetails() @@ -161,9 +164,11 @@ def PreBidForm(request): def noOfEntriesTechnicalBid(request): formNoTechnicalObjects = NoOfTechnicalBidTimes() - formNoTechnicalObjects.key = Projects.objects.get(id=request.session['projectId']) + formNoTechnicalObjects.key = Projects.objects.get( + id=request.session['projectId']) if request.method == 'POST': - existingObject = NoOfTechnicalBidTimes.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = NoOfTechnicalBidTimes.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formNoTechnicalObjects.number = int(request.POST['number']) @@ -174,9 +179,11 @@ def noOfEntriesTechnicalBid(request): def TechnicalBidForm(request): formObject = TechnicalBidDetails() - numberOfTechnicalBidTimes = NoOfTechnicalBidTimes.objects.get(key=Projects.objects.get(id=request.session['projectId'])).number + numberOfTechnicalBidTimes = NoOfTechnicalBidTimes.objects.get( + key=Projects.objects.get(id=request.session['projectId'])).number if request.method == 'POST': - existingObject = TechnicalBidDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = TechnicalBidDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = TechnicalBidDetails() @@ -184,12 +191,14 @@ def TechnicalBidForm(request): formObject.sNo = request.POST['sNo'] formObject.requirements = request.POST['requirements'] formObject.save() - TechnicalBidContractorDetails.objects.filter(key=formObject).all().delete() + TechnicalBidContractorDetails.objects.filter( + key=formObject).all().delete() for w in range(numberOfTechnicalBidTimes): formContractorObject = TechnicalBidContractorDetails() formContractorObject.key = formObject formContractorObject.name = request.POST[str(w) + 'name'] - formContractorObject.description = request.POST[str(w) + 'Description'] + formContractorObject.description = request.POST[str( + w) + 'Description'] formContractorObject.save() return redirect('iwdModuleV2/noOfEntriesFinancialBid') return render(request, 'iwdModuleV2/page2_support_4_technicalbid.html', @@ -198,12 +207,15 @@ def TechnicalBidForm(request): def noOfEntriesFinancialBid(request): listOfContractors = [] - objectTechnicalBid = TechnicalBidDetails.objects.get(key=Projects.objects.get(id=request.session['projectId'])) - objects = TechnicalBidContractorDetails.objects.filter(key=objectTechnicalBid) + objectTechnicalBid = TechnicalBidDetails.objects.get( + key=Projects.objects.get(id=request.session['projectId'])) + objects = TechnicalBidContractorDetails.objects.filter( + key=objectTechnicalBid) for t in objects: listOfContractors.append(t.name) if request.method == 'POST': - existingObject = FinancialBidDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = FinancialBidDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = FinancialBidDetails() @@ -217,7 +229,8 @@ def noOfEntriesFinancialBid(request): formContractorObject.name = listOfContractors[f] formContractorObject.totalCost = request.POST[listOfContractors[f] + 'totalCost'] formContractorObject.estimatedCost = request.POST[listOfContractors[f] + 'estimatedCost'] - formContractorObject.percentageRelCost = request.POST[listOfContractors[f] + 'percentageRelCost'] + formContractorObject.percentageRelCost = request.POST[ + listOfContractors[f] + 'percentageRelCost'] formContractorObject.perFigures = request.POST[listOfContractors[f] + 'perFigures'] formContractorObject.save() return redirect('iwdModuleV2/letterOfIntent') @@ -227,7 +240,8 @@ def noOfEntriesFinancialBid(request): def letterOfIntent(request): if request.method == 'POST': - existingObject = LetterOfIntentDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = LetterOfIntentDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = LetterOfIntentDetails() @@ -244,7 +258,8 @@ def letterOfIntent(request): def workOrderForm(request): if request.method == 'POST': - existingObject = WorkOrderForm.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = WorkOrderForm.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = WorkOrderForm() @@ -267,7 +282,8 @@ def workOrderForm(request): def AgreementInput(request): if request.method == 'POST': - existingObject = Agreement.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + existingObject = Agreement.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) if existingObject.count() == 1: existingObject.delete() formObject = Agreement() @@ -291,7 +307,8 @@ def milestonesForm(request): formObject.timeAllowed = request.POST['timeAllowed'] formObject.save() return redirect('iwdModuleV2/page3_1') - Milestones.objects.filter(key=Projects.objects.get(id=request.session['projectId'])).all().delete() + Milestones.objects.filter(key=Projects.objects.get( + id=request.session['projectId'])).all().delete() return render(request, 'iwdModuleV2/page2_support_9_milestone.html', {}) @@ -321,35 +338,42 @@ def ExtensionOfTimeForm(request): def page1View(request): - request.session['projectId'] = request.POST['id'] - projectPageOne = PageOneDetails.objects.get(id=Projects.objects.get(id=request.session['projectId'])) + if request.POST: + request.session['projectId'] = request.POST['id'] + projectPageOne = PageOneDetails.objects.get( + id=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/Page1.html', {'x': projectPageOne}) def page2View(request): - projectPageTwo = PageTwoDetails.objects.get(id=Projects.objects.get(id=request.session['projectId'])) + projectPageTwo = PageTwoDetails.objects.get( + id=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/Page2.html', {'x': projectPageTwo}) def AESView(request): - objects = AESDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + objects = AESDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/AA&ES.html', {'AES': objects}) def financialBidView(request): elements = [] - objects = FinancialBidDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + objects = FinancialBidDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) for f in objects: contractorObjects = FinancialContractorDetails.objects.filter(key=f) for w in contractorObjects: - obj = [f.sNo, f.description, w.name, w.estimatedCost, w.percentageRelCost, w.perFigures, w.totalCost] + obj = [f.sNo, f.description, w.name, w.estimatedCost, + w.percentageRelCost, w.perFigures, w.totalCost] elements.append(obj) return render(request, 'iwdModuleV2/Page2_financialbid.html', {'financial': elements}) def technicalBidView(request): elements = [] - objects = TechnicalBidDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + objects = TechnicalBidDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) for f in objects: contractorObjects = TechnicalBidContractorDetails.objects.filter(key=f) for w in contractorObjects: @@ -359,45 +383,54 @@ def technicalBidView(request): def preBidDetailsView(request): - preBidObjects = PreBidDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + preBidObjects = PreBidDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/Page2_pre-bid.html', {'preBidDetails': preBidObjects}) def corrigendumView(request): - corrigendumObject = CorrigendumTable.objects.get(key=Projects.objects.get(id=request.session['projectId'])) + corrigendumObject = CorrigendumTable.objects.get( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/corrigendum.html', {'corrigendum': corrigendumObject}) def addendumView(request): - addendumObject = Addendum.objects.get(key=Projects.objects.get(id=request.session['projectId'])) + addendumObject = Addendum.objects.get( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/Addendum.html', {'x': addendumObject}) def letterOfIntentView(request): - letterOfIntentObject = LetterOfIntentDetails.objects.get(key=Projects.objects.get(id=request.session['projectId'])) + letterOfIntentObject = LetterOfIntentDetails.objects.get( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/letterOfIntent.html', {'x': letterOfIntentObject}) def workOrderFormView(request): - workOrderFormObject = WorkOrderForm.objects.get(key=Projects.objects.get(id=request.session['projectId'])) + workOrderFormObject = WorkOrderForm.objects.get( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/WorkOrderForm.html', {'x': workOrderFormObject}) def agreementView(request): - agreementObject = Agreement.objects.get(key=Projects.objects.get(id=request.session['projectId'])) + agreementObject = Agreement.objects.get( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/Agreement.html', {'agreement': agreementObject}) def milestoneView(request): - milestoneObjects = Milestones.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + milestoneObjects = Milestones.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/Page2_milestones.html', {'milestones': milestoneObjects}) def page3View(request): - pageThreeDetails = PageThreeDetails.objects.get(id=Projects.objects.get(id=request.session['projectId'])) + pageThreeDetails = PageThreeDetails.objects.get( + id=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/Page3.html', {'x': pageThreeDetails}) def extensionFormView(request): - extensionObjects = ExtensionOfTimeDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) + extensionObjects = ExtensionOfTimeDetails.objects.filter( + key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/ExtensionForm.html', {'extension': extensionObjects}) diff --git a/FusionIIIT/templates/iwdModuleV2/Page1.html b/FusionIIIT/templates/iwdModuleV2/Page1.html index 8e7eac710..bfd2d8a69 100644 --- a/FusionIIIT/templates/iwdModuleV2/Page1.html +++ b/FusionIIIT/templates/iwdModuleV2/Page1.html @@ -65,7 +65,7 @@ AA And AES
Download
-
i
+
i
@@ -111,7 +111,8 @@ - Next + Next + {% if var %}

{{var}}

{% endif %} diff --git a/FusionIIIT/templates/iwdModuleV2/Page2.html b/FusionIIIT/templates/iwdModuleV2/Page2.html index 9f933e3be..715244f82 100644 --- a/FusionIIIT/templates/iwdModuleV2/Page2.html +++ b/FusionIIIT/templates/iwdModuleV2/Page2.html @@ -65,7 +65,7 @@ Corrigendum
Download
-
i
+
i
@@ -73,7 +73,8 @@ Addendum
Download
-
i
+ +
i
@@ -81,7 +82,8 @@ Pre-bid meeting details
Download
-
i
+ +
i
@@ -89,7 +91,8 @@ Technical-bid meeting details
Download
-
i
+ +
i
@@ -101,7 +104,8 @@ Financial-bid meeting details
Download
-
i
+ +
i
@@ -113,7 +117,8 @@ Letter of intent
Download
-
i
+ +
i
@@ -121,7 +126,8 @@ Work order
Download
-
i
+ +
i
@@ -129,7 +135,8 @@ Agreement Letter
Download
-
i
+ +
i
@@ -137,13 +144,15 @@ Milestones
Download
-
i
+ +
i
- Next + Prev + Next @@ -178,4 +187,4 @@ -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/iwdModuleV2/Page3.html b/FusionIIIT/templates/iwdModuleV2/Page3.html index d19ae128d..ddde765e5 100644 --- a/FusionIIIT/templates/iwdModuleV2/Page3.html +++ b/FusionIIIT/templates/iwdModuleV2/Page3.html @@ -65,7 +65,8 @@ Extension of time
Download
-
i
+ +
i
@@ -76,7 +77,8 @@ - Next + Prev + Back To Home @@ -110,4 +112,4 @@ -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/iwdModuleV2/createWork.html b/FusionIIIT/templates/iwdModuleV2/createWork.html index 04323ba15..7fa533571 100644 --- a/FusionIIIT/templates/iwdModuleV2/createWork.html +++ b/FusionIIIT/templates/iwdModuleV2/createWork.html @@ -4,20 +4,17 @@ Create Project Requisition: -
+
- - -
+ -
+ - -
+ -
+
diff --git a/FusionIIIT/templates/iwdModuleV2/page1_support_1_aes.html b/FusionIIIT/templates/iwdModuleV2/page1_support_1_aes.html index ed6ff8543..a5da06deb 100644 --- a/FusionIIIT/templates/iwdModuleV2/page1_support_1_aes.html +++ b/FusionIIIT/templates/iwdModuleV2/page1_support_1_aes.html @@ -125,7 +125,8 @@

- + Prev +

diff --git a/FusionIIIT/templates/iwdModuleV2/page2_support_1_corrigendum.html b/FusionIIIT/templates/iwdModuleV2/page2_support_1_corrigendum.html index f372125ac..151e5afc0 100644 --- a/FusionIIIT/templates/iwdModuleV2/page2_support_1_corrigendum.html +++ b/FusionIIIT/templates/iwdModuleV2/page2_support_1_corrigendum.html @@ -100,7 +100,7 @@
- Next + Prev diff --git a/FusionIIIT/templates/iwdModuleV2/viewWork.html b/FusionIIIT/templates/iwdModuleV2/viewWork.html index 3fb49831f..d67b8d528 100644 --- a/FusionIIIT/templates/iwdModuleV2/viewWork.html +++ b/FusionIIIT/templates/iwdModuleV2/viewWork.html @@ -1,6 +1,7 @@
-
{% csrf_token %} + + {% csrf_token %}

From 5535dd49b45ae7f82f3fefe939657e936c68fe8a Mon Sep 17 00:00:00 2001 From: JAYANT JAIN <56956286+jayant26@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:50:03 +0530 Subject: [PATCH 002/158] gad-2: improved CSS of page_1 and corrigendum of IWD module (#1112) --- .../templates/iwdModuleV2/page1_create.html | 2 +- .../page2_support_1_corrigendum.html | 204 ++++++++++-------- 2 files changed, 121 insertions(+), 85 deletions(-) diff --git a/FusionIIIT/templates/iwdModuleV2/page1_create.html b/FusionIIIT/templates/iwdModuleV2/page1_create.html index c549fe90f..de798b7cb 100644 --- a/FusionIIIT/templates/iwdModuleV2/page1_create.html +++ b/FusionIIIT/templates/iwdModuleV2/page1_create.html @@ -78,7 +78,7 @@
- +

-
- -
- +
- -{% endblock %} -{% block javascript %} --> From 27a45cfa2874e431a74aebcc0aa5c3726324513d Mon Sep 17 00:00:00 2001 From: Stark Date: Mon, 19 Feb 2024 02:47:18 +0530 Subject: [PATCH 038/158] chore: run python manage.py copy_data to merge table to get all student details at one place --- .../migrations/0007_auto_20240218_2312.py | 18 ++++++++ .../migrations/0008_auto_20240219_0205.py | 18 ++++++++ .../applications/hostel_management/admin.py | 2 + .../management/commands/copy_data.py | 45 +++++++++++++++++++ .../migrations/0008_studentdetails.py | 27 +++++++++++ .../migrations/0009_auto_20240219_0203.py | 28 ++++++++++++ .../migrations/0010_auto_20240219_0205.py | 18 ++++++++ .../migrations/0011_auto_20240219_0207.py | 28 ++++++++++++ .../applications/hostel_management/models.py | 16 +++++++ 9 files changed, 200 insertions(+) create mode 100644 FusionIIIT/applications/globals/migrations/0007_auto_20240218_2312.py create mode 100644 FusionIIIT/applications/globals/migrations/0008_auto_20240219_0205.py create mode 100644 FusionIIIT/applications/hostel_management/management/commands/copy_data.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0008_studentdetails.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0009_auto_20240219_0203.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0010_auto_20240219_0205.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0011_auto_20240219_0207.py diff --git a/FusionIIIT/applications/globals/migrations/0007_auto_20240218_2312.py b/FusionIIIT/applications/globals/migrations/0007_auto_20240218_2312.py new file mode 100644 index 000000000..e688c56bb --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0007_auto_20240218_2312.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-02-18 23:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0006_auto_20240218_1336'), + ] + + operations = [ + migrations.AlterField( + model_name='extrainfo', + name='user_status', + field=models.CharField(choices=[('PRESENT', 'PRESENT'), ('NEW', 'NEW')], default='PRESENT', max_length=50), + ), + ] diff --git a/FusionIIIT/applications/globals/migrations/0008_auto_20240219_0205.py b/FusionIIIT/applications/globals/migrations/0008_auto_20240219_0205.py new file mode 100644 index 000000000..9127c5025 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0008_auto_20240219_0205.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-02-19 02:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0007_auto_20240218_2312'), + ] + + operations = [ + migrations.AlterField( + model_name='extrainfo', + name='user_status', + field=models.CharField(choices=[('NEW', 'NEW'), ('PRESENT', 'PRESENT')], default='PRESENT', max_length=50), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/admin.py b/FusionIIIT/applications/hostel_management/admin.py index bef792d8e..b0549694a 100644 --- a/FusionIIIT/applications/hostel_management/admin.py +++ b/FusionIIIT/applications/hostel_management/admin.py @@ -14,6 +14,8 @@ admin.site.register(WorkerReport) admin.site.register(HostelLeave) admin.site.register(HostelComplaint) +admin.site.register(StudentDetails) + # admin.site.register(HostelAllotment) \ No newline at end of file diff --git a/FusionIIIT/applications/hostel_management/management/commands/copy_data.py b/FusionIIIT/applications/hostel_management/management/commands/copy_data.py new file mode 100644 index 000000000..c5fb577f8 --- /dev/null +++ b/FusionIIIT/applications/hostel_management/management/commands/copy_data.py @@ -0,0 +1,45 @@ +from applications.academic_information.models import Student +from applications.hostel_management.models import StudentDetails +from django.contrib.auth.models import User + + +def copy_data(): + + # Fetch data from the Student table with a join to the User table + student_data = Student.objects.all() + + # Iterate over the student data and create StudentDetails instances + for student_instance in student_data: + # Extract data from the related User instance + id = student_instance.id_id + # print(id) + user_instance = User.objects.filter(username=id).first(); + # print('name',user_instance.first_name) + print(student_instance.room_no) + print(student_instance.hall_no) + user_instance = User.objects.get(username=id) + print(user_instance.username) + + + + + + # Create a StudentDetails instance using data from the Student and User instances + student_details_instance = StudentDetails( + id=student_instance.id_id, + first_name=user_instance.first_name, + last_name=user_instance.last_name, + programme=student_instance.programme, + batch=student_instance.batch, + room_num=student_instance.room_no, + hall_no=student_instance.hall_no, + specialization=student_instance.specialization, + # parent_contact=student_instance.parent_contact, + # address=student_instance.address + ) + + # Save the StudentDetails instance to the database + student_details_instance.save() + +# Call the function to initiate the data copying process +copy_data() diff --git a/FusionIIIT/applications/hostel_management/migrations/0008_studentdetails.py b/FusionIIIT/applications/hostel_management/migrations/0008_studentdetails.py new file mode 100644 index 000000000..b6ce6c44e --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0008_studentdetails.py @@ -0,0 +1,27 @@ +# Generated by Django 3.1.5 on 2024-02-18 23:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0007_hostelleave_status'), + ] + + operations = [ + migrations.CreateModel( + name='StudentDetails', + fields=[ + ('id', models.CharField(max_length=20, primary_key=True, serialize=False)), + ('first_name', models.CharField(max_length=100)), + ('last_name', models.CharField(max_length=100)), + ('programme', models.CharField(max_length=100)), + ('batch', models.CharField(max_length=100)), + ('room_num', models.CharField(max_length=20)), + ('specialization', models.CharField(max_length=100)), + ('parent_contact', models.CharField(blank=True, max_length=20, null=True)), + ('address', models.CharField(blank=True, max_length=255, null=True)), + ], + ), + ] diff --git a/FusionIIIT/applications/hostel_management/migrations/0009_auto_20240219_0203.py b/FusionIIIT/applications/hostel_management/migrations/0009_auto_20240219_0203.py new file mode 100644 index 000000000..2b920737e --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0009_auto_20240219_0203.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.5 on 2024-02-19 02:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0008_studentdetails'), + ] + + operations = [ + migrations.AddField( + model_name='studentdetails', + name='hall_no', + field=models.CharField(blank=True, max_length=20, null=True), + ), + migrations.AlterField( + model_name='studentdetails', + name='first_name', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='studentdetails', + name='last_name', + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/migrations/0010_auto_20240219_0205.py b/FusionIIIT/applications/hostel_management/migrations/0010_auto_20240219_0205.py new file mode 100644 index 000000000..7525ddde9 --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0010_auto_20240219_0205.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-02-19 02:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0009_auto_20240219_0203'), + ] + + operations = [ + migrations.AlterField( + model_name='studentdetails', + name='room_num', + field=models.CharField(blank=True, max_length=20, null=True), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/migrations/0011_auto_20240219_0207.py b/FusionIIIT/applications/hostel_management/migrations/0011_auto_20240219_0207.py new file mode 100644 index 000000000..aaba22121 --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0011_auto_20240219_0207.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.5 on 2024-02-19 02:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0010_auto_20240219_0205'), + ] + + operations = [ + migrations.AlterField( + model_name='studentdetails', + name='batch', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='studentdetails', + name='programme', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='studentdetails', + name='specialization', + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/models.py b/FusionIIIT/applications/hostel_management/models.py index d09f920e9..c478ce74f 100644 --- a/FusionIIIT/applications/hostel_management/models.py +++ b/FusionIIIT/applications/hostel_management/models.py @@ -286,4 +286,20 @@ def __str__(self): +class StudentDetails(models.Model): + id = models.CharField(primary_key=True, max_length=20) + first_name = models.CharField(max_length=100,blank=True,null=True) + last_name = models.CharField(max_length=100,blank=True,null=True) + programme = models.CharField(max_length=100,blank=True,null=True) + batch = models.CharField(max_length=100,blank=True,null=True) + room_num= models.CharField(max_length=20,blank=True,null=True) + hall_no= models.CharField(max_length=20,blank=True,null=True) + specialization = models.CharField(max_length=100,blank=True,null=True) + parent_contact = models.CharField(max_length=20, blank=True, null=True) + address = models.CharField(max_length=255, blank=True, null=True) + + def __str__(self): + return self.first_name + ' ' + self.last_name + + From 645b2d841e92114e95216791ede9b149ac17eb7f Mon Sep 17 00:00:00 2001 From: Stark Date: Mon, 19 Feb 2024 04:17:10 +0530 Subject: [PATCH 039/158] chore: Added functionality - caretaker and warden can get all details of student of their hall -----used StudentDetails table --- .../applications/hostel_management/urls.py | 2 + .../applications/hostel_management/views.py | 35 +++++++++++++-- .../hostelmanagement/student_details.html | 43 +++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 FusionIIIT/templates/hostelmanagement/student_details.html diff --git a/FusionIIIT/applications/hostel_management/urls.py b/FusionIIIT/applications/hostel_management/urls.py index 10d4c514e..11d8c2a6e 100644 --- a/FusionIIIT/applications/hostel_management/urls.py +++ b/FusionIIIT/applications/hostel_management/urls.py @@ -45,6 +45,8 @@ # Student can view his leave status path('my_leaves/', views.my_leaves.as_view(), name='my_leaves'), + path('get_students/', views.get_students, name='get_students'), + diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index b8be29f66..57d6e5aff 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -3,7 +3,12 @@ from django.shortcuts import render, HttpResponse from django.views.decorators.csrf import csrf_exempt from rest_framework.permissions import IsAuthenticated +from .models import HallCaretaker,HallWarden from django.urls import reverse +from .models import StudentDetails +from rest_framework.exceptions import APIException + + from django.shortcuts import render, redirect from .models import HostelLeave @@ -528,10 +533,33 @@ def hostel_complaint_list(request): else: return HttpResponse('') - - - +from django.http import JsonResponse, HttpResponse +from django.shortcuts import redirect +from django.contrib.auth.decorators import login_required +from applications.hostel_management.models import HallCaretaker, HallWarden +@login_required +def get_students(request): + try: + staff = request.user.extrainfo.id + print(staff) + except AttributeError: + staff = None + + if HallCaretaker.objects.filter(staff_id=staff).exists(): + hall_id = HallCaretaker.objects.get(staff_id=staff).hall_id + print(hall_id) + student_details = StudentDetails.objects.filter(hall_no=hall_id) + + return render(request, 'hostelmanagement/student_details.html', {'students': student_details}) + + elif HallWarden.objects.filter(faculty_id=staff).exists(): + hall_id = HallWarden.objects.get(faculty_id=staff).hall_id + student_details = StudentDetails.objects.filter(hall_no=hall_id) + + return render(request, 'hostelmanagement/student_details.html', {'students': student_details}) + else: + return HttpResponse('') # Student can post complaints @@ -610,3 +638,4 @@ def update_leave_status(request): return JsonResponse({'status': 'error', 'message': 'Leave not found.'}, status=404) else: return JsonResponse({'status': 'error', 'message': 'Only POST requests are allowed.'}, status=405) + diff --git a/FusionIIIT/templates/hostelmanagement/student_details.html b/FusionIIIT/templates/hostelmanagement/student_details.html new file mode 100644 index 000000000..3d570bec7 --- /dev/null +++ b/FusionIIIT/templates/hostelmanagement/student_details.html @@ -0,0 +1,43 @@ + + + + + + Student Details + + +

Student Details

+ + + + + + + + + + + + + + + + + {% for student in students %} + + + + + + + + + + + + + {% endfor %} + +
IDFirst NameLast NameProgrammeBatchRoom NumberHall NumberSpecializationParent ContactAddress
{{ student.id }}{{ student.first_name }}{{ student.last_name }}{{ student.programme }}{{ student.batch }}{{ student.room_num }}{{ student.hall_no }}{{ student.specialization }}{{ student.parent_contact }}{{ student.address }}
+ + From 2c38d19b7799f7fbc5bf2aab5556df400d0d0218 Mon Sep 17 00:00:00 2001 From: ANKIT Date: Mon, 19 Feb 2024 06:09:59 +0530 Subject: [PATCH 040/158] guest room part done --- .../migrations/0008_auto_20240219_0450.py | 18 ++ .../applications/hostel_management/admin.py | 2 +- .../migrations/0008_auto_20240219_0450.py | 52 ++++ .../applications/hostel_management/models.py | 28 +- .../applications/hostel_management/views.py | 39 ++- .../book_guest_room_status.html | 51 ++++ .../templates/hostelmanagement/hostel.html | 254 ++++++++++-------- .../hostelmanagement/request_list.html | 97 +++++++ .../hostelmanagement/update_guest_room.html | 28 ++ 9 files changed, 431 insertions(+), 138 deletions(-) create mode 100644 FusionIIIT/applications/globals/migrations/0008_auto_20240219_0450.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0008_auto_20240219_0450.py create mode 100644 FusionIIIT/templates/hostelmanagement/book_guest_room_status.html create mode 100644 FusionIIIT/templates/hostelmanagement/request_list.html create mode 100644 FusionIIIT/templates/hostelmanagement/update_guest_room.html diff --git a/FusionIIIT/applications/globals/migrations/0008_auto_20240219_0450.py b/FusionIIIT/applications/globals/migrations/0008_auto_20240219_0450.py new file mode 100644 index 000000000..878a3256b --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0008_auto_20240219_0450.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-02-19 04:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0007_auto_20240218_2017'), + ] + + operations = [ + migrations.AlterField( + model_name='extrainfo', + name='user_status', + field=models.CharField(choices=[('PRESENT', 'PRESENT'), ('NEW', 'NEW')], default='PRESENT', max_length=50), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/admin.py b/FusionIIIT/applications/hostel_management/admin.py index ef37d3e92..786affe5a 100644 --- a/FusionIIIT/applications/hostel_management/admin.py +++ b/FusionIIIT/applications/hostel_management/admin.py @@ -5,7 +5,7 @@ admin.site.register(Hall) admin.site.register(HallCaretaker) admin.site.register(HallWarden) -admin.site.register(GuestRoomDetail) + admin.site.register(GuestRoomBooking) admin.site.register(StaffSchedule) admin.site.register(HostelNoticeBoard) diff --git a/FusionIIIT/applications/hostel_management/migrations/0008_auto_20240219_0450.py b/FusionIIIT/applications/hostel_management/migrations/0008_auto_20240219_0450.py new file mode 100644 index 000000000..b2354f20f --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0008_auto_20240219_0450.py @@ -0,0 +1,52 @@ +# Generated by Django 3.1.5 on 2024-02-19 04:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0007_auto_20240218_2028'), + ] + + operations = [ + + migrations.AlterField( + model_name='guestroombooking', + name='guest_email', + field=models.CharField(blank=True, max_length=255), + ), + migrations.AlterField( + model_name='guestroombooking', + name='guest_name', + field=models.CharField(max_length=255), + ), + migrations.AlterField( + model_name='guestroombooking', + name='guest_phone', + field=models.CharField(max_length=255), + ), + migrations.RemoveField( + model_name='guestroombooking', + name='guest_room_id', + ), + migrations.AddField( + model_name='guestroombooking', + name='guest_room_id', + field=models.CharField(blank=True, max_length=255), + ), + migrations.AlterField( + model_name='guestroombooking', + name='nationality', + field=models.CharField(blank=True, max_length=255), + ), + migrations.AlterField( + model_name='guestroombooking', + name='status', + field=models.CharField(choices=[('Confirmed', 'Confirmed'), ('Pending', 'Pending'), ('Rejected', 'Rejected'), ('Canceled', 'Canceled'), ('CancelRequested', 'Cancel Requested'), ('CheckedIn', 'Checked In'), ('Complete', 'Complete'), ('Forward', 'Forward')], default='Pending', max_length=255), + ), + migrations.DeleteModel( + name='GuestRoomDetail', + ), + + ] diff --git a/FusionIIIT/applications/hostel_management/models.py b/FusionIIIT/applications/hostel_management/models.py index 2dab89367..5f62812ba 100644 --- a/FusionIIIT/applications/hostel_management/models.py +++ b/FusionIIIT/applications/hostel_management/models.py @@ -82,20 +82,7 @@ def __str__(self): return str(self.hall) + ' (' + str(self.faculty.id.user.username) + ')' -class GuestRoomDetail(models.Model): - """ - Records information related to guest rooms in Hall of Residences. - 'hall' refers to the related Hall of Residence. - 'room_no' stores the guest room number. - 'room_status' stores the current status of the guest room from the available choices in 'ROOM_STATUS'. - """ - hall = models.ForeignKey(Hall, on_delete=models.CASCADE) - room_no = models.CharField(max_length=4, unique=True) - room_status = models.CharField(max_length=20, choices=HostelManagementConstants.ROOM_STATUS, default='Available') - - def __str__(self): - return self.room_no class GuestRoomBooking(models.Model): @@ -117,26 +104,27 @@ class GuestRoomBooking(models.Model): """ hall = models.ForeignKey(Hall, on_delete=models.CASCADE) intender = models.ForeignKey(User, on_delete=models.CASCADE) - guest_name = models.CharField(max_length=100) - guest_phone = models.CharField(max_length=15) - guest_email = models.CharField(max_length=40, blank=True) + guest_name = models.CharField(max_length=255) + guest_phone = models.CharField(max_length=255) + guest_email = models.CharField(max_length=255, blank=True) guest_address = models.TextField(blank=True) - rooms_required = models.IntegerField(default=1,null=True,blank=True) - guest_room_id = models.ManyToManyField(GuestRoomDetail) + rooms_required = models.IntegerField(default=1, null=True, blank=True) + guest_room_id = models.CharField(max_length=255, blank=True) total_guest = models.IntegerField(default=1) purpose = models.TextField() arrival_date = models.DateField(auto_now_add=False, auto_now=False) arrival_time = models.TimeField(auto_now_add=False, auto_now=False) departure_date = models.DateField(auto_now_add=False, auto_now=False) departure_time = models.TimeField(auto_now_add=False, auto_now=False) - status = models.CharField(max_length=15, choices=HostelManagementConstants.BOOKING_STATUS ,default ="Pending") + status = models.CharField(max_length=255, choices=HostelManagementConstants.BOOKING_STATUS ,default ="Pending") booking_date = models.DateField(auto_now_add=False, auto_now=False, default=timezone.now) - nationality = models.CharField(max_length=20, blank=True) + nationality = models.CharField(max_length=255, blank=True) def __str__(self): return '%s ----> %s - %s' % (self.id, self.guest_name, self.status) + class StaffSchedule(models.Model): """ Records schedule of staffs in various Hall of Residences. diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index 2d4f44cd4..64b881abd 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -69,6 +69,7 @@ def is_superuser(user): from django.db import IntegrityError + @login_required def hostel_view(request, context={}): """ @@ -103,6 +104,15 @@ def hostel_view(request, context={}): hall_notices[hall.hall_id] = HostelNoticeBoard.objects.filter( hall=hall).select_related('hall', 'posted_by__user') + pending_guest_room_requests = {} + for hall in all_hall: + pending_guest_room_requests[hall.hall_id] = GuestRoomBooking.objects.filter(hall=hall, status='Pending').select_related('hall', 'intender') + guest_rooms = {} + for hall in all_hall: + guest_rooms[hall.hall_id] = GuestRoom.objects.filter(hall=hall).select_related('hall') + user_guest_room_requests = GuestRoomBooking.objects.filter(intender=request.user).order_by("-arrival_date") + + Staff_obj = Staff.objects.all().select_related('id__user') hall1 = Hall.objects.get(hall_id='hall1') hall3 = Hall.objects.get(hall_id='hall3') @@ -137,6 +147,11 @@ def hostel_view(request, context={}): for warden in hall_wardens: hall_warden_user.append(warden.faculty.id.user) + all_students = Student.objects.all().select_related('id__user') + all_students_id = [] + for student in all_students: + all_students_id.append(student.id_id) + todays_date = date.today() current_year = todays_date.year current_month = todays_date.month @@ -172,6 +187,10 @@ def hostel_view(request, context={}): 'hall_staffs': hall_staffs, 'hall_notices': hall_notices, 'attendance': halls_attendance, + 'guest_rooms': guest_rooms, + 'pending_guest_room_requests': pending_guest_room_requests, + 'user_guest_room_requests': user_guest_room_requests, + 'all_students_id': all_students_id, **context } @@ -1120,17 +1139,29 @@ def update_guest_room(request): if 'accept_request' in request.POST: status = request.POST['status'] guest_room_request = GuestRoomBooking.objects.get(pk=request.POST['accept_request']) - guest_room_request.status = status - guest_room_request.guest_room_id = request.POST['guest_room_id'] + guest_room_instance = GuestRoom.objects.get(hall=guest_room_request.hall, room=request.POST['guest_room_id']) + + # Assign the guest room ID to guest_room_id field + guest_room_request.guest_room_id = str(guest_room_instance.id) + room_booked = GuestRoom.objects.get(hall=guest_room_request.hall, room=request.POST['guest_room_id']) room_booked.occupied_till = guest_room_request.departure_date room_booked.save() + # Save the guest room request after updating the fields + guest_room_request.status = status guest_room_request.save() messages.success(request, "Request accepted successfully!") elif 'reject_request' in request.POST: guest_room_request = GuestRoomBooking.objects.get(pk=request.POST['reject_request']) - guest_room_request.delete() + guest_room_request.status = 'Rejected' + guest_room_request.save() + messages.success(request, "Request rejected successfully!") else: messages.error(request, "Invalid request!") - return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) \ No newline at end of file + return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) + + + + + diff --git a/FusionIIIT/templates/hostelmanagement/book_guest_room_status.html b/FusionIIIT/templates/hostelmanagement/book_guest_room_status.html new file mode 100644 index 000000000..8faba8964 --- /dev/null +++ b/FusionIIIT/templates/hostelmanagement/book_guest_room_status.html @@ -0,0 +1,51 @@ +{% block book_guest_room_status %} + {% for user_request in user_guest_room_requests %} +
+
+
+

Room for {{user_request.total_guest}} in {{user_request.hall.hall_id}}

+
+
+ + + + + + + + + + + + + + + + + + + + + + +
Requested ForContactArrivalDepartureStatus
{{user_request.guest_name}}{{user_request.guest_phone}}{{user_request.arrival_date}}{{user_request.departure_date}}{{user_request.status}}
+
+
+ + Reason +
+
+

Description

+ +
+
+
+
+
+
+ +
+
+
+ {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/hostel.html b/FusionIIIT/templates/hostelmanagement/hostel.html index c2fc06f20..6fb082988 100644 --- a/FusionIIIT/templates/hostelmanagement/hostel.html +++ b/FusionIIIT/templates/hostelmanagement/hostel.html @@ -2,145 +2,173 @@ {% load static %} {% block title %} - Hostel +Hostel {% endblock %} {% block body %} - {% block navBar %} - {% include 'dashboard/navbar.html' %} - {% endblock %} - +{% block navBar %} +{% include 'dashboard/navbar.html' %} +{% endblock %} -
-
+
-
+
-
- {% block userCard %} - {% include 'globals/usercard.html' %} - {% endblock %} -
+
-
- -
- +
+ {% block userCard %} + {% include 'globals/usercard.html' %} + {% endblock %} +
+
+ +
+
-
-
- {% block alloted_hostel_room %} - {% include 'hostelmanagement/alloted_hostel_room.html'%} - {% endblock %} -
+
- {% if user in hall_caretaker or hall_warden%} -
- {% block staff_schedule %} - {% include 'hostelmanagement/staff_schedule.html'%} - {% endblock %} -
- {% endif %} +
+
+ {% block alloted_hostel_room %} + {% include 'hostelmanagement/alloted_hostel_room.html'%} + {% endblock %} +
-
- {% block notice_board %} - {% include 'hostelmanagement/notice.html'%} - {% endblock %} -
+ {% if user in hall_caretaker or hall_warden%} +
+ {% block staff_schedule %} + {% include 'hostelmanagement/staff_schedule.html'%} + {% endblock %} +
+ {% endif %} -
- {% block attendance %} - {% include 'hostelmanagement/attendance.html' %} - {% endblock %} -
+
+ {% block notice_board %} + {% include 'hostelmanagement/notice.html'%} + {% endblock %} +
- {% if user not in hall_caretaker and user not in hall_warden%} -
- {% block book_guest_room %} - {% include 'hostelmanagement/book_guest_room.html' %} - {% endblock %} -
- {% endif %} +
+ {% block attendance %} + {% include 'hostelmanagement/attendance.html' %} + {% endblock %} +
+ + {% if user.username in all_students_id %} +
+ {% block book_guest_room %} + {% include 'hostelmanagement/book_guest_room.html' %} + {% endblock %} +
+ {% endif %} - {% comment %}
- {% block guest_room %} - {% include 'hostelmanagement/guestroom_booking.html'%} - {% endblock %} -
{% endcomment %} + {% if user in hall_caretaker or hall_warden%} +
+ {% block request_list %} + {% include 'hostelmanagement/update_guest_room.html' %} + {% endblock %} +
+ {% endif %} + {% if user.username in all_students_id %} +
+ {% block book_guest_room_status %} + {% include 'hostelmanagement/book_guest_room_status.html' %} + {% endblock %}
+ {% endif %} + + + + +
+
+ {% endblock %} {% block javascript %} -{% endblock %} - +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/request_list.html b/FusionIIIT/templates/hostelmanagement/request_list.html new file mode 100644 index 000000000..57217aee2 --- /dev/null +++ b/FusionIIIT/templates/hostelmanagement/request_list.html @@ -0,0 +1,97 @@ +{% load custom_tags %} + +{% block {{hall.hall_id}} %} + {% for pending_request in pending_guest_room_requests|get_hall_no:hall_id %} +
+
+
+

Room for {{pending_request.total_guest}} in {{pending_request.hall.hall_id}}

+
+
+ + + + + + + + + + + + + + + + + + + + + + +
Requested ByGuest NameGuest PhoneArrivalDeparture
{{pending_request.intender}}{{pending_request.guest_name}}{{pending_request.guest_phone}}{{pending_request.arrival_date}}{{pending_request.departure_date}}
+
+
+ + Reason +
+
+

Description

+ +
+
+
+
+
+
+
+ {% if user in hall_caretaker or user in hall_warden %} + {% ifequal current_hall pending_request.hall.hall_id %} +
+ {% csrf_token %} +
+ + +
+ + +
+
+
+ +
+
+ + {% endifequal %} + {% endif %} +
+
+
+
+ {% endfor %} +{% endblock %} + + + diff --git a/FusionIIIT/templates/hostelmanagement/update_guest_room.html b/FusionIIIT/templates/hostelmanagement/update_guest_room.html new file mode 100644 index 000000000..0ded23d9f --- /dev/null +++ b/FusionIIIT/templates/hostelmanagement/update_guest_room.html @@ -0,0 +1,28 @@ +{% load static %} +{% block request_list %} + + + +{% for hall in all_hall %} +
+
+ {% block {{hall.hall_id}} %} + {% include 'hostelmanagement/request_list.html' with hall_id=hall.hall_id %} + {% endblock %} +
+
+{% endfor %} + +{% endblock %} \ No newline at end of file From 50107df6daabf274e338073b2fdefc5793074e40 Mon Sep 17 00:00:00 2001 From: Anuj Patel Date: Mon, 19 Feb 2024 12:26:29 +0530 Subject: [PATCH 041/158] added templates for hostel_complaint,inventory_form,my_leaves --- .../migrations/0005_merge_20240218_2206.py | 14 ++ .../migrations/0005_merge_20240218_2206.py | 14 ++ .../migrations/0007_merge_20240218_2205.py | 14 ++ .../migrations/0008_merge_20240218_2206.py | 16 ++ .../applications/hostel_management/views.py | 158 ++++++++++-------- .../migrations/0005_merge_20240218_2206.py | 14 ++ .../migrations/0005_merge_20240218_2205.py | 14 ++ .../hostelmanagement/all_leave_data.html | 51 +++--- .../hostelmanagement/create_leave.html | 16 +- .../templates/hostelmanagement/hostel.html | 63 ++++++- .../hostelmanagement/hostel_complaint.html | 141 +++------------- .../hostelmanagement/inventory_form.html | 120 ++++++------- .../templates/hostelmanagement/my_leaves.html | 19 +-- 13 files changed, 354 insertions(+), 300 deletions(-) create mode 100644 FusionIIIT/applications/academic_procedures/migrations/0005_merge_20240218_2206.py create mode 100644 FusionIIIT/applications/eis/migrations/0005_merge_20240218_2206.py create mode 100644 FusionIIIT/applications/globals/migrations/0007_merge_20240218_2205.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0008_merge_20240218_2206.py create mode 100644 FusionIIIT/applications/programme_curriculum/migrations/0005_merge_20240218_2206.py create mode 100644 FusionIIIT/applications/scholarships/migrations/0005_merge_20240218_2205.py diff --git a/FusionIIIT/applications/academic_procedures/migrations/0005_merge_20240218_2206.py b/FusionIIIT/applications/academic_procedures/migrations/0005_merge_20240218_2206.py new file mode 100644 index 000000000..bccc5f90b --- /dev/null +++ b/FusionIIIT/applications/academic_procedures/migrations/0005_merge_20240218_2206.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-18 22:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('academic_procedures', '0002_auto_20240216_2018'), + ('academic_procedures', '0004_merge_20240217_2302'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/eis/migrations/0005_merge_20240218_2206.py b/FusionIIIT/applications/eis/migrations/0005_merge_20240218_2206.py new file mode 100644 index 000000000..ea165ac93 --- /dev/null +++ b/FusionIIIT/applications/eis/migrations/0005_merge_20240218_2206.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-18 22:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('eis', '0002_auto_20240216_2018'), + ('eis', '0004_merge_20240217_2302'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/globals/migrations/0007_merge_20240218_2205.py b/FusionIIIT/applications/globals/migrations/0007_merge_20240218_2205.py new file mode 100644 index 000000000..d99c363cd --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0007_merge_20240218_2205.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-18 22:05 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0006_auto_20240218_1336'), + ('globals', '0002_auto_20240217_1949'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/hostel_management/migrations/0008_merge_20240218_2206.py b/FusionIIIT/applications/hostel_management/migrations/0008_merge_20240218_2206.py new file mode 100644 index 000000000..7f7d1e5a7 --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0008_merge_20240218_2206.py @@ -0,0 +1,16 @@ +# Generated by Django 3.1.5 on 2024-02-18 22:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0005_auto_20240217_1949'), + ('hostel_management', '0002_hostelinventory'), + ('hostel_management', '0007_hostelleave_status'), + ('hostel_management', '0005_merge_20240217_2302'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index 4e4790c0f..1f3782627 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -128,7 +128,11 @@ def hostel_view(request, context={}): hall4_staff = StaffSchedule.objects.filter(hall=hall4) hall_caretakers = HallCaretaker.objects.all().select_related() hall_wardens = HallWarden.objects.all().select_related() - + all_students = Student.objects.all().select_related('id__user') + all_students_id = [] + for student in all_students: + all_students_id.append(student.id_id) + # print(all_students) hall_student = "" current_hall = "" get_avail_room = [] @@ -169,6 +173,18 @@ def hostel_view(request, context={}): for hall in all_hall: halls_attendance[hall.hall_id] = HostelStudentAttendence.objects.filter( hall=hall).select_related() + + user_complaints = HostelComplaint.objects.filter(roll_number=request.user.username) + user_leaves = HostelLeave.objects.filter(roll_num=request.user.username) + my_leaves = [] + for leave in user_leaves: + my_leaves.append(leave) + my_complaints = [] + for complaint in user_complaints: + my_complaints.append(complaint) + + all_leaves = HostelLeave.objects.all() + all_complaints = HostelComplaint.objects.all() context = { @@ -188,6 +204,11 @@ def hostel_view(request, context={}): 'hall_staffs': hall_staffs, 'hall_notices': hall_notices, 'attendance': halls_attendance, + 'all_students_id': all_students_id, + 'my_complaints': my_complaints, + 'my_leaves': my_leaves, + 'all_leaves': all_leaves, + 'all_complaints': all_complaints, **context } @@ -630,7 +651,6 @@ def get(self, request, *args, **kwargs): # Retrieve leaves registered by the current student based on their roll number my_leaves = HostelLeave.objects.filter(roll_num__iexact=user_id) - # Construct the context to pass to the template context = { 'leaves': my_leaves @@ -659,91 +679,91 @@ def get(self, request, *args, **kwargs): -@method_decorator(user_passes_test(is_superuser), name='dispatch') -class AssignCaretakerView(APIView): - authentication_classes = [SessionAuthentication] - permission_classes = [IsAuthenticated] - template_name = 'hostelmanagement/assign_caretaker.html' +# @method_decorator(user_passes_test(is_superuser), name='dispatch') +# class AssignCaretakerView(APIView): +# authentication_classes = [SessionAuthentication] +# permission_classes = [IsAuthenticated] +# template_name = 'hostelmanagement/assign_caretaker.html' - def get(self, request, *args, **kwargs): - hall = Hall.objects.all() - caretaker_usernames=Staff.objects.all() - return render(request, self.template_name , {'halls': hall,'caretaker_usernames':caretaker_usernames}) +# def get(self, request, *args, **kwargs): +# hall = Hall.objects.all() +# caretaker_usernames=Staff.objects.all() +# return render(request, self.template_name , {'halls': hall,'caretaker_usernames':caretaker_usernames}) - def post(self, request, *args, **kwargs): - hall_id = request.data.get('hall_id') - caretaker_username = request.data.get('caretaker_username') +# def post(self, request, *args, **kwargs): +# hall_id = request.data.get('hall_id') +# caretaker_username = request.data.get('caretaker_username') - try: - hall = Hall.objects.get(hall_id=hall_id) - caretaker_staff = Staff.objects.get(id__user__username=caretaker_username) +# try: +# hall = Hall.objects.get(hall_id=hall_id) +# caretaker_staff = Staff.objects.get(id__user__username=caretaker_username) - # Delete any previous assignments of the caretaker in HallCaretaker table - HallCaretaker.objects.filter(staff=caretaker_staff).delete() +# # Delete any previous assignments of the caretaker in HallCaretaker table +# HallCaretaker.objects.filter(staff=caretaker_staff).delete() - # Delete any previous assignments of the caretaker in RoomAllotment table - HostelAllotment.objects.filter(assignedCaretaker=caretaker_staff).delete() +# # Delete any previous assignments of the caretaker in RoomAllotment table +# HostelAllotment.objects.filter(assignedCaretaker=caretaker_staff).delete() - # Delete any previously assigned caretaker to the same hall - HallCaretaker.objects.filter(hall=hall).delete() +# # Delete any previously assigned caretaker to the same hall +# HallCaretaker.objects.filter(hall=hall).delete() - # Assign the new caretaker to the hall in HallCaretaker table - hall_caretaker = HallCaretaker.objects.create(hall=hall, staff=caretaker_staff) +# # Assign the new caretaker to the hall in HallCaretaker table +# hall_caretaker = HallCaretaker.objects.create(hall=hall, staff=caretaker_staff) - # Update the assigned caretaker in Hostelallottment table - hostel_allotments = HostelAllotment.objects.filter(hall=hall) - for hostel_allotment in hostel_allotments: - hostel_allotment.assignedCaretaker = caretaker_staff - hostel_allotment.save() +# # Update the assigned caretaker in Hostelallottment table +# hostel_allotments = HostelAllotment.objects.filter(hall=hall) +# for hostel_allotment in hostel_allotments: +# hostel_allotment.assignedCaretaker = caretaker_staff +# hostel_allotment.save() - return Response({'message': f'Caretaker {caretaker_username} assigned to Hall {hall_id} successfully'}, status=status.HTTP_201_CREATED) +# return Response({'message': f'Caretaker {caretaker_username} assigned to Hall {hall_id} successfully'}, status=status.HTTP_201_CREATED) - except Hall.DoesNotExist: - return Response({'error': f'Hall with ID {hall_id} not found'}, status=status.HTTP_404_NOT_FOUND) - except Staff.DoesNotExist: - return Response({'error': f'Caretaker with username {caretaker_username} not found'}, status=status.HTTP_404_NOT_FOUND) - except Exception as e: - return JsonResponse({'status': 'error', 'error': str(e)}, status=500) +# except Hall.DoesNotExist: +# return Response({'error': f'Hall with ID {hall_id} not found'}, status=status.HTTP_404_NOT_FOUND) +# except Staff.DoesNotExist: +# return Response({'error': f'Caretaker with username {caretaker_username} not found'}, status=status.HTTP_404_NOT_FOUND) +# except Exception as e: +# return JsonResponse({'status': 'error', 'error': str(e)}, status=500) -@method_decorator(user_passes_test(is_superuser), name='dispatch') -class AssignBatchView(View): - authentication_classes = [SessionAuthentication] - permission_classes = [IsAuthenticated] - template_name = 'hostelmanagement/assign_batch.html' # Assuming the HTML file is directly in the 'templates' folder +# @method_decorator(user_passes_test(is_superuser), name='dispatch') +# class AssignBatchView(View): +# authentication_classes = [SessionAuthentication] +# permission_classes = [IsAuthenticated] +# template_name = 'hostelmanagement/assign_batch.html' # Assuming the HTML file is directly in the 'templates' folder - def get(self, request, *args, **kwargs): - hall = Hall.objects.all() - return render(request, self.template_name , {'halls': hall}) - - def post(self, request, *args, **kwargs): - try: - data = json.loads(request.body.decode('utf-8')) - hall_id = data.get('hall_id') - - hall = Hall.objects.get(hall_id=hall_id) - hall.assigned_batch = data.get('batch') - hall.save() - - # Update the assignedBatch field in HostelAllotment table for the corresponding hall - room_allotments = HostelAllotment.objects.filter(hall=hall) - for room_allotment in room_allotments: - room_allotment.assignedBatch = hall.assigned_batch - room_allotment.save() - - return JsonResponse({'status': 'success', 'message': 'Batch assigned successfully'}, status=200) +# def get(self, request, *args, **kwargs): +# hall = Hall.objects.all() +# return render(request, self.template_name , {'halls': hall}) + +# def post(self, request, *args, **kwargs): +# try: +# data = json.loads(request.body.decode('utf-8')) +# hall_id = data.get('hall_id') + +# hall = Hall.objects.get(hall_id=hall_id) +# hall.assigned_batch = data.get('batch') +# hall.save() + +# # Update the assignedBatch field in HostelAllotment table for the corresponding hall +# room_allotments = HostelAllotment.objects.filter(hall=hall) +# for room_allotment in room_allotments: +# room_allotment.assignedBatch = hall.assigned_batch +# room_allotment.save() + +# return JsonResponse({'status': 'success', 'message': 'Batch assigned successfully'}, status=200) - except Hall.DoesNotExist: - return JsonResponse({'status': 'error', 'error': f'Hall with ID {hall_id} not found'}, status=404) +# except Hall.DoesNotExist: +# return JsonResponse({'status': 'error', 'error': f'Hall with ID {hall_id} not found'}, status=404) - except Exception as e: - return JsonResponse({'status': 'error', 'error': str(e)}, status=500) +# except Exception as e: +# return JsonResponse({'status': 'error', 'error': str(e)}, status=500) - def test_func(self): - # Check if the user is a superuser - return self.request.user.is_superuser +# def test_func(self): +# # Check if the user is a superuser +# return self.request.user.is_superuser class HallIdView(APIView): authentication_classes = [] # Allow public access for testing diff --git a/FusionIIIT/applications/programme_curriculum/migrations/0005_merge_20240218_2206.py b/FusionIIIT/applications/programme_curriculum/migrations/0005_merge_20240218_2206.py new file mode 100644 index 000000000..c5b217944 --- /dev/null +++ b/FusionIIIT/applications/programme_curriculum/migrations/0005_merge_20240218_2206.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-18 22:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('programme_curriculum', '0002_auto_20240216_2018'), + ('programme_curriculum', '0004_merge_20240217_2302'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/scholarships/migrations/0005_merge_20240218_2205.py b/FusionIIIT/applications/scholarships/migrations/0005_merge_20240218_2205.py new file mode 100644 index 000000000..f91c717f8 --- /dev/null +++ b/FusionIIIT/applications/scholarships/migrations/0005_merge_20240218_2205.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-18 22:05 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('scholarships', '0002_auto_20240216_2018'), + ('scholarships', '0004_merge_20240217_2302'), + ] + + operations = [ + ] diff --git a/FusionIIIT/templates/hostelmanagement/all_leave_data.html b/FusionIIIT/templates/hostelmanagement/all_leave_data.html index b86640551..296eb3c55 100644 --- a/FusionIIIT/templates/hostelmanagement/all_leave_data.html +++ b/FusionIIIT/templates/hostelmanagement/all_leave_data.html @@ -1,15 +1,6 @@ - - - - - - All Leave Data - - - - -

All Leave Data

- +{% block leave_requests %} +

All Leave Requests

+
@@ -22,8 +13,8 @@

All Leave Data

- {% for leave in all_leave %} - {% if leave.status != 'approved' %} + {% for leave in all_leaves %} + @@ -31,43 +22,52 @@

All Leave Data

- - {% endif %} + {% endfor %}
Student Name
{{ leave.student_name }} {{ leave.roll_num }} {{ leave.start_date }} {{ leave.end_date }} {{ leave.status }} +
{% csrf_token %} - - + +
{% csrf_token %} - - + +
+ + - - \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/create_leave.html b/FusionIIIT/templates/hostelmanagement/create_leave.html index f8b9580d1..091af4436 100644 --- a/FusionIIIT/templates/hostelmanagement/create_leave.html +++ b/FusionIIIT/templates/hostelmanagement/create_leave.html @@ -1,21 +1,27 @@ -{% block create_leave%} +{% block create_leave %}

Leave Form

{% csrf_token %} +


- +
+


- +
+


- +
+


- +
+


+
diff --git a/FusionIIIT/templates/hostelmanagement/hostel.html b/FusionIIIT/templates/hostelmanagement/hostel.html index 494e5623a..afd7000ab 100644 --- a/FusionIIIT/templates/hostelmanagement/hostel.html +++ b/FusionIIIT/templates/hostelmanagement/hostel.html @@ -35,34 +35,67 @@ {% endif %} - {% if user in hall_caretaker or hall_warden%} + {% if user in hall_caretaker or user in hall_warden%} Staff's Schedule {% endif %} - Notice Board + {% if user in hall_caretaker or user in hall_warden %} Student Attendance + {% endif %} + {% if user.username in all_students_id %} Complaint Form - + {% endif %} + + {% if user.username in all_students_id %} Leave Form + {% endif %} + + {% if user.username in all_students_id %} + + Leave Status + + + {% endif %} + + {% if user in hall_caretaker or user in hall_warden %} + + Leave Requests + + + {% endif %} + + {% if user in hall_caretaker or user in hall_warden %} + + Complaints + + + {% endif %} + + {% if user in hall_caretaker or user in hall_warden %} + + Inventory Form + + + {% endif %} {% comment %} Book Guest Room @@ -113,6 +146,30 @@ {% endblock %}
+
+ {% block leave_status %} + {% include 'hostelmanagement/my_leaves.html' %} + {% endblock %} +
+ +
+ {% block leave_requests %} + {% include 'hostelmanagement/all_leave_data.html' %} + {% endblock %} +
+ +
+ {% block all_complaints %} + {% include 'hostelmanagement/hostel_complaint.html' %} + {% endblock %} +
+ +
+ {% block inventory_form %} + {% include 'hostelmanagement/inventory_form.html' %} + {% endblock %} +
+ {% comment %}
{% block guest_room %} {% include 'hostelmanagement/guestroom_booking.html'%} diff --git a/FusionIIIT/templates/hostelmanagement/hostel_complaint.html b/FusionIIIT/templates/hostelmanagement/hostel_complaint.html index b69d99779..393bdfb93 100644 --- a/FusionIIIT/templates/hostelmanagement/hostel_complaint.html +++ b/FusionIIIT/templates/hostelmanagement/hostel_complaint.html @@ -1,118 +1,25 @@ -{% extends 'globals/base.html' %} -{% load static %} - -{% block title %} -Hostel Complaints +{% block all_complaints %} +

Complaints Data

+ + + + + + + + + + + + {% for complaint in all_complaints %} + + + + + + + + {% endfor %} + +
Hall NameStudent NameRoll NumberDescriptionContact Number
{{ complaint.hall_name }}{{ complaint.student_name }}{{ complaint.roll_number }}{{ complaint.description }}{{ complaint.contact_number }}
{% endblock %} - - -{% block body %} -{% block navBar %} -{% include 'dashboard/navbar.html' %} -{% endblock %} - - -
- -
- -
- -
-
-
-

Complaints Data

- - - - - - - - - - - - {% for complaint in complaints %} - - - - - - - - {% endfor %} - -
Hall NameStudent NameRoll NumberDescriptionContact Number
{{ complaint.hall_name }}{{ complaint.student_name }}{{ complaint.roll_number }}{{ complaint.description }}{{ complaint.contact_number }}
-
-
- -
- -
- -{% endblock %} -{% block javascript %} - -{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/inventory_form.html b/FusionIIIT/templates/hostelmanagement/inventory_form.html index 7ea7572a1..c8d149c40 100644 --- a/FusionIIIT/templates/hostelmanagement/inventory_form.html +++ b/FusionIIIT/templates/hostelmanagement/inventory_form.html @@ -1,68 +1,54 @@ - - - - - - Hostel Inventory Form - - -

Hostel Inventory Form

- - {% csrf_token %} - - -

- - -

- - -

- - -

- - - - -
- - - - + .catch((error) => { + console.error("Error:", error); + }); + }); + +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/my_leaves.html b/FusionIIIT/templates/hostelmanagement/my_leaves.html index f2bfa3f79..5c42a7f73 100644 --- a/FusionIIIT/templates/hostelmanagement/my_leaves.html +++ b/FusionIIIT/templates/hostelmanagement/my_leaves.html @@ -1,23 +1,17 @@ - - - - - - My Leaves - - -

My Leaves

- +{% block leave_status %} +

My Leaves

+
+ - {% for leave in leaves %} + {% for leave in my_leaves %} @@ -28,5 +22,4 @@

My Leaves

{% endfor %}
Student Name Reason Start Date End DateStatus
{{ leave.student_name }} {{ leave.reason }}
- - +{% endblock %} From abac924ad632234f3cf25a8d99c5e9e494ad8178 Mon Sep 17 00:00:00 2001 From: Anuj Patel Date: Mon, 19 Feb 2024 13:27:56 +0530 Subject: [PATCH 042/158] added full student details table --- .../migrations/0009_merge_20240219_1303.py | 14 +++++++++++ .../migrations/0010_auto_20240219_1316.py | 18 +++++++++++++++ .../management/commands/copy_data.py | 9 -------- .../migrations/0012_merge_20240219_1303.py | 14 +++++++++++ .../migrations/0013_auto_20240219_1316.py | 23 +++++++++++++++++++ .../applications/hostel_management/models.py | 4 ++-- 6 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 FusionIIIT/applications/globals/migrations/0009_merge_20240219_1303.py create mode 100644 FusionIIIT/applications/globals/migrations/0010_auto_20240219_1316.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0012_merge_20240219_1303.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0013_auto_20240219_1316.py diff --git a/FusionIIIT/applications/globals/migrations/0009_merge_20240219_1303.py b/FusionIIIT/applications/globals/migrations/0009_merge_20240219_1303.py new file mode 100644 index 000000000..d93c60694 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0009_merge_20240219_1303.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 13:03 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0008_auto_20240219_0205'), + ('globals', '0007_merge_20240218_2205'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/globals/migrations/0010_auto_20240219_1316.py b/FusionIIIT/applications/globals/migrations/0010_auto_20240219_1316.py new file mode 100644 index 000000000..ca7443318 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0010_auto_20240219_1316.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-02-19 13:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0009_merge_20240219_1303'), + ] + + operations = [ + migrations.AlterField( + model_name='extrainfo', + name='user_status', + field=models.CharField(choices=[('PRESENT', 'PRESENT'), ('NEW', 'NEW')], default='PRESENT', max_length=50), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/management/commands/copy_data.py b/FusionIIIT/applications/hostel_management/management/commands/copy_data.py index c5fb577f8..370583025 100644 --- a/FusionIIIT/applications/hostel_management/management/commands/copy_data.py +++ b/FusionIIIT/applications/hostel_management/management/commands/copy_data.py @@ -12,17 +12,8 @@ def copy_data(): for student_instance in student_data: # Extract data from the related User instance id = student_instance.id_id - # print(id) user_instance = User.objects.filter(username=id).first(); - # print('name',user_instance.first_name) - print(student_instance.room_no) - print(student_instance.hall_no) user_instance = User.objects.get(username=id) - print(user_instance.username) - - - - # Create a StudentDetails instance using data from the Student and User instances student_details_instance = StudentDetails( diff --git a/FusionIIIT/applications/hostel_management/migrations/0012_merge_20240219_1303.py b/FusionIIIT/applications/hostel_management/migrations/0012_merge_20240219_1303.py new file mode 100644 index 000000000..2d9a3462c --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0012_merge_20240219_1303.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 13:03 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0008_merge_20240218_2206'), + ('hostel_management', '0011_auto_20240219_0207'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/hostel_management/migrations/0013_auto_20240219_1316.py b/FusionIIIT/applications/hostel_management/migrations/0013_auto_20240219_1316.py new file mode 100644 index 000000000..0e733da4f --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0013_auto_20240219_1316.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.5 on 2024-02-19 13:16 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0010_auto_20240219_1316'), + ('hostel_management', '0012_merge_20240219_1303'), + ] + + operations = [ + migrations.AlterField( + model_name='staffschedule', + name='staff_id', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.staff'), + ), + migrations.DeleteModel( + name='HostelAllottment', + ), + ] diff --git a/FusionIIIT/applications/hostel_management/models.py b/FusionIIIT/applications/hostel_management/models.py index 1aa5981b2..fa91c9377 100644 --- a/FusionIIIT/applications/hostel_management/models.py +++ b/FusionIIIT/applications/hostel_management/models.py @@ -313,5 +313,5 @@ def __str__(self): - def __str__(self): - return str(self.hall)+ str(self.assignedCaretaker)+str(self.assignedWarden) + str(self.assignedBatch) + # def __str__(self): + # return str(self.hall)+ str(self.assignedCaretaker)+str(self.assignedWarden) + str(self.assignedBatch) From b59514dc0ea380b90dbc1034a9c2c0c7adf6343a Mon Sep 17 00:00:00 2001 From: Stark Date: Mon, 19 Feb 2024 15:54:07 +0530 Subject: [PATCH 043/158] fix:input fields of complaint and leave form --- FusionIIIT/applications/hostel_management/views.py | 7 +++++-- FusionIIIT/templates/hostelmanagement/create_leave.html | 4 ++-- .../templates/hostelmanagement/post_complaint_form.html | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index 57d6e5aff..78f6453fa 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -492,6 +492,7 @@ def all_leave_data(request): @login_required def create_hostel_leave(request): + print(request.user.username) if request.method == 'GET': return render(request, 'hostelmanagement/create_leave.html') elif request.method == 'POST': @@ -521,7 +522,8 @@ def create_hostel_leave(request): @login_required def hostel_complaint_list(request): - user_id = request.user.id + user_id = request.user.id + try: staff = request.user.extrainfo.id # Assuming the user's profile is stored in extrainfo except AttributeError: @@ -566,8 +568,9 @@ def get_students(request): class PostComplaint(APIView): authentication_classes = [SessionAuthentication] # Assuming you are using session authentication permission_classes = [IsAuthenticated] # Allow only authenticated users to access the view - + def dispatch(self, request, *args, **kwargs): + print(request.user.username) if not request.user.is_authenticated: return redirect('/hostelmanagement') # Redirect to the login page if user is not authenticated return super().dispatch(request, *args, **kwargs) diff --git a/FusionIIIT/templates/hostelmanagement/create_leave.html b/FusionIIIT/templates/hostelmanagement/create_leave.html index 8f422d8b2..fe1ca173a 100644 --- a/FusionIIIT/templates/hostelmanagement/create_leave.html +++ b/FusionIIIT/templates/hostelmanagement/create_leave.html @@ -10,10 +10,10 @@

Create Hostel Leave

{% csrf_token %} -

+

-

+




diff --git a/FusionIIIT/templates/hostelmanagement/post_complaint_form.html b/FusionIIIT/templates/hostelmanagement/post_complaint_form.html index 4c766206e..ad9fec531 100644 --- a/FusionIIIT/templates/hostelmanagement/post_complaint_form.html +++ b/FusionIIIT/templates/hostelmanagement/post_complaint_form.html @@ -13,10 +13,10 @@

Post Complaint




-

+


-

+




From aef9fa45b841af1861b5c678e83ae53c9ebcc060 Mon Sep 17 00:00:00 2001 From: ANKIT Date: Mon, 19 Feb 2024 15:57:18 +0530 Subject: [PATCH 044/158] added funtionality of hostel super admin , guest room --- .DS_Store | Bin 8196 -> 8196 bytes FusionIIIT/.DS_Store | Bin 10244 -> 10244 bytes FusionIIIT/applications/.DS_Store | Bin 10244 -> 10244 bytes .../applications/hostel_management/urls.py | 3 +- .../applications/hostel_management/views.py | 89 +++++-- FusionIIIT/templates/.DS_Store | Bin 0 -> 10244 bytes .../hostelmanagement/add_hostel.html | 236 +++--------------- .../hostelmanagement/admin_hostel_list.html | 145 ++--------- .../hostelmanagement/assign_batch.html | 121 +-------- .../hostelmanagement/assign_caretaker.html | 217 +++++----------- .../hostelmanagement/assign_warden.html | 127 +--------- .../templates/hostelmanagement/hostel.html | 84 ++++++- 12 files changed, 287 insertions(+), 735 deletions(-) create mode 100644 FusionIIIT/templates/.DS_Store diff --git a/.DS_Store b/.DS_Store index a39fc6d91c7382e7dce9ca52bd4153bf1a9fbb1e..ced1c82c96373dc0a5f81b4d166b937bb287029a 100644 GIT binary patch delta 73 zcmZp1XmQvODa^Qia+GkPns{}!rLm5Jp^hv*_|CHVp9niM03N*-kpKVy diff --git a/FusionIIIT/.DS_Store b/FusionIIIT/.DS_Store index a454928e34173342286c477b098d6f187102665d..51de37f1a3cf1279beb94c8af97af82768f1aada 100644 GIT binary patch delta 424 zcmZn(XbG6$LAU^hRb*5n7mGLtm~oEf)I4iG8i60fedG}citG%}xjMnsyibMgxj zdB!fVA_qZk#*33Th^umliA#uyOG%4wzALW5IC+&&ux1!zI%5W7E@K%37%(wHXa-p* z4W$^%K_+c>5tibZd_}B*)!bZ1!F2Lz5t+%Q;wqC1rG?EilgkQ{a`KZH7#Pnc735?V zmlzn_7Z6}%VrF4wW9Q)H;^yJy;};MV5*8E@6cq)!L{w5rQfBg9@w&-r5^>V;0{q1p z`Q@I;`FR0Fsb!g|g4+p8ucL#V5e}1pgN3!kuxMOKQEP2*&zTb!@;1< z;K<<15XO+rP{lBjVJ^c;hTRM&816E>XZXv=&M3*K#Hh_^!f4BA&*;Gz$QZo{JeCaF2;?8PK=w`6@Ia7<`rdT1^_k% BTVVhI delta 73 zcmV-P0Ji^xP=rvBPXQ;fP`eKSCzA{iUz0-=ypsKe^%MgGaQ+vt diff --git a/FusionIIIT/applications/.DS_Store b/FusionIIIT/applications/.DS_Store index d2413951446c48a3e49756e10b20049fa9059a55..fcfccc0add08fec261a53159aa008648d9442e4a 100644 GIT binary patch delta 55 zcmZn(XbISGR+w@7T;kQ$mc}{?hDPR-y+ouLJ13`!$TN0Lo+GTbd5uUk_hvSQ L-z=M%M46cZ6Cn|G delta 55 zcmZn(XbISGR+w?e+!EE*Mh50O3PvU-lRZVG8M`K@ipVo|Po5*Jwt2NkH1}q9 Lg/', views.DeleteHostelView.as_view(), name='delete_hostel'), - + + path('check-hall-exists/', views.CheckHallExistsView.as_view(), name='check_hall_exists'), path('accounts/', include('django.contrib.auth.urls')), path('logout/', views.logout_view, name='logout_view'), # path('logout/', auth_views.LogoutView.as_view(), name='logout'), diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index 64b881abd..c8b0582c2 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -86,6 +86,8 @@ def hostel_view(request, context={}): all_hall - stores all the hall of residence all_notice - stores all notices of hostels (latest first) """ + # Check if the user is a superuser + is_superuser = request.user.is_superuser all_hall = Hall.objects.all() halls_student = {} @@ -113,6 +115,34 @@ def hostel_view(request, context={}): user_guest_room_requests = GuestRoomBooking.objects.filter(intender=request.user).order_by("-arrival_date") + halls = Hall.objects.all() + # Create a list to store additional details + hostel_details = [] + + # Loop through each hall and fetch assignedCaretaker and assignedWarden + for hall in halls: + try: + caretaker = HallCaretaker.objects.filter(hall=hall).first() + warden = HallWarden.objects.filter(hall=hall).first() + except HostelAllotment.DoesNotExist: + assigned_caretaker = None + assigned_warden = None + + hostel_detail = { + 'hall_id': hall.hall_id, + 'hall_name': hall.hall_name, + 'max_accomodation': hall.max_accomodation, + 'number_students': hall.number_students, + 'assigned_batch': hall.assigned_batch, + 'assigned_caretaker': caretaker.staff.id.user.username if caretaker else None, + 'assigned_warden': warden.faculty.id.user.username if warden else None, + } + + hostel_details.append(hostel_detail) + + + + Staff_obj = Staff.objects.all().select_related('id__user') hall1 = Hall.objects.get(hall_id='hall1') hall3 = Hall.objects.get(hall_id='hall3') @@ -169,6 +199,8 @@ def hostel_view(request, context={}): halls_attendance[hall.hall_id] = HostelStudentAttendence.objects.filter( hall=hall).select_related() + add_hostel_form = HallForm() + warden_ids=Faculty.objects.all().select_related('id__user') context = { 'all_hall': all_hall, @@ -191,6 +223,10 @@ def hostel_view(request, context={}): 'pending_guest_room_requests': pending_guest_room_requests, 'user_guest_room_requests': user_guest_room_requests, 'all_students_id': all_students_id, + 'is_superuser': is_superuser, + 'warden_ids':warden_ids, + 'add_hostel_form':add_hostel_form, + 'hostel_details':hostel_details, **context } @@ -655,6 +691,7 @@ def get(self, request, *args, **kwargs): def post(self, request, *args, **kwargs): hall_id = request.data.get('hall_id') + caretaker_username = request.data.get('caretaker_username') try: @@ -756,6 +793,7 @@ def get(self, request, *args, **kwargs): def post(self, request, *args, **kwargs): hall_id = request.data.get('hall_id') + print('~~~~~~~~~~~~~~~~~~~~~~~~~~~',hall_id) caretaker_username = request.data.get('caretaker_username') try: @@ -836,23 +874,19 @@ def test_func(self): class AssignWardenView(APIView): authentication_classes = [SessionAuthentication] permission_classes = [IsAuthenticated] - template_name = 'hostelmanagement/assign_warden.html' - - - def get(self, request, *args, **kwargs): - hall = Hall.objects.all() - warden_ids=Faculty.objects.all() - return render(request, self.template_name , {'halls': hall,'warden_ids':warden_ids}) + template_name = 'hostelmanagement/assign_warden.html' def post(self, request, *args, **kwargs): hall_id = request.data.get('hall_id') warden_id = request.data.get('warden_id') - + print(hall_id) + # print ("this is from view ~~~~~~~~~~~~~~~") + print("~~~~~~~~~~~~~~~~`",warden_id) try: hall = Hall.objects.get(hall_id=hall_id) - warden=Faculty.objects.get(id__user__username=warden_id) - - # print('~~~~~~~~~~~~~~~',warden) + print("helpopppppppooooooooooooooiiiiiii") + warden = Faculty.objects.get(id__user__username=warden_id) + # Delete any previous assignments of the warden in Hallwarden table HallWarden.objects.filter(faculty=warden).delete() @@ -894,19 +928,43 @@ def post(self, request, *args, **kwargs): if form.is_valid(): hall_id = form.cleaned_data['hall_id'] + # # Check if a hall with the given hall_id already exists + # if Hall.objects.filter(hall_id=hall_id).exists(): + # messages.error(request, f'Hall with ID {hall_id} already exists.') + # return redirect('hostelmanagement:add_hostel') + # Check if a hall with the given hall_id already exists if Hall.objects.filter(hall_id=hall_id).exists(): - messages.error(request, f'Hall with ID {hall_id} already exists.') - return redirect('hostelmanagement:add_hostel') + error_message = f'Hall with ID {hall_id} already exists.' + + return HttpResponse(error_message, status=400) # If not, create a new hall form.save() messages.success(request, 'Hall added successfully!') - return redirect('hostelmanagement:admin_hostel_list') # Redirect to the view showing all hostels + return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) # Redirect to the view showing all hostels # If form is not valid, render the form with errors return render(request, self.template_name, {'form': form}) +class CheckHallExistsView(View): + + def get(self, request, *args, **kwargs): + + hall_id = request.GET.get('hall_id') + # hall_id='hall9' + print('~~~~~~~~~~~~~~~~~~~~') + print(hall_id) + try: + hall = Hall.objects.get(hall_id=hall_id) + exists = True + except Hall.DoesNotExist: + exists = False + messages.MessageFailure(request, f'Hall {hall_id} already exist.') + return JsonResponse({'exists': exists}) + + + @method_decorator(user_passes_test(is_superuser), name='dispatch') class AdminHostelListView(View): @@ -954,8 +1012,9 @@ def get(self, request, hall_id, *args, **kwargs): # Delete the hall hall.delete() + messages.success(request, f'Hall {hall_id} deleted successfully.') - return redirect('hostelmanagement:admin_hostel_list') + return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) class HallIdView(APIView): diff --git a/FusionIIIT/templates/.DS_Store b/FusionIIIT/templates/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1c991a0cdb4c7ab749ed346e8acdfd786261fa4f GIT binary patch literal 10244 zcmeHM&2QsG6n~R;Y0^*kYuO@@B62}&wPZ_|6+&pU*{C;oV{GR=0CM6|06WgulBWgulBW#GTT z0Oo8yvLi~S*OY;jfs}#g3~+tO<78Qinbl@Vl0FZ-dmIrjX_=n7M17s|4LX7z}imw%rp~L6Ntb=OdWEh zJ^a!#S~w<$tau-ppA%?9qB)uX@jLjlp*Jx)9vAN8cw*kaQM^Ora;iq-OMDvsBXJ&dd=7D%z_zG{m`$+Qi1#Qnp(BQ64m#47Gkr!cl6M_53M(+F^Mcqc+Dr7s z8PIWKunEAYiRhRaj`PeOWme8chVW4Z>b#8T$SbrB1iw>>w~4tI;~Mv)u(T1Eg$RAb zSf?G8z4)k@^BC@$#BrWnndQ5X4S26dx#Tw}##P)OXC&rt2>Es}z8X9_$*4IOG3#+y z?}LvWaH-ywzHh5QK4Mq{7*A$|-^~l(HqOew!`JqLPV_6`_qC2=2Vt@Ji^vQNUU^|C zJCq&CKCZO9y-H|?-Jopx5BYB0^PE~wH)|WVwO2J}?s;x#+OFkGfZecQ^5|pRZFqZS zuj@7fiLIyy*<3bPHLe~W-o8DbzqN2QpFezip*WvkeDkfNqg-~j@Wwl9)g7npdY|)0 zhfzff4H{GT&#zxVyO1Tjz8j5F{L~xeZ-&tuXKr|8bZmUWn4FrPoSB@Rz53#{*}0eI zUalI`HM73c^f~@}p5ystr)xcI`gWtzG3&P5+zhR!VZ}bMs>W2pbj@l!IcZwo@4#l} zq(QoS&$ldB`diuF4yU|L{RrV$656PJG4D_>rnvqmqM$(maHf`uUmcpGs6}^Sh2R-FA zr5IFD3Q?idI+l8Nrq>inkz02?*UA-2t5HjquH$oCrVV@q2lN$vP2bWF^dtRBf6y~A zB<94c;<{KA?}|I(eet1K6LrxLw)j-xGri>VB&8i9z|Dop->vwrqT_~vb7iDFsqxg^PL^SrgWt6r|6VT0s6|=8fjlib`pFTYD zTiJKgj-fKJPfWU!Yu)n{dauiAh?iTu>}m0PbY7mB`^*!K`!QJa!qJ8Y_M%O^@o{ku z5=dT7^cH)p_gU~V|1o41-%abBeBsTH*=uzrRZ|9122uttmw^G*U48`e0oFBr{{Mfu zL8ZN=45SQPDg$Ehe&v1{UG{c8$=><5_B_r{aPq-+$4W{FF7oGiNcnR-ZusYTxrIYp e5xP8}mso*3RuUSHOaEs;y8mya`~Uy<{{J7!wbx$& literal 0 HcmV?d00001 diff --git a/FusionIIIT/templates/hostelmanagement/add_hostel.html b/FusionIIIT/templates/hostelmanagement/add_hostel.html index d4bc60177..4b5d212a6 100644 --- a/FusionIIIT/templates/hostelmanagement/add_hostel.html +++ b/FusionIIIT/templates/hostelmanagement/add_hostel.html @@ -1,203 +1,45 @@ -{% extends 'globals/base.html' %} -{% load static %} - -{% block title %} -Super Admin -{% endblock %} - -{% block body %} - -
- -
- -
-
-
- -
- {% block userCard %} - {% include 'globals/usercard.html' %} - {% endblock %} -
- -
- {% if user.is_authenticated %} - - -
-
- - - -

Add Hostel

- {% if messages %} -
    - {% for message in messages %} -
  • {{ message }}
  • - {% endfor %} -
- {% endif %} - {% csrf_token %} - {{ form.as_p }} - - +{% block Add_hostel %} +
+

Add Hostel

+ {% if messages %} +
    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
{% endif %} -
- {% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/admin_hostel_list.html b/FusionIIIT/templates/hostelmanagement/admin_hostel_list.html index 743cf8e37..33274078f 100644 --- a/FusionIIIT/templates/hostelmanagement/admin_hostel_list.html +++ b/FusionIIIT/templates/hostelmanagement/admin_hostel_list.html @@ -1,95 +1,11 @@ -{% extends 'globals/base.html' %} -{% load static %} -{% block title %} -Super Admin -{% endblock %} +{% block View_Hostels %} -{% block body %} -
- -
- -
-
-
- -
- {% block userCard %} - {% include 'globals/usercard.html' %} - {% endblock %} -
- -
- {% if user.is_authenticated %} - - -
- - - - -
-

Hostel List

- - +
@@ -116,7 +32,8 @@

Hostel List

- Delete + + Delete @@ -126,44 +43,18 @@

Hostel List

Hall ID
- {% endif %} -
- - {% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/assign_batch.html b/FusionIIIT/templates/hostelmanagement/assign_batch.html index db7eae678..ba36a1b2e 100644 --- a/FusionIIIT/templates/hostelmanagement/assign_batch.html +++ b/FusionIIIT/templates/hostelmanagement/assign_batch.html @@ -1,104 +1,13 @@ +{% block manage_Hostel %} -{% extends 'globals/base.html' %} -{% load static %} - -{% block title %} - Super Admin -{% endblock %} - -{% block body %} - -
- -
-
-
-
- -
- {% block userCard %} - {% include 'globals/usercard.html' %} - {% endblock %} -
- -
- {% if user.is_authenticated %} - - -
-
-
- - + {% csrf_token %}
@@ -110,32 +19,16 @@ -
- {% endif %} -
- - - + + - {% endblock %} + diff --git a/FusionIIIT/templates/hostelmanagement/assign_caretaker.html b/FusionIIIT/templates/hostelmanagement/assign_caretaker.html index 51e807e33..e176971fe 100644 --- a/FusionIIIT/templates/hostelmanagement/assign_caretaker.html +++ b/FusionIIIT/templates/hostelmanagement/assign_caretaker.html @@ -1,155 +1,55 @@ -{% extends 'globals/base.html' %} -{% load static %} - -{% block title %} - Super Admin -{% endblock %} - -{% block body %} - -
- +{% block manage_Caretaker %} +
+ {% csrf_token %} +
+ + +
-
-
-
- -
- {% block userCard %} - {% include 'globals/usercard.html' %} - {% endblock %} -
+
+ -
- {% if user.is_authenticated %} -
- +
-
+ + -
-
-
- -
- {% csrf_token %} -
- - - -
-
- - - - - -
- - -
-
- {% endif %} -
- + - -{% endblock %} + return cookieValue; + } + +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/assign_warden.html b/FusionIIIT/templates/hostelmanagement/assign_warden.html index 74f3d9dcb..24dc70cde 100644 --- a/FusionIIIT/templates/hostelmanagement/assign_warden.html +++ b/FusionIIIT/templates/hostelmanagement/assign_warden.html @@ -1,103 +1,12 @@ -{% extends 'globals/base.html' %} -{% load static %} - -{% block title %} - Super Admin -{% endblock %} - -{% block body %} - -
- -
-
-
-
- -
- {% block userCard %} - {% include 'globals/usercard.html' %} - {% endblock %} -
- -
- {% if user.is_authenticated %} - - -
-
-
- -
+{% block manage_Warden %} + {% csrf_token %}
- - {% for hall in halls %} + {% for hall in all_hall %} {% endfor %} @@ -109,7 +18,7 @@ @@ -117,33 +26,17 @@ -
- {% endif %} -
- - - + + ') + + + + +class HostelFineView(APIView): + """ + API endpoint for imposing fines on students. + """ + authentication_classes = [SessionAuthentication] + permission_classes = [IsAuthenticated] + + @method_decorator(login_required) + def dispatch(self, *args, **kwargs): + return super().dispatch(*args, **kwargs) + + + def post(self, request): + # Check if the user is a caretaker + user_id = request.user + staff = user_id.extrainfo.id + + try: + caretaker = HallCaretaker.objects.get(staff_id=staff) + except HallCaretaker.DoesNotExist: + return HttpResponse(f'') + + hall_id = caretaker.hall_id + + # Extract data from the request + student_id = request.data.get('student_id') + student_name = request.data.get('student_name') + amount = request.data.get('amount') + reason = request.data.get('reason') + + + + # Validate the data + if not all([student_id, student_name, amount, reason]): + return HttpResponse({'error': 'Incomplete data provided.'}, status=status.HTTP_400_BAD_REQUEST) + + # Create the HostelFine object + try: + fine = HostelFine.objects.create( + student_id=student_id, + student_name=student_name, + amount=amount, + reason=reason, + hall_id=hall_id + ) + return HttpResponse({'message': 'Fine imposed successfully.'}, status=status.HTTP_201_CREATED) + except Exception as e: + return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + +@login_required +def get_student_name(request, username): + try: + user = User.objects.get(username=username) + full_name = f"{user.first_name} {user.last_name}" if user.first_name or user.last_name else "" + return JsonResponse({"name": full_name}) + except User.DoesNotExist: + return JsonResponse({"error": "User not found"}, status=404) + +@login_required +def hostel_fine_list(request): + user_id = request.user + staff=user_id.extrainfo.id + caretaker = HallCaretaker.objects.get(staff_id=staff) + hall_id = caretaker.hall_id + hostel_fines = HostelFine.objects.filter(hall_id=hall_id) + + + if HallCaretaker.objects.filter(staff_id=staff).exists(): + return render(request, 'hostelmanagement/hostel_fine_list.html', {'hostel_fines': hostel_fines}) + + return HttpResponse(f'') + + + + + +class HostelFineUpdateView(APIView): + authentication_classes = [SessionAuthentication] + permission_classes = [IsAuthenticated] + + @method_decorator(login_required) + def dispatch(self, *args, **kwargs): + return super().dispatch(*args, **kwargs) + + def post(self, request, fine_id): + user_id = request.user + staff = user_id.extrainfo.id + + data = request.data + fine_idd = data.get('fine_id') + status_ = data.get('status') + # print("fine_idd",fine_idd) + # print("status_",status_) + + try: + caretaker = HallCaretaker.objects.get(staff_id=staff) + except HallCaretaker.DoesNotExist: + return Response({'error': 'You are not authorized to access this page'}, status=status.HTTP_403_FORBIDDEN) + + hall_id = caretaker.hall_id + + # Convert fine_id to integer + fine_id = int(fine_id) + + # Get hostel fine object + try: + hostel_fine = HostelFine.objects.get(hall_id=hall_id, fine_id=fine_id) + except HostelFine.DoesNotExist: + raise NotFound(detail="Hostel fine not found") + + # Validate required fields + if status_ not in ['Pending', 'Paid']: + return Response({'error': 'Invalid status value'}, status=status.HTTP_400_BAD_REQUEST) + + # # Update status of the hostel fine + hostel_fine.status = status_ + hostel_fine.save() + + # Return success response + return Response({'message': 'Hostel fine status updated successfully!'}, status=status.HTTP_200_OK) + + + + + def delete(self, request, fine_id): + user_id = request.user + staff = user_id.extrainfo.id + + try: + caretaker = HallCaretaker.objects.get(staff_id=staff) + except HallCaretaker.DoesNotExist: + return Response({'error': 'You are not authorized to access this page'}, status=status.HTTP_403_FORBIDDEN) + + hall_id = caretaker.hall_id + + # Convert fine_id to integer + fine_id = int(fine_id) + + # Get hostel fine object + try: + hostel_fine = HostelFine.objects.get(hall_id=hall_id, fine_id=fine_id) + hostel_fine.delete() + except HostelFine.DoesNotExist: + raise NotFound(detail="Hostel fine not found") + + return Response({'message': 'Fine deleted successfully.'}, status=status.HTTP_204_NO_CONTENT) \ No newline at end of file diff --git a/FusionIIIT/templates/hostelmanagement/hostel_fine_list.html b/FusionIIIT/templates/hostelmanagement/hostel_fine_list.html new file mode 100644 index 000000000..a66e65ff9 --- /dev/null +++ b/FusionIIIT/templates/hostelmanagement/hostel_fine_list.html @@ -0,0 +1,99 @@ + + + + + + Hostel Fine List + + +

Hostel Fine List

+ + + + + + + + + + + + + + + {% for hostel_fine in hostel_fines %} + + + + + + + + + + + {% endfor %} + +
Fine IDStudentHallStudent NameAmountStatusReasonAction
{{ hostel_fine.fine_id }}{{ hostel_fine.student }}{{ hostel_fine.hall }}{{ hostel_fine.student_name }}{{ hostel_fine.amount }} + + {{ hostel_fine.reason }}
+ + + + + diff --git a/FusionIIIT/templates/hostelmanagement/impose_fine.html b/FusionIIIT/templates/hostelmanagement/impose_fine.html new file mode 100644 index 000000000..785ed1b93 --- /dev/null +++ b/FusionIIIT/templates/hostelmanagement/impose_fine.html @@ -0,0 +1,82 @@ + + + + + + Hostel Fine Form + + +

Hostel Fine Form

+
+ {% csrf_token %} + + +

+ + +

+ + +
+ +
+ +
+
+ + +
+ +
+ + + + diff --git a/FusionIIIT/templates/hostelmanagement/inventory_form.html b/FusionIIIT/templates/hostelmanagement/inventory_form.html index 7ea7572a1..c9fca2478 100644 --- a/FusionIIIT/templates/hostelmanagement/inventory_form.html +++ b/FusionIIIT/templates/hostelmanagement/inventory_form.html @@ -44,6 +44,17 @@

Hostel Inventory Form

.getElementById("inventoryForm") .addEventListener("submit", function (event) { event.preventDefault(); + // Validate form fields + var hallId = document.getElementById("hall_id").value; + var inventoryName = document.getElementById("inventory_name").value; + var cost = document.getElementById("cost").value; + var quantity = document.getElementById("quantity").value; + + if (!hallId || !inventoryName || !cost || !quantity) { + alert("Please fill in all fields."); + return; + } + var formData = new FormData(this); fetch(this.action, { method: this.method, From 1e91f0a3d0c9a67a9f5769ba505c0f75fba45be2 Mon Sep 17 00:00:00 2001 From: Anuj Patel Date: Mon, 19 Feb 2024 18:16:20 +0530 Subject: [PATCH 046/158] migration files of DB --- .../migrations/0006_merge_20240219_1730.py | 14 ++++++++++++++ .../eis/migrations/0006_merge_20240219_1730.py | 14 ++++++++++++++ .../globals/migrations/0011_merge_20240219_1730.py | 14 ++++++++++++++ .../migrations/0014_merge_20240219_1730.py | 14 ++++++++++++++ .../migrations/0006_merge_20240219_1730.py | 14 ++++++++++++++ .../migrations/0006_merge_20240219_1730.py | 14 ++++++++++++++ .../hostelmanagement/post_complaint_form.html | 4 ++-- 7 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 FusionIIIT/applications/academic_procedures/migrations/0006_merge_20240219_1730.py create mode 100644 FusionIIIT/applications/eis/migrations/0006_merge_20240219_1730.py create mode 100644 FusionIIIT/applications/globals/migrations/0011_merge_20240219_1730.py create mode 100644 FusionIIIT/applications/hostel_management/migrations/0014_merge_20240219_1730.py create mode 100644 FusionIIIT/applications/programme_curriculum/migrations/0006_merge_20240219_1730.py create mode 100644 FusionIIIT/applications/scholarships/migrations/0006_merge_20240219_1730.py diff --git a/FusionIIIT/applications/academic_procedures/migrations/0006_merge_20240219_1730.py b/FusionIIIT/applications/academic_procedures/migrations/0006_merge_20240219_1730.py new file mode 100644 index 000000000..4470d9b43 --- /dev/null +++ b/FusionIIIT/applications/academic_procedures/migrations/0006_merge_20240219_1730.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('academic_procedures', '0004_merge_20240218_1736'), + ('academic_procedures', '0005_merge_20240218_2206'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/eis/migrations/0006_merge_20240219_1730.py b/FusionIIIT/applications/eis/migrations/0006_merge_20240219_1730.py new file mode 100644 index 000000000..e4a5388a0 --- /dev/null +++ b/FusionIIIT/applications/eis/migrations/0006_merge_20240219_1730.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('eis', '0004_merge_20240218_1736'), + ('eis', '0005_merge_20240218_2206'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/globals/migrations/0011_merge_20240219_1730.py b/FusionIIIT/applications/globals/migrations/0011_merge_20240219_1730.py new file mode 100644 index 000000000..02f0035d6 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0011_merge_20240219_1730.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0008_auto_20240219_0450'), + ('globals', '0010_auto_20240219_1316'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/hostel_management/migrations/0014_merge_20240219_1730.py b/FusionIIIT/applications/hostel_management/migrations/0014_merge_20240219_1730.py new file mode 100644 index 000000000..871c7b6d6 --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0014_merge_20240219_1730.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0013_auto_20240219_1316'), + ('hostel_management', '0008_auto_20240219_0450'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/programme_curriculum/migrations/0006_merge_20240219_1730.py b/FusionIIIT/applications/programme_curriculum/migrations/0006_merge_20240219_1730.py new file mode 100644 index 000000000..07a6a4110 --- /dev/null +++ b/FusionIIIT/applications/programme_curriculum/migrations/0006_merge_20240219_1730.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('programme_curriculum', '0004_merge_20240218_1736'), + ('programme_curriculum', '0005_merge_20240218_2206'), + ] + + operations = [ + ] diff --git a/FusionIIIT/applications/scholarships/migrations/0006_merge_20240219_1730.py b/FusionIIIT/applications/scholarships/migrations/0006_merge_20240219_1730.py new file mode 100644 index 000000000..d0dfcb0e2 --- /dev/null +++ b/FusionIIIT/applications/scholarships/migrations/0006_merge_20240219_1730.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.5 on 2024-02-19 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('scholarships', '0004_merge_20240218_1736'), + ('scholarships', '0005_merge_20240218_2205'), + ] + + operations = [ + ] diff --git a/FusionIIIT/templates/hostelmanagement/post_complaint_form.html b/FusionIIIT/templates/hostelmanagement/post_complaint_form.html index 5b1be09c7..57a010f17 100644 --- a/FusionIIIT/templates/hostelmanagement/post_complaint_form.html +++ b/FusionIIIT/templates/hostelmanagement/post_complaint_form.html @@ -7,10 +7,10 @@

Complaint Form


-
+
-
+

From d444f1687c39b74b9dea2b69db4f029e77f891e2 Mon Sep 17 00:00:00 2001 From: Aniruddha Date: Tue, 20 Feb 2024 17:54:21 +0530 Subject: [PATCH 047/158] chore:student fine show --- .../applications/hostel_management/urls.py | 1 + .../applications/hostel_management/views.py | 28 ++++++++++++++++- .../student_fine_details.html | 31 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 FusionIIIT/templates/hostelmanagement/student_fine_details.html diff --git a/FusionIIIT/applications/hostel_management/urls.py b/FusionIIIT/applications/hostel_management/urls.py index 2bf3c5cd2..5bf3b85e7 100644 --- a/FusionIIIT/applications/hostel_management/urls.py +++ b/FusionIIIT/applications/hostel_management/urls.py @@ -49,6 +49,7 @@ path('fine/impose/list/', views.hostel_fine_list, name='fine_list_show'), path('fine/impose/list/update//', views.HostelFineUpdateView.as_view(), name='fine_update'), path('fine/delete//', views.HostelFineUpdateView.as_view(), name='fine_delete'), + path('fine/show/', views.student_fine_details, name='fine_show'), diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index bb27513a1..2e8b622d4 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -688,6 +688,8 @@ def get(self, request, hall_id): 'quantity': inventory.quantity, }) + inventory_data.sort(key=lambda x: x['inventory_id']) + # Return inventory data as JSON response return render(request, 'hostelmanagement/inventory_list.html', {'halls': halls,'inventories': inventory_data}) @@ -846,7 +848,7 @@ def hostel_fine_list(request): staff=user_id.extrainfo.id caretaker = HallCaretaker.objects.get(staff_id=staff) hall_id = caretaker.hall_id - hostel_fines = HostelFine.objects.filter(hall_id=hall_id) + hostel_fines = HostelFine.objects.filter(hall_id=hall_id).order_by('fine_id') if HallCaretaker.objects.filter(staff_id=staff).exists(): @@ -856,6 +858,30 @@ def hostel_fine_list(request): +@login_required +def student_fine_details(request): + user_id = request.user.username + print(user_id) + # staff=user_id.extrainfo.id + + # Check if the user_id exists in the Student table + # if HallCaretaker.objects.filter(staff_id=staff).exists(): + # return HttpResponse('') + + if not Student.objects.filter(id_id=user_id).exists(): + return HttpResponse('') + + # # Check if the user_id exists in the HostelFine table + if not HostelFine.objects.filter(student_id=user_id).exists(): + return HttpResponse('') + + # # Retrieve the fines associated with the current student + student_fines = HostelFine.objects.filter(student_id=user_id) + + + return render(request, 'hostelmanagement/student_fine_details.html', {'student_fines': student_fines}) + + # return JsonResponse({'message': 'Nice'}, status=status.HTTP_200_OK) class HostelFineUpdateView(APIView): diff --git a/FusionIIIT/templates/hostelmanagement/student_fine_details.html b/FusionIIIT/templates/hostelmanagement/student_fine_details.html new file mode 100644 index 000000000..cfec401b2 --- /dev/null +++ b/FusionIIIT/templates/hostelmanagement/student_fine_details.html @@ -0,0 +1,31 @@ + + + + + + Student Fine Details + + +

Student Fine Details

+ + + + + + + + + + + {% for fine in student_fines %} + + + + + + + {% endfor %} + +
HallAmountStatusReason
{{ fine.hall }}{{ fine.amount }}{{ fine.status }}{{ fine.reason }}
+ + From edb2661d9ee275a60f72ec6ad8ce7acd0ce6e76a Mon Sep 17 00:00:00 2001 From: Stark Date: Tue, 20 Feb 2024 18:50:08 +0530 Subject: [PATCH 048/158] fix:student details --- .../migrations/0012_studentdetails_hall_id.py | 18 ++++++++++++++++++ .../applications/hostel_management/models.py | 1 + .../applications/hostel_management/views.py | 12 ++++++------ .../hostelmanagement/student_details.html | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 FusionIIIT/applications/hostel_management/migrations/0012_studentdetails_hall_id.py diff --git a/FusionIIIT/applications/hostel_management/migrations/0012_studentdetails_hall_id.py b/FusionIIIT/applications/hostel_management/migrations/0012_studentdetails_hall_id.py new file mode 100644 index 000000000..1312d8376 --- /dev/null +++ b/FusionIIIT/applications/hostel_management/migrations/0012_studentdetails_hall_id.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-02-20 18:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hostel_management', '0011_auto_20240219_0207'), + ] + + operations = [ + migrations.AddField( + model_name='studentdetails', + name='hall_id', + field=models.CharField(blank=True, max_length=20, null=True), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/models.py b/FusionIIIT/applications/hostel_management/models.py index c478ce74f..62c0d7582 100644 --- a/FusionIIIT/applications/hostel_management/models.py +++ b/FusionIIIT/applications/hostel_management/models.py @@ -294,6 +294,7 @@ class StudentDetails(models.Model): batch = models.CharField(max_length=100,blank=True,null=True) room_num= models.CharField(max_length=20,blank=True,null=True) hall_no= models.CharField(max_length=20,blank=True,null=True) + hall_id=models.CharField(max_length=20,blank=True,null=True) specialization = models.CharField(max_length=100,blank=True,null=True) parent_contact = models.CharField(max_length=20, blank=True, null=True) address = models.CharField(max_length=255, blank=True, null=True) diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index 78f6453fa..b4e01bb1c 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -535,10 +535,7 @@ def hostel_complaint_list(request): else: return HttpResponse('') -from django.http import JsonResponse, HttpResponse -from django.shortcuts import redirect -from django.contrib.auth.decorators import login_required -from applications.hostel_management.models import HallCaretaker, HallWarden + @login_required def get_students(request): @@ -551,13 +548,16 @@ def get_students(request): if HallCaretaker.objects.filter(staff_id=staff).exists(): hall_id = HallCaretaker.objects.get(staff_id=staff).hall_id print(hall_id) - student_details = StudentDetails.objects.filter(hall_no=hall_id) + hall_no = Hall.objects.get(id=hall_id) + print(hall_no) + student_details = StudentDetails.objects.filter(hall_id=hall_no) + return render(request, 'hostelmanagement/student_details.html', {'students': student_details}) elif HallWarden.objects.filter(faculty_id=staff).exists(): hall_id = HallWarden.objects.get(faculty_id=staff).hall_id - student_details = StudentDetails.objects.filter(hall_no=hall_id) + student_details = StudentDetails.objects.filter(hall_id=hall_no) return render(request, 'hostelmanagement/student_details.html', {'students': student_details}) else: diff --git a/FusionIIIT/templates/hostelmanagement/student_details.html b/FusionIIIT/templates/hostelmanagement/student_details.html index 3d570bec7..53832bf96 100644 --- a/FusionIIIT/templates/hostelmanagement/student_details.html +++ b/FusionIIIT/templates/hostelmanagement/student_details.html @@ -31,7 +31,7 @@

Student Details

{{ student.programme }} {{ student.batch }} {{ student.room_num }} - {{ student.hall_no }} + {{ student.hall_id }} {{ student.specialization }} {{ student.parent_contact }} {{ student.address }} From 8aa91d0233d0eb3627ceb8e8833b86031bc2beb1 Mon Sep 17 00:00:00 2001 From: Anuj Patel Date: Tue, 20 Feb 2024 18:58:54 +0530 Subject: [PATCH 049/158] updated html files with template --- .DS_Store | Bin 8196 -> 8196 bytes .../applications/hostel_management/views.py | 3 ++- .../hostelmanagement/add_hostel.html | 4 ++-- .../hostelmanagement/admin_hostel_list.html | 4 +--- .../hostelmanagement/assign_batch.html | 17 ++++++++--------- .../hostelmanagement/assign_caretaker.html | 12 +++++++----- .../hostelmanagement/assign_warden.html | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.DS_Store b/.DS_Store index ced1c82c96373dc0a5f81b4d166b937bb287029a..f10ebd46490991557dbdc1c3c6ab1cf6c3b3d3ff 100644 GIT binary patch delta 89 zcmZp1XmOa}LAU^hRb)@B}opG?xs45H+`AG~63<5yx$iTp;HCazs jVY8GlD-#>zcOYM5v#RJGrp@dU-&iJJ7x6#{?qmW03P~1f delta 67 zcmZp1XmOa}XEU^hRb=4Kv&pG=eEg+(_z2(vP=F|21`VAR^|ExLzkVu9Lbc8PB+ Lla)o4P{ox2n^zLv diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index c5db63010..b97f69b7e 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -925,7 +925,8 @@ def post(self, request, *args, **kwargs): form.save() messages.success(request, 'Hall added successfully!') return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) # Redirect to the view showing all hostels - + # return render(request, 'hostelmanagement/admin_hostel_list.html') + # If form is not valid, render the form with errors return render(request, self.template_name, {'form': form}) diff --git a/FusionIIIT/templates/hostelmanagement/add_hostel.html b/FusionIIIT/templates/hostelmanagement/add_hostel.html index 4b5d212a6..50445ea4e 100644 --- a/FusionIIIT/templates/hostelmanagement/add_hostel.html +++ b/FusionIIIT/templates/hostelmanagement/add_hostel.html @@ -1,6 +1,6 @@ {% block Add_hostel %}
-

Add Hostel

+

Add Hostel

{% if messages %}
    {% for message in messages %} @@ -10,7 +10,7 @@

    Add Hostel

    {% endif %} {% csrf_token %} {{ add_hostel_form.as_p }} - + - - + +{% endblock %} + + diff --git a/FusionIIIT/templates/hostelmanagement/impose_fine.html b/FusionIIIT/templates/hostelmanagement/impose_fine.html index 785ed1b93..fa4755205 100644 --- a/FusionIIIT/templates/hostelmanagement/impose_fine.html +++ b/FusionIIIT/templates/hostelmanagement/impose_fine.html @@ -1,13 +1,6 @@ - - - - - - Hostel Fine Form - - +{% block Impose_fine %}

    Hostel Fine Form

    -
    + {% csrf_token %} @@ -19,7 +12,7 @@

    Hostel Fine Form



    -

    +


    @@ -46,7 +39,8 @@

    Hostel Fine Form

    fetch(`/hostelmanagement/student/${studentId}/name/`) .then(response => response.json()) .then(data => { - document.getElementById("student_name").value = data.name; + console.log(data.name); + document.getElementById("student_fine_name").value = data.name; }) .catch(error => { console.error("Error fetching student name:", error); @@ -68,7 +62,7 @@

    Hostel Fine Form

    }) .then(response => { if (response.ok) { - window.location.href = "impose/list/"; + window.location.href = "/hostelmanagement/"; } else { console.error("Error updating status"); } @@ -78,5 +72,4 @@

    Hostel Fine Form

    }); }); - - +{% endblock %} From 13672d2de5185d121ae1d027078f1325aee91ba5 Mon Sep 17 00:00:00 2001 From: Aniruddha Date: Tue, 20 Feb 2024 20:17:20 +0530 Subject: [PATCH 051/158] fix:List name change --- FusionIIIT/templates/hostelmanagement/hostel.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FusionIIIT/templates/hostelmanagement/hostel.html b/FusionIIIT/templates/hostelmanagement/hostel.html index 3dc183033..634ae6cc1 100644 --- a/FusionIIIT/templates/hostelmanagement/hostel.html +++ b/FusionIIIT/templates/hostelmanagement/hostel.html @@ -158,7 +158,7 @@ {% if user in hall_caretaker%} - Manage Fine + Impose Fine {% endif %} From 651681c23fc39d8733f3976425d44a461d032fc2 Mon Sep 17 00:00:00 2001 From: Anuj Patel Date: Tue, 20 Feb 2024 22:55:40 +0530 Subject: [PATCH 052/158] updated frontend using templates --- .../applications/hostel_management/models.py | 2 +- .../applications/hostel_management/urls.py | 2 +- .../templates/hostelmanagement/hostel.html | 15 +++++++++++- .../hostelmanagement/inventory_form.html | 23 +++++++++++-------- .../templates/hostelmanagement/my_leaves.html | 18 ++++++++++++++- .../hostelmanagement/student_details.html | 14 +++-------- 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/FusionIIIT/applications/hostel_management/models.py b/FusionIIIT/applications/hostel_management/models.py index 34ef34871..06cf6b88e 100644 --- a/FusionIIIT/applications/hostel_management/models.py +++ b/FusionIIIT/applications/hostel_management/models.py @@ -300,7 +300,7 @@ class StudentDetails(models.Model): address = models.CharField(max_length=255, blank=True, null=True) def __str__(self): - return self.first_name + ' ' + self.last_name + return self.first_name diff --git a/FusionIIIT/applications/hostel_management/urls.py b/FusionIIIT/applications/hostel_management/urls.py index d564a50b2..5b64da506 100644 --- a/FusionIIIT/applications/hostel_management/urls.py +++ b/FusionIIIT/applications/hostel_management/urls.py @@ -83,7 +83,7 @@ # !!? Inventory path('inventory/', views.HostelInventoryView.as_view(), name='hostel_inventory_list'), path('inventory//modify/', views.HostelInventoryUpdateView.as_view(), name='hostel_inventory_update'), - path('inventory//delete/', views.HostelInventoryView.as_view(), name='hostel_inventory_detail'), + path('inventory//delete/', views.HostelInventoryView.as_view(), name='hostel_inventory_delete'), path('inventory//', views.HostelInventoryView.as_view(), name='hostel_inventory_by_hall'), path('inventory/form/', views.get_inventory_form, name='get_inventory_form'), path('inventory/edit_inventory//', views.edit_inventory, name='edit_inventory'), diff --git a/FusionIIIT/templates/hostelmanagement/hostel.html b/FusionIIIT/templates/hostelmanagement/hostel.html index da575bb1b..23e0e9764 100644 --- a/FusionIIIT/templates/hostelmanagement/hostel.html +++ b/FusionIIIT/templates/hostelmanagement/hostel.html @@ -99,6 +99,13 @@ {% endif %} + + {% if user in hall_caretaker or user in hall_warden %} + + Hall Students + + + {% endif %} {% if user.username in all_students_id %} @@ -162,7 +169,7 @@
-
+
{% block alloted_hostel_room %} {% include 'hostelmanagement/alloted_hostel_room.html'%} @@ -224,6 +231,12 @@ {% include 'hostelmanagement/inventory_form.html' %} {% endblock %}
+ +
+ {% block hall_all_students %} + {% include 'hostelmanagement/student_details.html' %} + {% endblock %} +
{% if user.username in all_students_id %}
diff --git a/FusionIIIT/templates/hostelmanagement/inventory_form.html b/FusionIIIT/templates/hostelmanagement/inventory_form.html index c8d149c40..5afbb0be9 100644 --- a/FusionIIIT/templates/hostelmanagement/inventory_form.html +++ b/FusionIIIT/templates/hostelmanagement/inventory_form.html @@ -1,6 +1,6 @@ {% block inventory_form %} -

Hostel Inventory Form

- +

Hostel Inventory Form

+ {% csrf_token %}
@@ -13,15 +13,15 @@

Hostel Inventory Form

- +
- +
- +
@@ -32,18 +32,23 @@

Hostel Inventory Form

.addEventListener("submit", function (event) { event.preventDefault(); var formData = new FormData(this); + console.log("hiiiiiiiiii"); + fetch(this.action, { method: this.method, body: formData, }) .then((response) => response.json()) .then((data) => { - document.getElementById("responseMessage").innerHTML = - data.message; + console.log(data); + // document.getElementById("responseMessage").innerHTML = + // data.message; if (data.hall_id) { - // console.log(data.hall_id); + console.log(data.hall_id); + alert("Inventory added successfully"); window.location.href = - "/hostelmanagement/inventory/" + data.hall_id + "/"; + // "/hostelmanagement/inventory/" + data.hall_id + "/"; + "/hostelmanagement/" } }) .catch((error) => { diff --git a/FusionIIIT/templates/hostelmanagement/my_leaves.html b/FusionIIIT/templates/hostelmanagement/my_leaves.html index 5c42a7f73..ea0fe79c8 100644 --- a/FusionIIIT/templates/hostelmanagement/my_leaves.html +++ b/FusionIIIT/templates/hostelmanagement/my_leaves.html @@ -17,9 +17,25 @@

My Leaves

{{ leave.reason }} {{ leave.start_date }} {{ leave.end_date }} - {{ leave.status}} + + {{ leave.status }} + {% endfor %} + {% endblock %} diff --git a/FusionIIIT/templates/hostelmanagement/student_details.html b/FusionIIIT/templates/hostelmanagement/student_details.html index 53832bf96..07446a551 100644 --- a/FusionIIIT/templates/hostelmanagement/student_details.html +++ b/FusionIIIT/templates/hostelmanagement/student_details.html @@ -1,13 +1,6 @@ - - - - - - Student Details - - +{% block hall_all_students %}

Student Details

- +
@@ -39,5 +32,4 @@

Student Details

{% endfor %}
ID
- - +{% endblock %} \ No newline at end of file From 90c64fb8c183340c8183b64bcc248222557dc7bc Mon Sep 17 00:00:00 2001 From: Anuj Patel Date: Wed, 21 Feb 2024 01:38:07 +0530 Subject: [PATCH 053/158] fixed few bugs and few glitches. --- .../migrations/0013_auto_20240220_2259.py | 18 + .../applications/hostel_management/views.py | 381 +++++++++--------- .../hostelmanagement/create_leave.html | 1 + .../templates/hostelmanagement/hostel.html | 21 +- .../hostelmanagement/hostel_fine_list.html | 11 +- .../hostelmanagement/impose_fine.html | 25 +- .../hostelmanagement/inventory_list.html | 75 ++-- .../templates/hostelmanagement/my_leaves.html | 6 +- .../hostelmanagement/student_details.html | 22 +- 9 files changed, 294 insertions(+), 266 deletions(-) create mode 100644 FusionIIIT/applications/globals/migrations/0013_auto_20240220_2259.py diff --git a/FusionIIIT/applications/globals/migrations/0013_auto_20240220_2259.py b/FusionIIIT/applications/globals/migrations/0013_auto_20240220_2259.py new file mode 100644 index 000000000..6a4337263 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0013_auto_20240220_2259.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-02-20 22:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0012_merge_20240220_1917'), + ] + + operations = [ + migrations.AlterField( + model_name='extrainfo', + name='user_status', + field=models.CharField(choices=[('NEW', 'NEW'), ('PRESENT', 'PRESENT')], default='PRESENT', max_length=50), + ), + ] diff --git a/FusionIIIT/applications/hostel_management/views.py b/FusionIIIT/applications/hostel_management/views.py index 39f513c6f..1f71d97d4 100644 --- a/FusionIIIT/applications/hostel_management/views.py +++ b/FusionIIIT/applications/hostel_management/views.py @@ -1,9 +1,19 @@ +from django.core.serializers import serialize +from django.http import HttpResponseBadRequest +from .models import HostelLeave, HallCaretaker +from applications.hostel_management.models import HallCaretaker, HallWarden +from django.http import JsonResponse, HttpResponse +from django.db import IntegrityError +from rest_framework.exceptions import NotFound +from django.shortcuts import redirect +from django.template import loader +from django.shortcuts import get_object_or_404 from django.shortcuts import render from django.http import HttpResponseRedirect from django.shortcuts import render, HttpResponse from django.views.decorators.csrf import csrf_exempt from rest_framework.permissions import IsAuthenticated -from .models import HallCaretaker,HallWarden +from .models import HallCaretaker, HallWarden from django.urls import reverse from .models import StudentDetails from rest_framework.exceptions import APIException @@ -68,32 +78,8 @@ def is_superuser(user): return user.is_authenticated and user.is_superuser -from django.core.serializers import serialize # //! My change -from django.http import JsonResponse -from rest_framework.views import APIView -from rest_framework.response import Response -from django.shortcuts import get_object_or_404 -from rest_framework import status -from rest_framework.authentication import SessionAuthentication -from rest_framework.permissions import IsAuthenticated -from django.template import loader -from django.urls import reverse -from django.shortcuts import redirect -from rest_framework.exceptions import NotFound -from rest_framework import status -from django.http import JsonResponse -from django.db import IntegrityError - -from django.contrib.auth.decorators import login_required -from rest_framework.permissions import IsAuthenticated -from django.utils.decorators import method_decorator -from rest_framework.authentication import SessionAuthentication -from django.http import JsonResponse, HttpResponse -from django.shortcuts import redirect -from django.contrib.auth.decorators import login_required -from applications.hostel_management.models import HallCaretaker, HallWarden @login_required @@ -134,41 +120,40 @@ def hostel_view(request, context={}): pending_guest_room_requests = {} for hall in all_hall: - pending_guest_room_requests[hall.hall_id] = GuestRoomBooking.objects.filter(hall=hall, status='Pending').select_related('hall', 'intender') + pending_guest_room_requests[hall.hall_id] = GuestRoomBooking.objects.filter( + hall=hall, status='Pending').select_related('hall', 'intender') guest_rooms = {} for hall in all_hall: - guest_rooms[hall.hall_id] = GuestRoom.objects.filter(hall=hall).select_related('hall') - user_guest_room_requests = GuestRoomBooking.objects.filter(intender=request.user).order_by("-arrival_date") - + guest_rooms[hall.hall_id] = GuestRoom.objects.filter( + hall=hall).select_related('hall') + user_guest_room_requests = GuestRoomBooking.objects.filter( + intender=request.user).order_by("-arrival_date") halls = Hall.objects.all() - # Create a list to store additional details + # Create a list to store additional details hostel_details = [] - # Loop through each hall and fetch assignedCaretaker and assignedWarden + # Loop through each hall and fetch assignedCaretaker and assignedWarden for hall in halls: try: caretaker = HallCaretaker.objects.filter(hall=hall).first() warden = HallWarden.objects.filter(hall=hall).first() except HostelAllotment.DoesNotExist: - assigned_caretaker = None - assigned_warden = None + assigned_caretaker = None + assigned_warden = None hostel_detail = { - 'hall_id': hall.hall_id, - 'hall_name': hall.hall_name, - 'max_accomodation': hall.max_accomodation, - 'number_students': hall.number_students, - 'assigned_batch': hall.assigned_batch, - 'assigned_caretaker': caretaker.staff.id.user.username if caretaker else None, - 'assigned_warden': warden.faculty.id.user.username if warden else None, - } + 'hall_id': hall.hall_id, + 'hall_name': hall.hall_name, + 'max_accomodation': hall.max_accomodation, + 'number_students': hall.number_students, + 'assigned_batch': hall.assigned_batch, + 'assigned_caretaker': caretaker.staff.id.user.username if caretaker else None, + 'assigned_warden': warden.faculty.id.user.username if warden else None, + } hostel_details.append(hostel_detail) - - - Staff_obj = Staff.objects.all().select_related('id__user') hall1 = Hall.objects.get(hall_id='hall1') hall3 = Hall.objects.get(hall_id='hall3') @@ -228,8 +213,9 @@ def hostel_view(request, context={}): for hall in all_hall: halls_attendance[hall.hall_id] = HostelStudentAttendence.objects.filter( hall=hall).select_related() - - user_complaints = HostelComplaint.objects.filter(roll_number=request.user.username) + + user_complaints = HostelComplaint.objects.filter( + roll_number=request.user.username) user_leaves = HostelLeave.objects.filter(roll_num=request.user.username) my_leaves = [] for leave in user_leaves: @@ -242,19 +228,76 @@ def hostel_view(request, context={}): all_complaints = HostelComplaint.objects.all() add_hostel_form = HallForm() - warden_ids=Faculty.objects.all().select_related('id__user') + warden_ids = Faculty.objects.all().select_related('id__user') - #//! My change for imposing fines + # //! My change for imposing fines user_id = request.user - staff_fine_caretaker=user_id.extrainfo.id - students = Student.objects.all(); + staff_fine_caretaker = user_id.extrainfo.id + students = Student.objects.all() + + fine_user = request.user + + if request.user.id in Staff.objects.values_list('id__user', flat=True): + staff_fine_caretaker = request.user.extrainfo.id + + caretaker_fine_id = HallCaretaker.objects.filter( + staff_id=staff_fine_caretaker).first() + if caretaker_fine_id: + hall_fine_id = caretaker_fine_id.hall_id + hostel_fines = HostelFine.objects.filter( + hall_id=hall_fine_id).order_by('fine_id') + context['hostel_fines'] = hostel_fines + + # caretaker_fine_id = HallCaretaker.objects.get(staff_id=staff_fine_caretaker) + # hall_fine_id = caretaker_fine_id.hall_id + # hostel_fines = HostelFine.objects.filter(hall_id=hall_fine_id).order_by('fine_id') + + if request.user.id in Staff.objects.values_list('id__user', flat=True): + staff_inventory_caretaker = request.user.extrainfo.id + + caretaker_inventory_id = HallCaretaker.objects.filter( + staff_id=staff_inventory_caretaker).first() + + if caretaker_inventory_id: + hall_inventory_id = caretaker_inventory_id.hall_id + inventories = HostelInventory.objects.filter( + hall_id=hall_inventory_id).order_by('inventory_id') + + # Serialize inventory data + inventory_data = [] + for inventory in inventories: + inventory_data.append({ + 'inventory_id': inventory.inventory_id, + 'hall_id': inventory.hall_id, + 'inventory_name': inventory.inventory_name, + # Convert DecimalField to string + 'cost': str(inventory.cost), + 'quantity': inventory.quantity, + }) + + inventory_data.sort(key=lambda x: x['inventory_id']) + context['inventories'] = inventory_data + + # all studens details for caretaker and warden + if request.user.id in Staff.objects.values_list('id__user', flat=True): + staff_student_info = request.user.extrainfo.id + + if HallCaretaker.objects.filter(staff_id=staff_student_info).exists(): + hall_caretaker_id = HallCaretaker.objects.get( + staff_id=staff_student_info).hall_id + + hall_num = Hall.objects.get(id=hall_caretaker_id) + hostel_students_details = StudentDetails.objects.filter(hall_id=hall_num) + context['hostel_students_details']= hostel_students_details + elif HallWarden.objects.filter(faculty_id=staff_student_info).exists(): + hall_warden_id = HallWarden.objects.get( + faculty_id=staff_student_info).hall_id + + hall_num = Hall.objects.get(id=hall_warden_id) + hostel_students_details = StudentDetails.objects.filter(hall_id=hall_num) + context['hostel_students_details'] = hostel_students_details - fine_user=request.user - - caretaker_fine_id = HallCaretaker.objects.get(staff_id=staff_fine_caretaker) - hall_fine_id = caretaker_fine_id.hall_id - hostel_fines = HostelFine.objects.filter(hall_id=hall_fine_id).order_by('fine_id') context = { @@ -279,18 +322,16 @@ def hostel_view(request, context={}): 'user_guest_room_requests': user_guest_room_requests, 'all_students_id': all_students_id, 'is_superuser': is_superuser, - 'warden_ids':warden_ids, - 'add_hostel_form':add_hostel_form, - 'hostel_details':hostel_details, + 'warden_ids': warden_ids, + 'add_hostel_form': add_hostel_form, + 'hostel_details': hostel_details, 'all_students_id': all_students_id, 'my_complaints': my_complaints, 'my_leaves': my_leaves, 'all_leaves': all_leaves, 'all_complaints': all_complaints, - - 'staff_fine_caretaker':staff_fine_caretaker, - 'students':students, - 'hostel_fines':hostel_fines, + 'staff_fine_caretaker': staff_fine_caretaker, + 'students': students, **context } @@ -613,23 +654,19 @@ def get(self, request, *args, **kwargs): return HttpResponse("Not found") - def hostel_notice_board(request): - notices = all().values('id', 'hall', 'posted_by', 'head_line', 'content', 'description') + notices = all().values('id', 'hall', 'posted_by', + 'head_line', 'content', 'description') data = list(notices) return JsonResponse(data, safe=False) - -from django.contrib.auth.decorators import login_required -from django.http import HttpResponse -from .models import HostelLeave, HallCaretaker - @login_required def all_leave_data(request): user_id = request.user.id # Using request.user to get the user ID try: - staff = request.user.extrainfo.id # Assuming the user's profile is stored in extrainfo + # Assuming the user's profile is stored in extrainfo + staff = request.user.extrainfo.id except AttributeError: staff = None @@ -640,7 +677,6 @@ def all_leave_data(request): return HttpResponse('') - @login_required def create_hostel_leave(request): print(request.user.username) @@ -671,9 +707,10 @@ def create_hostel_leave(request): @login_required def hostel_complaint_list(request): user_id = request.user.id - + try: - staff = request.user.extrainfo.id # Assuming the user's profile is stored in extrainfo + # Assuming the user's profile is stored in extrainfo + staff = request.user.extrainfo.id except AttributeError: staff = None @@ -684,43 +721,45 @@ def hostel_complaint_list(request): return HttpResponse('') - @login_required def get_students(request): try: staff = request.user.extrainfo.id print(staff) - except AttributeError: + except AttributeError: staff = None - + if HallCaretaker.objects.filter(staff_id=staff).exists(): hall_id = HallCaretaker.objects.get(staff_id=staff).hall_id print(hall_id) hall_no = Hall.objects.get(id=hall_id) print(hall_no) student_details = StudentDetails.objects.filter(hall_id=hall_no) - - + return render(request, 'hostelmanagement/student_details.html', {'students': student_details}) - + elif HallWarden.objects.filter(faculty_id=staff).exists(): hall_id = HallWarden.objects.get(faculty_id=staff).hall_id student_details = StudentDetails.objects.filter(hall_id=hall_no) - + return render(request, 'hostelmanagement/student_details.html', {'students': student_details}) else: return HttpResponse('') # Student can post complaints + class PostComplaint(APIView): - authentication_classes = [SessionAuthentication] # Assuming you are using session authentication - permission_classes = [IsAuthenticated] # Allow only authenticated users to access the view - + # Assuming you are using session authentication + authentication_classes = [SessionAuthentication] + # Allow only authenticated users to access the view + permission_classes = [IsAuthenticated] + def dispatch(self, request, *args, **kwargs): print(request.user.username) if not request.user.is_authenticated: - return redirect('/hostelmanagement') # Redirect to the login page if user is not authenticated + # Redirect to the login page if user is not authenticated + return redirect('/hostelmanagement') return super().dispatch(request, *args, **kwargs) def get(self, request): @@ -734,7 +773,7 @@ def post(self, request): contact_number = request.data.get('contact_number') # Assuming the student's name is stored in the user object - student_name = request.user.username + student_name = request.user.username complaint = HostelComplaint.objects.create( hall_name=hall_name, @@ -743,12 +782,11 @@ def post(self, request): description=description, contact_number=contact_number ) - + # Use JavaScript to display a pop-up message after submission return HttpResponse('') - # // student can see his leave status class my_leaves(View): @@ -771,10 +809,8 @@ def get(self, request, *args, **kwargs): except User.DoesNotExist: # Handle the case where the user with the given ID doesn't exist return HttpResponse(f"User with ID {user_id} does not exist.") - - class HallIdView(APIView): authentication_classes = [] # Allow public access for testing permission_classes = [] # Allow any user to access the view @@ -794,13 +830,12 @@ def logout_view(request): class AssignCaretakerView(APIView): authentication_classes = [SessionAuthentication] permission_classes = [IsAuthenticated] - template_name = 'hostelmanagement/assign_caretaker.html' - + template_name = 'hostelmanagement/assign_caretaker.html' def get(self, request, *args, **kwargs): hall = Hall.objects.all() - caretaker_usernames=Staff.objects.all() - return render(request, self.template_name , {'halls': hall,'caretaker_usernames':caretaker_usernames}) + caretaker_usernames = Staff.objects.all() + return render(request, self.template_name, {'halls': hall, 'caretaker_usernames': caretaker_usernames}) def post(self, request, *args, **kwargs): hall_id = request.data.get('hall_id') @@ -808,19 +843,22 @@ def post(self, request, *args, **kwargs): try: hall = Hall.objects.get(hall_id=hall_id) - caretaker_staff = Staff.objects.get(id__user__username=caretaker_username) - + caretaker_staff = Staff.objects.get( + id__user__username=caretaker_username) + # Delete any previous assignments of the caretaker in HallCaretaker table HallCaretaker.objects.filter(staff=caretaker_staff).delete() # Delete any previous assignments of the caretaker in HostelAllotment table - HostelAllotment.objects.filter(assignedCaretaker=caretaker_staff).delete() - + HostelAllotment.objects.filter( + assignedCaretaker=caretaker_staff).delete() + # Delete any previously assigned caretaker to the same hall HallCaretaker.objects.filter(hall=hall).delete() - # Assign the new caretaker to the hall in HallCaretaker table - hall_caretaker = HallCaretaker.objects.create(hall=hall, staff=caretaker_staff) + # Assign the new caretaker to the hall in HallCaretaker table + hall_caretaker = HallCaretaker.objects.create( + hall=hall, staff=caretaker_staff) # # Update the assigned caretaker in Hostelallottment table hostel_allotments = HostelAllotment.objects.filter(hall=hall) @@ -828,8 +866,6 @@ def post(self, request, *args, **kwargs): hostel_allotment.assignedCaretaker = caretaker_staff hostel_allotment.save() - - return Response({'message': f'Caretaker {caretaker_username} assigned to Hall {hall_id} successfully'}, status=status.HTTP_201_CREATED) except Hall.DoesNotExist: @@ -840,17 +876,16 @@ def post(self, request, *args, **kwargs): return JsonResponse({'status': 'error', 'error': str(e)}, status=500) - - @method_decorator(user_passes_test(is_superuser), name='dispatch') class AssignBatchView(View): authentication_classes = [SessionAuthentication] permission_classes = [IsAuthenticated] - template_name = 'hostelmanagement/assign_batch.html' # Assuming the HTML file is directly in the 'templates' folder - + # Assuming the HTML file is directly in the 'templates' folder + template_name = 'hostelmanagement/assign_batch.html' + def get(self, request, *args, **kwargs): hall = Hall.objects.all() - return render(request, self.template_name , {'halls': hall}) + return render(request, self.template_name, {'halls': hall}) def post(self, request, *args, **kwargs): try: @@ -868,7 +903,7 @@ def post(self, request, *args, **kwargs): room_allotment.save() return JsonResponse({'status': 'success', 'message': 'Batch assigned successfully'}, status=200) - + except Hall.DoesNotExist: return JsonResponse({'status': 'error', 'error': f'Hall with ID {hall_id} not found'}, status=404) @@ -892,7 +927,7 @@ def post(self, request, *args, **kwargs): try: hall = Hall.objects.get(hall_id=hall_id) warden = Faculty.objects.get(id__user__username=warden_id) - + # Delete any previous assignments of the warden in Hallwarden table HallWarden.objects.filter(faculty=warden).delete() @@ -938,26 +973,28 @@ def post(self, request, *args, **kwargs): # if Hall.objects.filter(hall_id=hall_id).exists(): # messages.error(request, f'Hall with ID {hall_id} already exists.') # return redirect('hostelmanagement:add_hostel') - + # Check if a hall with the given hall_id already exists if Hall.objects.filter(hall_id=hall_id).exists(): error_message = f'Hall with ID {hall_id} already exists.' - + return HttpResponse(error_message, status=400) # If not, create a new hall form.save() messages.success(request, 'Hall added successfully!') - return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) # Redirect to the view showing all hostels + # Redirect to the view showing all hostels + return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) # return render(request, 'hostelmanagement/admin_hostel_list.html') - + # If form is not valid, render the form with errors return render(request, self.template_name, {'form': form}) + class CheckHallExistsView(View): - + def get(self, request, *args, **kwargs): - + hall_id = request.GET.get('hall_id') try: hall = Hall.objects.get(hall_id=hall_id) @@ -968,15 +1005,13 @@ def get(self, request, *args, **kwargs): return JsonResponse({'exists': exists}) - - @method_decorator(user_passes_test(is_superuser), name='dispatch') class AdminHostelListView(View): template_name = 'hostelmanagement/admin_hostel_list.html' def get(self, request, *args, **kwargs): halls = Hall.objects.all() - # Create a list to store additional details + # Create a list to store additional details hostel_details = [] # Loop through each hall and fetch assignedCaretaker and assignedWarden @@ -1035,9 +1070,6 @@ def logout_view(request): return redirect("/") - - - # //! alloted_rooms def alloted_rooms(request, hall_id): """ @@ -1111,7 +1143,7 @@ def all_staff(request, hall_id): @param: request - HttpRequest object containing metadata about the user request. hall_id - The ID of the hall for which staff information is requested. - + @variables: all_staff - stores all staff information for the specified hall. @@ -1136,8 +1168,6 @@ def all_staff(request, hall_id): return JsonResponse(staff_details, safe=False) - - # //! Edit Stuff schedule class StaffScheduleView(APIView): """ @@ -1155,10 +1185,11 @@ def patch(self, request, staff_id): day = request.data.get('day') # print(staff_id, start_time, end_time, day) - + if start_time and end_time and day and staff_type: # Check if staff schedule exists for the given day - existing_schedule = StaffSchedule.objects.filter(staff_id=staff_id).first() + existing_schedule = StaffSchedule.objects.filter( + staff_id=staff_id).first() # print(existing_schedule) if existing_schedule: existing_schedule.start_time = start_time @@ -1170,9 +1201,8 @@ def patch(self, request, staff_id): else: # If staff schedule doesn't exist for the given day, return 404 return Response({"error": "Staff schedule does not exist for the given day."}, status=status.HTTP_404_NOT_FOUND) - - return Response({"error": "Please provide start_time, end_time, and day."}, status=status.HTTP_400_BAD_REQUEST) + return Response({"error": "Please provide start_time, end_time, and day."}, status=status.HTTP_400_BAD_REQUEST) # //! Hostel Inventory @@ -1181,7 +1211,7 @@ def patch(self, request, staff_id): def get_inventory_form(request): user_id = request.user # print("user_id",user_id) - staff=user_id.extrainfo.id + staff = user_id.extrainfo.id # print("staff",staff) # Check if the user is present in the HallCaretaker table @@ -1195,17 +1225,15 @@ def get_inventory_form(request): return HttpResponse(f'') - - @login_required def edit_inventory(request, inventory_id): # Retrieve hostel inventory object inventory = get_object_or_404(HostelInventory, pk=inventory_id) - + # Check if the user is a caretaker user_id = request.user staff_id = user_id.extrainfo.id - + if HallCaretaker.objects.filter(staff_id=staff_id).exists(): halls = Hall.objects.all() @@ -1225,8 +1253,7 @@ def edit_inventory(request, inventory_id): return HttpResponse('') - -class HostelInventoryUpdateView(APIView): +class HostelInventoryUpdateView(APIView): authentication_classes = [SessionAuthentication] permission_classes = [IsAuthenticated] @@ -1307,9 +1334,7 @@ def get(self, request, hall_id): inventory_data.sort(key=lambda x: x['inventory_id']) # Return inventory data as JSON response - return render(request, 'hostelmanagement/inventory_list.html', {'halls': halls,'inventories': inventory_data}) - - + return render(request, 'hostelmanagement/inventory_list.html', {'halls': halls, 'inventories': inventory_data}) def post(self, request): user_id = request.user @@ -1336,13 +1361,9 @@ def post(self, request): cost=cost, quantity=quantity ) - return Response({'message': 'Hostel inventory created successfully','hall_id': hall_id }, status=status.HTTP_201_CREATED) + return Response({'message': 'Hostel inventory created successfully', 'hall_id': hall_id}, status=status.HTTP_201_CREATED) except Exception as e: return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - - - - def delete(self, request, inventory_id): user_id = request.user @@ -1355,6 +1376,7 @@ def delete(self, request, inventory_id): inventory.delete() return Response({'message': 'Hostel inventory deleted successfully'}, status=status.HTTP_204_NO_CONTENT) + def update_allotment(request, pk): if request.method == 'POST': try: @@ -1377,7 +1399,6 @@ def update_allotment(request, pk): return JsonResponse({'error': 'Invalid request method'}, status=405) - @login_required def request_guest_room(request): """ @@ -1406,27 +1427,31 @@ def request_guest_room(request): nationality = form.cleaned_data['nationality'] newBooking = GuestRoomBooking.objects.create(hall=hall, intender=request.user, guest_name=guest_name, guest_address=guest_address, - guest_phone=guest_phone, guest_email=guest_email, rooms_required=rooms_required, total_guest=total_guest, purpose=purpose, - arrival_date=arrival_date, arrival_time=arrival_time, departure_date=departure_date, departure_time=departure_time, nationality= nationality) + guest_phone=guest_phone, guest_email=guest_email, rooms_required=rooms_required, total_guest=total_guest, purpose=purpose, + arrival_date=arrival_date, arrival_time=arrival_time, departure_date=departure_date, departure_time=departure_time, nationality=nationality) newBooking.save() - messages.success(request,"Room booked successfuly") + messages.success(request, "Room booked successfuly") return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) else: messages.error(request, "Something went wrong") return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) + @login_required def update_guest_room(request): if request.method == "POST": if 'accept_request' in request.POST: status = request.POST['status'] - guest_room_request = GuestRoomBooking.objects.get(pk=request.POST['accept_request']) - guest_room_instance = GuestRoom.objects.get(hall=guest_room_request.hall, room=request.POST['guest_room_id']) + guest_room_request = GuestRoomBooking.objects.get( + pk=request.POST['accept_request']) + guest_room_instance = GuestRoom.objects.get( + hall=guest_room_request.hall, room=request.POST['guest_room_id']) # Assign the guest room ID to guest_room_id field guest_room_request.guest_room_id = str(guest_room_instance.id) - room_booked = GuestRoom.objects.get(hall=guest_room_request.hall, room=request.POST['guest_room_id']) + room_booked = GuestRoom.objects.get( + hall=guest_room_request.hall, room=request.POST['guest_room_id']) room_booked.occupied_till = guest_room_request.departure_date room_booked.save() # Save the guest room request after updating the fields @@ -1434,19 +1459,17 @@ def update_guest_room(request): guest_room_request.save() messages.success(request, "Request accepted successfully!") elif 'reject_request' in request.POST: - guest_room_request = GuestRoomBooking.objects.get(pk=request.POST['reject_request']) + guest_room_request = GuestRoomBooking.objects.get( + pk=request.POST['reject_request']) guest_room_request.status = 'Rejected' guest_room_request.save() - + messages.success(request, "Request rejected successfully!") else: messages.error(request, "Invalid request!") return HttpResponseRedirect(reverse("hostelmanagement:hostel_view")) - - - # //Caretaker can approve or reject leave applied by the student @csrf_exempt def update_leave_status(request): @@ -1464,34 +1487,22 @@ def update_leave_status(request): return JsonResponse({'status': 'error', 'message': 'Only POST requests are allowed.'}, status=405) - - - - - - # //! Manage Fine # //todo: Add Fine Functionality - -from rest_framework import status -from rest_framework.response import Response -from django.http import HttpResponseBadRequest @login_required def impose_fine_view(request): user_id = request.user - staff=user_id.extrainfo.id - students = Student.objects.all(); + staff = user_id.extrainfo.id + students = Student.objects.all() if HallCaretaker.objects.filter(staff_id=staff).exists(): - return render(request, 'hostelmanagement/impose_fine.html',{'students':students}) + return render(request, 'hostelmanagement/impose_fine.html', {'students': students}) return HttpResponse(f'') - - class HostelFineView(APIView): """ API endpoint for imposing fines on students. @@ -1503,7 +1514,6 @@ class HostelFineView(APIView): def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) - def post(self, request): # Check if the user is a caretaker user_id = request.user @@ -1522,8 +1532,6 @@ def post(self, request): amount = request.data.get('amount') reason = request.data.get('reason') - - # Validate the data if not all([student_id, student_name, amount, reason]): return HttpResponse({'error': 'Incomplete data provided.'}, status=status.HTTP_400_BAD_REQUEST) @@ -1541,6 +1549,7 @@ def post(self, request): except Exception as e: return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + @login_required def get_student_name(request, username): try: @@ -1550,14 +1559,15 @@ def get_student_name(request, username): except User.DoesNotExist: return JsonResponse({"error": "User not found"}, status=404) + @login_required def hostel_fine_list(request): user_id = request.user - staff=user_id.extrainfo.id + staff = user_id.extrainfo.id caretaker = HallCaretaker.objects.get(staff_id=staff) hall_id = caretaker.hall_id - hostel_fines = HostelFine.objects.filter(hall_id=hall_id).order_by('fine_id') - + hostel_fines = HostelFine.objects.filter( + hall_id=hall_id).order_by('fine_id') if HallCaretaker.objects.filter(staff_id=staff).exists(): return render(request, 'hostelmanagement/hostel_fine_list.html', {'hostel_fines': hostel_fines}) @@ -1565,7 +1575,6 @@ def hostel_fine_list(request): return HttpResponse(f'') - @login_required def student_fine_details(request): user_id = request.user.username @@ -1575,7 +1584,7 @@ def student_fine_details(request): # Check if the user_id exists in the Student table # if HallCaretaker.objects.filter(staff_id=staff).exists(): # return HttpResponse('') - + if not Student.objects.filter(id_id=user_id).exists(): return HttpResponse('') @@ -1586,13 +1595,12 @@ def student_fine_details(request): # # Retrieve the fines associated with the current student student_fines = HostelFine.objects.filter(student_id=user_id) - return render(request, 'hostelmanagement/student_fine_details.html', {'student_fines': student_fines}) # return JsonResponse({'message': 'Nice'}, status=status.HTTP_200_OK) -class HostelFineUpdateView(APIView): +class HostelFineUpdateView(APIView): authentication_classes = [SessionAuthentication] permission_classes = [IsAuthenticated] @@ -1600,7 +1608,7 @@ class HostelFineUpdateView(APIView): def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) - def post(self, request, fine_id): + def post(self, request, fine_id): user_id = request.user staff = user_id.extrainfo.id @@ -1622,7 +1630,8 @@ def post(self, request, fine_id): # Get hostel fine object try: - hostel_fine = HostelFine.objects.get(hall_id=hall_id, fine_id=fine_id) + hostel_fine = HostelFine.objects.get( + hall_id=hall_id, fine_id=fine_id) except HostelFine.DoesNotExist: raise NotFound(detail="Hostel fine not found") @@ -1636,9 +1645,6 @@ def post(self, request, fine_id): # Return success response return Response({'message': 'Hostel fine status updated successfully!'}, status=status.HTTP_200_OK) - - - def delete(self, request, fine_id): user_id = request.user @@ -1651,14 +1657,15 @@ def delete(self, request, fine_id): hall_id = caretaker.hall_id - # Convert fine_id to integer + # Convert fine_id to integer fine_id = int(fine_id) # Get hostel fine object try: - hostel_fine = HostelFine.objects.get(hall_id=hall_id, fine_id=fine_id) + hostel_fine = HostelFine.objects.get( + hall_id=hall_id, fine_id=fine_id) hostel_fine.delete() except HostelFine.DoesNotExist: raise NotFound(detail="Hostel fine not found") - return Response({'message': 'Fine deleted successfully.'}, status=status.HTTP_204_NO_CONTENT) \ No newline at end of file + return Response({'message': 'Fine deleted successfully.'}, status=status.HTTP_204_NO_CONTENT) diff --git a/FusionIIIT/templates/hostelmanagement/create_leave.html b/FusionIIIT/templates/hostelmanagement/create_leave.html index 43c2b91ac..99d4fe7bc 100644 --- a/FusionIIIT/templates/hostelmanagement/create_leave.html +++ b/FusionIIIT/templates/hostelmanagement/create_leave.html @@ -52,6 +52,7 @@

Leave Form

alert(data.message); // Optionally, reset form fields form.reset(); + window.location.href = "/hostelmanagement/"; }) .catch(error => { console.error('There was a problem with the fetch operation:', error); diff --git a/FusionIIIT/templates/hostelmanagement/hostel.html b/FusionIIIT/templates/hostelmanagement/hostel.html index d7d256140..288923275 100644 --- a/FusionIIIT/templates/hostelmanagement/hostel.html +++ b/FusionIIIT/templates/hostelmanagement/hostel.html @@ -50,7 +50,7 @@
{% endif %} - {% if user.username in all_students_id or user in hall_caretaker or user in hall_warden %} + {% if user in hall_caretaker %} Student Attendance @@ -93,7 +93,7 @@ {% endif %} - {% if user in hall_caretaker or user in hall_warden %} + {% if user in hall_caretaker %} Inventory Form @@ -176,6 +176,14 @@ {% endif %} + + {% if user in hall_caretaker%} + + Inventory list + + + {% endif %} +
@@ -333,6 +341,15 @@
{% endif %} + {% if user in hall_caretaker %} +
+ {% block inventory_list %} + {% include 'hostelmanagement/inventory_list.html' %} + {% endblock %} +
+ {% endif %} + +
diff --git a/FusionIIIT/templates/hostelmanagement/hostel_fine_list.html b/FusionIIIT/templates/hostelmanagement/hostel_fine_list.html index bd1e4b537..45197439f 100644 --- a/FusionIIIT/templates/hostelmanagement/hostel_fine_list.html +++ b/FusionIIIT/templates/hostelmanagement/hostel_fine_list.html @@ -1,6 +1,6 @@ {% block fine_list %}

Hostel Fine List

- +
@@ -28,12 +28,17 @@

Hostel Fine List

- + {% endfor %}
Fine ID {{ hostel_fine.reason }}
- + - - +{% endblock %} diff --git a/FusionIIIT/templates/hostelmanagement/my_leaves.html b/FusionIIIT/templates/hostelmanagement/my_leaves.html index ea0fe79c8..220df74a9 100644 --- a/FusionIIIT/templates/hostelmanagement/my_leaves.html +++ b/FusionIIIT/templates/hostelmanagement/my_leaves.html @@ -18,7 +18,7 @@

My Leaves

{{ leave.start_date }} {{ leave.end_date }} + class="{% if leave.status == 'Approved' %}approved-status{% elif leave.status == 'Rejected' %}rejected-status{% elif leave.status == 'pending' %}pending-status{%endif%}"> {{ leave.status }} @@ -37,5 +37,9 @@

My Leaves

background-color: #ff0000; /* Red for Rejected status */ } + .pending-status { + background-color: #ffff00; + /* Yellow for Pending status */ + } {% endblock %} diff --git a/FusionIIIT/templates/hostelmanagement/student_details.html b/FusionIIIT/templates/hostelmanagement/student_details.html index 07446a551..8790ebd89 100644 --- a/FusionIIIT/templates/hostelmanagement/student_details.html +++ b/FusionIIIT/templates/hostelmanagement/student_details.html @@ -16,18 +16,18 @@

Student Details

- {% for student in students %} + {% for stu in hostel_students_details %} - {{ student.id }} - {{ student.first_name }} - {{ student.last_name }} - {{ student.programme }} - {{ student.batch }} - {{ student.room_num }} - {{ student.hall_id }} - {{ student.specialization }} - {{ student.parent_contact }} - {{ student.address }} + {{ stu.id }} + {{ stu.first_name }} + {{ stu.last_name }} + {{ stu.programme }} + {{ stu.batch }} + {{ stu.room_num }} + {{ stu.hall_id }} + {{ stu.specialization }} + {{ stu.parent_contact }} + {{ stu.address }} {% endfor %} From 084ed26dd50eaa49555955db11b3212025f6f2f7 Mon Sep 17 00:00:00 2001 From: Srivatsa19 Date: Thu, 22 Feb 2024 19:43:54 +0530 Subject: [PATCH 054/158] Implemented the cerate_request, process_request and approve/reject_request use cases. --- FusionIIIT/applications/iwdModuleV2/models.py | 19 +++ FusionIIIT/applications/iwdModuleV2/urls.py | 13 +- FusionIIIT/applications/iwdModuleV2/views.py | 135 +++++++++++++++- .../templates/dashboard/sidenavbar.html | 6 +- .../templates/iwdModuleV2/billsView.html | 147 ++++++++++++++++++ .../iwdModuleV2/createdRequests.html | 120 ++++++++++++++ .../templates/iwdModuleV2/dashboard.html | 77 ++++++--- .../iwdModuleV2/deanProcessedRequests.html | 96 ++++++++++++ .../engineerProcessedRequests.html | 121 ++++++++++++++ .../templates/iwdModuleV2/requestsStatus.html | 114 ++++++++++++++ .../templates/iwdModuleV2/requestsView.html | 124 +++++++++++++++ requirements.txt | 2 +- 12 files changed, 943 insertions(+), 31 deletions(-) create mode 100644 FusionIIIT/templates/iwdModuleV2/billsView.html create mode 100644 FusionIIIT/templates/iwdModuleV2/createdRequests.html create mode 100644 FusionIIIT/templates/iwdModuleV2/deanProcessedRequests.html create mode 100644 FusionIIIT/templates/iwdModuleV2/engineerProcessedRequests.html create mode 100644 FusionIIIT/templates/iwdModuleV2/requestsStatus.html create mode 100644 FusionIIIT/templates/iwdModuleV2/requestsView.html diff --git a/FusionIIIT/applications/iwdModuleV2/models.py b/FusionIIIT/applications/iwdModuleV2/models.py index a5c40c7b2..c0754c70d 100644 --- a/FusionIIIT/applications/iwdModuleV2/models.py +++ b/FusionIIIT/applications/iwdModuleV2/models.py @@ -160,3 +160,22 @@ class NoOfTechnicalBidTimes(models.Model): key = models.ForeignKey(Projects, on_delete=models.CASCADE, unique=True) number = models.IntegerField() +class Requests(models.Model): + # id = models.IntegerField(primary_key=True, max_length=200) + name = models.CharField(max_length=200) + description = models.CharField(max_length=200) + area = models.CharField(max_length=200) + requestCreatedBy = models.CharField(max_length=200) + engineerProcessed = models.IntegerField() + directorApproval = models.IntegerField() + deanProcessed = models.IntegerField() + status = models.CharField(max_length=200) + +class Bills(models.Model): + key = models.ForeignKey(Projects, on_delete=models.CASCADE, unique=True) + name = models.CharField(max_length=200) + work = models.CharField(max_length=200) + description = models.CharField(max_length=200) + agency = models.CharField(max_length=200) + bill_processed = models.IntegerField() + bill_settled = models.IntegerField() \ No newline at end of file diff --git a/FusionIIIT/applications/iwdModuleV2/urls.py b/FusionIIIT/applications/iwdModuleV2/urls.py index 6ad401098..2f047d690 100644 --- a/FusionIIIT/applications/iwdModuleV2/urls.py +++ b/FusionIIIT/applications/iwdModuleV2/urls.py @@ -36,5 +36,16 @@ url(r'milestoneView/$', views.milestoneView, name='Milestones'), url(r'addendumView/$', views.addendumView, name='Addendum View'), url('agreementView/$', views.agreementView, name='Agreement VIew'), - url(r'corrigendumView/$', views.corrigendumView, name='Corrigendum View') + url(r'corrigendumView/$', views.corrigendumView, name='Corrigendum View'), + url('requestsView/',views.requestsView, name='Requests view'), + url('createdRequestsView/',views.createdRequests, name='Created Requests view'), + url('handleEngineerProcessRequests/', views.handleEngineerProcessRequests, name='Engineer-Process-Requests'), + url('engineerProcessedRequestsView/',views.engineerProcessedRequests, name='Engineer-Processed-Requests view'), + url('handleDeanProcessRequests/', views.handleDeanProcessRequests, name='Dean-Process-Requests'), + url('deanProcessedRequestsView/',views.deanProcessedRequests, name='Dean-Processed-Requests view'), + url('handleDirectorApprovalRequests/', views.handleDirectorApprovalRequests, name='Director-Approval-Requests'), + url('handleDirectorRejectionRequests/', views.handleDirectorRejectionRequests, name='Director-Rejection-Requests'), + url('requestsStatus/', views.requestsStatus, name='Requests-Status'), + url('billsView/',views.billsView, name='Bills View'), + ] diff --git a/FusionIIIT/applications/iwdModuleV2/views.py b/FusionIIIT/applications/iwdModuleV2/views.py index 2b36550fc..0a532548d 100644 --- a/FusionIIIT/applications/iwdModuleV2/views.py +++ b/FusionIIIT/applications/iwdModuleV2/views.py @@ -1,5 +1,5 @@ from django.shortcuts import render, redirect - +from django.db.models import Q from applications.globals.models import * from .models import * from django.http import HttpResponseRedirect @@ -17,17 +17,24 @@ # owing to length and inherent extensiveness of code. Rather than, whosoever read this code is advised to do so # in conjunction with SRS. After that, everything will become easier. +# def dashboard(request): +# eligible = False +# userObj = request.user +# userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) +# for p in userDesignationObjects: +# if p.designation.name == 'Admin IWD': +# eligible = True +# break +# return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) + def dashboard(request): - eligible = False + eligible = "" userObj = request.user userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) for p in userDesignationObjects: - if p.designation.name == 'Admin IWD': - eligible = True - break + eligible = p.designation.name return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) - def page1_1(request): if request.method == 'POST': formObject = PageOneDetails() @@ -401,3 +408,119 @@ def page3View(request): def extensionFormView(request): extensionObjects = ExtensionOfTimeDetails.objects.filter(key=Projects.objects.get(id=request.session['projectId'])) return render(request, 'iwdModuleV2/ExtensionForm.html', {'extension': extensionObjects}) + +def requestsView(request): + if request.method == 'POST': + formObject = Requests() + # formObject.key = Projects.objects.get(id=request.session['projectId']) + formObject.name = request.POST['name'] + formObject.description = request.POST['description'] + formObject.area = request.POST['area'] + formObject.engineerProcessed = 0 + formObject.directorApproval = 0 + formObject.deanProcessed = 0 + formObject.requestCreatedBy = request.user.username + formObject.status = "Pending" + formObject.save() + return redirect('http://127.0.0.1:8000/iwdModuleV2/') + return render(request, 'http://127.0.0.1:8000/iwdModuleV2/', {}) + + +def billsView(request): + if request.method == 'POST': + formObject = Requests() + # formObject.key = Projects.objects.get(id=request.session['projectId']) + formObject.name = request.POST['name'] + formObject.work = request.POST['work'] + formObject.description = request.POST['description'] + formObject.agency = request.POST['agency'] + formObject.bill_processed = request.POST['bill_processed'] + formObject.bill_settled = request.POST['bill_settled'] + formObject.save() + return redirect('iwdModuleV2/billsView.html') + return render(request, 'iwdModuleV2/billsView.html', {}) + +def createdRequests(request): + obj = [] + requestsObject = Requests.objects.exclude( + Q(requestCreatedBy=request.user.username) | + Q(engineerProcessed__gt=0) | + Q(deanProcessed__gt=0) | + Q(directorApproval__gt=0) + ) + + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy] + obj.append(element) + return render(request, 'iwdModuleV2/createdRequests.html', {'obj' : obj}) + +def handleEngineerProcessRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + Requests.objects.filter(id=request_id).update(engineerProcessed=1, status="Approved by the engineer") + obj = [] + requestsObject = Requests.objects.filter(engineerProcessed = 0, deanProcessed = 0, directorApproval = 0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy] + obj.append(element) + return render(request, 'iwdModuleV2/createdRequests.html', {'obj' : obj}) + +def engineerProcessedRequests(request): + obj = [] + requestsObject = Requests.objects.filter(engineerProcessed = 1, deanProcessed = 0, directorApproval = 0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy] + obj.append(element) + return render(request, 'iwdModuleV2/engineerProcessedRequests.html', {'obj' : obj}) + +def handleDeanProcessRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + Requests.objects.filter(id=request_id).update(deanProcessed=1, status="Approved by the dean") + obj = [] + requestsObject = Requests.objects.filter(engineerProcessed = 1, deanProcessed = 0, directorApproval = 0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy] + obj.append(element) + return render(request, 'iwdModuleV2/engineerProcessedRequests.html', {'obj' : obj}) + +def deanProcessedRequests(request): + print(request) + obj = [] + requestsObject = Requests.objects.filter(engineerProcessed = 1, deanProcessed = 1, directorApproval = 0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy] + obj.append(element) + return render(request, 'iwdModuleV2/deanProcessedRequests.html', {'obj' : obj}) + +def handleDirectorApprovalRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + Requests.objects.filter(id=request_id).update(directorApproval=1, status="Approved by the director") + obj = [] + requestsObject = Requests.objects.filter(engineerProcessed = 1, deanProcessed = 1, directorApproval = 0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy] + obj.append(element) + return render(request, 'iwdModuleV2/deanProcessedRequests.html', {'obj' : obj}) + +def handleDirectorRejectionRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + Requests.objects.filter(id=request_id).update(directorApproval=-1, status="Rejected by the director") + obj = [] + requestsObject = Requests.objects.filter(engineerProcessed = 1, deanProcessed = 1, directorApproval = 0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy] + obj.append(element) + return render(request, 'iwdModuleV2/deanProcessedRequests.html', {'obj' : obj}) + +def requestsStatus(request): + print(request) + obj = [] + requestsObject = Requests.objects.all() + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy, x.status] + obj.append(element) + return render(request, 'iwdModuleV2/requestsStatus.html', {'obj' : obj}) + diff --git a/FusionIIIT/templates/dashboard/sidenavbar.html b/FusionIIIT/templates/dashboard/sidenavbar.html index 81cecbe94..fbf346e47 100644 --- a/FusionIIIT/templates/dashboard/sidenavbar.html +++ b/FusionIIIT/templates/dashboard/sidenavbar.html @@ -53,9 +53,9 @@

Programme & Curriculum Module

Gymkhana Module

- -

IWD Module

-
+ +

IWD Module

+
{% if request.user.extrainfo.user_type == 'faculty' or request.user.extrainfo.user_type == 'staff' %}

Establishment Module

diff --git a/FusionIIIT/templates/iwdModuleV2/billsView.html b/FusionIIIT/templates/iwdModuleV2/billsView.html new file mode 100644 index 000000000..89969b1b8 --- /dev/null +++ b/FusionIIIT/templates/iwdModuleV2/billsView.html @@ -0,0 +1,147 @@ +{% extends 'globals/base.html' %} +{% load static %} + + +{% block title %} + Academic +{% endblock %} + + +{% block body %} + {% block navBar %} + {% include 'dashboard/navbar.html' %} + {% endblock %} + +
+ {% comment %}the doctor appointment tab ends here {% endcomment %} + + + + +
+ {% comment %}The central-rail segment ends here!{% endcomment %} + + {% comment %}The right-rail segment starts here!{% endcomment %} +
+
+ {% comment %} + TODO: the right rail! + {% endcomment %} +
+
+ {% comment %}The right-rail segment ends here!{% endcomment %} + + {% comment %}The right-margin segment!{% endcomment %} +
+ +
+ {% comment %}The grid ends here!{% endcomment %} + +{% endblock %} + +{% block javascript %} + + + + +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/iwdModuleV2/createdRequests.html b/FusionIIIT/templates/iwdModuleV2/createdRequests.html new file mode 100644 index 000000000..a7f86e523 --- /dev/null +++ b/FusionIIIT/templates/iwdModuleV2/createdRequests.html @@ -0,0 +1,120 @@ +{% extends 'globals/base.html' %} +{% load static %} + + +{% block title %} +Academic +{% endblock %} + + +{% block body %} +{% block navBar %} +{% include 'dashboard/navbar.html' %} +{% endblock %} + +
+ + {% comment %}The left-margin segment!{% endcomment %} +
+ + {% comment %}The left-rail segment starts here!{% endcomment %} +
+ {% comment %}The user image card starts here!{% endcomment %} + {% block usercard %} + {% include 'globals/usercard.html' %} + {% endblock %} + {% comment %}The user image card ends here!{% endcomment %} + +
+ + {% comment %}The Tab-Menu ends here!{% endcomment %} +
+ {% comment %} + The left-rail segment ends here! + {% endcomment %} + + {% comment %} + The central-rail segment starts here! + {% endcomment %} +
+ + + + {% load static %} + {% comment %}the main tab starts here {% endcomment %} +
+ +
+
+ Created Requests +
+
+
+
+ + + + + + + + + + + + + + {% for f in obj %} + + + + + + + + + + + {% endfor %} +
Details:-
IdNameDescriptionAreaCreated By
{{f.0}}{{f.1}}{{f.3}}{{f.2}}{{f.4}} + +
+ {% csrf_token %} + + +
+
+
+
+
+ + + +
+ {% comment %}The central-rail segment ends here!{% endcomment %} + + {% comment %}The right-rail segment starts here!{% endcomment %} +
+
+ {% comment %} + TODO: the right rail! + {% endcomment %} +
+
+ {% comment %}The right-rail segment ends here!{% endcomment %} + + {% comment %}The right-margin segment!{% endcomment %} +
+ +
+{% comment %}The grid ends here!{% endcomment %} + +{% endblock %} + +{% block javascript %} + + + + +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/iwdModuleV2/dashboard.html b/FusionIIIT/templates/iwdModuleV2/dashboard.html index 9f0e1db49..12c27a550 100644 --- a/FusionIIIT/templates/iwdModuleV2/dashboard.html +++ b/FusionIIIT/templates/iwdModuleV2/dashboard.html @@ -34,28 +34,24 @@
{% comment %}ROW #2 starts here!{% endcomment %} - {% if eligible %} + {% if eligible == "Engineer" %}
{% comment %}The Tab-Menu starts here!{% endcomment %} {% comment %}The Tab-Menu ends here!{% endcomment %} @@ -69,22 +65,63 @@ {% comment %}The central-rail segment starts here!{% endcomment %}
{% comment %}The Appointments Form starts here!{% endcomment %} -
+
{% block appointment %} - {% include 'iwdModuleV2/createWork.html' %} + {% include 'iwdModuleV2/requestsView.html' %} {% endblock %}
- {% comment %}The appointment Form ends here!{% endcomment %} - {% comment %}The patient history starts here!{% endcomment %} -
- {% block history %} - {% include 'iwdModuleV2/viewWork.html' %} - {% endblock %} +
+ {% endif %} + {% if eligible == "Dean" %} +
+ {% comment %}The Tab-Menu starts here!{% endcomment %} + + {% comment %}The Tab-Menu ends here!{% endcomment %} +
- {% comment %}The patient history ends here!{% endcomment %} + {% comment %}ROW #2 ends here!{% endcomment %}
+ {% comment %}The left-rail segment ends here!{% endcomment %} + + {% comment %}The central-rail segment starts here!{% endcomment %} + {% endif %} + {% if eligible == "director" %} +
+ {% comment %}The Tab-Menu starts here!{% endcomment %} + + {% comment %}The Tab-Menu ends here!{% endcomment %} + +
+ {% comment %}ROW #2 ends here!{% endcomment %} + +
+ {% comment %}The left-rail segment ends here!{% endcomment %} + + {% comment %}The central-rail segment starts here!{% endcomment %} {% endif %} {% comment %}The central-rail segment ends here!{% endcomment %} diff --git a/FusionIIIT/templates/iwdModuleV2/deanProcessedRequests.html b/FusionIIIT/templates/iwdModuleV2/deanProcessedRequests.html new file mode 100644 index 000000000..dd9ba8ba8 --- /dev/null +++ b/FusionIIIT/templates/iwdModuleV2/deanProcessedRequests.html @@ -0,0 +1,96 @@ +{% extends 'globals/base.html' %} +{% load static %} + +{% block title %} + Academic +{% endblock %} + +{% block body %} + {% block navBar %} + {% include 'dashboard/navbar.html' %} + {% endblock %} + + +
+
+
+ {% block usercard %} + {% include 'globals/usercard.html' %} + {% endblock %} +
+
+
+
+ + +
+
+ Dean processed Requests +
+ +
+
+
+ + + + + + + + + + + + + {% for f in obj %} + + + + + + + + + + + {% endfor %} +
Details:-
IdNameDescriptionAreaCreated By
{{f.0}}{{f.1}}{{f.3}}{{f.2}}{{f.4}} +
+
+ {% csrf_token %} + + +
+
+ {% csrf_token %} + + +
+
+
+
+
+
+
+
+
+ +
+
+
+
+{% endblock %} diff --git a/FusionIIIT/templates/iwdModuleV2/engineerProcessedRequests.html b/FusionIIIT/templates/iwdModuleV2/engineerProcessedRequests.html new file mode 100644 index 000000000..7c3bd813d --- /dev/null +++ b/FusionIIIT/templates/iwdModuleV2/engineerProcessedRequests.html @@ -0,0 +1,121 @@ +{% extends 'globals/base.html' %} +{% load static %} + + +{% block title %} + Academic +{% endblock %} + + +{% block body %} + {% block navBar %} + {% include 'dashboard/navbar.html' %} + {% endblock %} + +
+ + {% comment %}The left-margin segment!{% endcomment %} +
+ + {% comment %}The left-rail segment starts here!{% endcomment %} +
+ {% comment %}The user image card starts here!{% endcomment %} + {% block usercard %} + {% include 'globals/usercard.html' %} + {% endblock %} + {% comment %}The user image card ends here!{% endcomment %} + +
+ + {% comment %}The Tab-Menu ends here!{% endcomment %} +
+ {% comment %} + The left-rail segment ends here! + {% endcomment %} + + {% comment %} + The central-rail segment starts here! + {% endcomment %} +
+ + + + + + {% load static %} + {% comment %}the main tab starts here {% endcomment %} +
+ +
+
+ Engineer Processed Requests +
+
+
+
+ + + + + + + + + + + + + + {% for f in obj %} + + + + + + + + + + + {% endfor %} +
Details:-
IdNameDescriptionAreaCreated By
{{f.0}}{{f.1}}{{f.3}}{{f.2}}{{f.4}} + +
+ {% csrf_token %} + + +
+
+
+
+
+ + + +
+ {% comment %}The central-rail segment ends here!{% endcomment %} + + {% comment %}The right-rail segment starts here!{% endcomment %} +
+
+ {% comment %} + TODO: the right rail! + {% endcomment %} +
+
+ {% comment %}The right-rail segment ends here!{% endcomment %} + + {% comment %}The right-margin segment!{% endcomment %} +
+ +
+ {% comment %}The grid ends here!{% endcomment %} + +{% endblock %} + +{% block javascript %} + + + + +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/iwdModuleV2/requestsStatus.html b/FusionIIIT/templates/iwdModuleV2/requestsStatus.html new file mode 100644 index 000000000..14711ab16 --- /dev/null +++ b/FusionIIIT/templates/iwdModuleV2/requestsStatus.html @@ -0,0 +1,114 @@ +{% extends 'globals/base.html' %} +{% load static %} + + +{% block title %} + Academic +{% endblock %} + + +{% block body %} + {% block navBar %} + {% include 'dashboard/navbar.html' %} + {% endblock %} + +
+ + {% comment %}The left-margin segment!{% endcomment %} +
+ + {% comment %}The left-rail segment starts here!{% endcomment %} +
+ {% comment %}The user image card starts here!{% endcomment %} + {% block usercard %} + {% include 'globals/usercard.html' %} + {% endblock %} + {% comment %}The user image card ends here!{% endcomment %} + +
+ + {% comment %}The Tab-Menu ends here!{% endcomment %} +
+ {% comment %} + The left-rail segment ends here! + {% endcomment %} + + {% comment %} + The central-rail segment starts here! + {% endcomment %} +
+ + + + + + {% load static %} + {% comment %}the main tab starts here {% endcomment %} +
+ +
+
+ Requests Status +
+
+
+
+ + + + + + + + + + + + + + {% for f in obj %} + + + + + + + + + + + {% endfor %} +
Details:-
IdNameDescriptionAreaCreated ByStatus
{{f.0}}{{f.1}}{{f.3}}{{f.2}}{{f.4}}{{f.5}}
+
+
+
+ + + +
+ {% comment %}The central-rail segment ends here!{% endcomment %} + + {% comment %}The right-rail segment starts here!{% endcomment %} +
+
+ {% comment %} + TODO: the right rail! + {% endcomment %} +
+
+ {% comment %}The right-rail segment ends here!{% endcomment %} + + {% comment %}The right-margin segment!{% endcomment %} +
+ +
+ {% comment %}The grid ends here!{% endcomment %} + +{% endblock %} + +{% block javascript %} + + + + +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/iwdModuleV2/requestsView.html b/FusionIIIT/templates/iwdModuleV2/requestsView.html new file mode 100644 index 000000000..230ebe362 --- /dev/null +++ b/FusionIIIT/templates/iwdModuleV2/requestsView.html @@ -0,0 +1,124 @@ + +{% load static %} + + +{% block title %} + Academic +{% endblock %} + + +{% block body %} + {% block navBar %} + + {% endblock %} + + + + {% comment %}The left-margin segment!{% endcomment %} + + + {% comment %}The left-rail segment starts here!{% endcomment %} + + {% comment %}The user image card starts here!{% endcomment %} + {% block usercard %} + + {% endblock %} + {% comment %}The user image card ends here!{% endcomment %} + + + + {% comment %}The Tab-Menu ends here!{% endcomment %} + + {% comment %} + The left-rail segment ends here! + {% endcomment %} + + {% comment %} + The central-rail segment starts here! + {% endcomment %} +
+ + + + + + {% load static %} +
+ Requests +
+
{% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+ + +
+ + +
+ +
+
+ + +
+
+
+
+ + + + {% comment %}The central-rail segment ends here!{% endcomment %} + + {% comment %}The right-rail segment starts here!{% endcomment %} + + {% comment %}The right-rail segment ends here!{% endcomment %} + + {% comment %}The right-margin segment!{% endcomment %} + + {% comment %}The grid ends here!{% endcomment %} + +{% endblock %} + +{% block javascript %} + + + + +{% endblock %} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 4cc3a0a30..f30bb509a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ amqp==5.0.2 -arabic-reshaper==2.1.1 +# arabic-reshaper==2.1.1 asgiref==3.3.1 attrs==20.3.0 beautifulsoup4==4.9.3 From d65e0a117a67bd16198de7fa18c79c231cdda8d1 Mon Sep 17 00:00:00 2001 From: Aniket Date: Fri, 23 Feb 2024 11:50:28 +0530 Subject: [PATCH 055/158] ps1 changes --- FusionIIIT/Fusion/settings/development.py | 2 +- .../ps1/migrations/0002_auto_20240219_2009.py | 28 ++ FusionIIIT/applications/ps1/models.py | 3 + FusionIIIT/applications/ps1/urls.py | 8 +- FusionIIIT/applications/ps1/views.py | 190 ++++++++++---- FusionIIIT/templates/ps1/composeIndent.html | 20 +- FusionIIIT/templates/ps1/forwardindent.html | 13 +- FusionIIIT/templates/ps1/generate_report.html | 11 +- .../templates/ps1/perform_transfer1.html | 162 ++++++++++++ FusionIIIT/templates/ps1/ps2.html | 9 +- FusionIIIT/templates/ps1/report.html | 246 ++++++++++++++++++ FusionIIIT/templates/ps1/stock_transfer.html | 158 +++++++++++ 12 files changed, 774 insertions(+), 76 deletions(-) create mode 100644 FusionIIIT/applications/ps1/migrations/0002_auto_20240219_2009.py create mode 100644 FusionIIIT/templates/ps1/perform_transfer1.html create mode 100644 FusionIIIT/templates/ps1/report.html create mode 100644 FusionIIIT/templates/ps1/stock_transfer.html diff --git a/FusionIIIT/Fusion/settings/development.py b/FusionIIIT/Fusion/settings/development.py index 6acc214c1..5fd6a1e2e 100644 --- a/FusionIIIT/Fusion/settings/development.py +++ b/FusionIIIT/Fusion/settings/development.py @@ -9,7 +9,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'fusionlab', + 'NAME': 'fusionlab2', 'HOST': os.environ.get("DB_HOST", default='localhost'), 'USER': 'fusion_admin', 'PASSWORD': 'hello123', diff --git a/FusionIIIT/applications/ps1/migrations/0002_auto_20240219_2009.py b/FusionIIIT/applications/ps1/migrations/0002_auto_20240219_2009.py new file mode 100644 index 000000000..c72ddbdfc --- /dev/null +++ b/FusionIIIT/applications/ps1/migrations/0002_auto_20240219_2009.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.5 on 2024-02-19 20:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ps1', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='stockentry', + name='dept', + field=models.CharField(max_length=250, null=True), + ), + migrations.AddField( + model_name='stockentry', + name='to_dept', + field=models.CharField(max_length=250, null=True), + ), + migrations.AddField( + model_name='stockentry', + name='transfer', + field=models.BooleanField(default=False, null=True), + ), + ] diff --git a/FusionIIIT/applications/ps1/models.py b/FusionIIIT/applications/ps1/models.py index bee76f36e..cf8e69b07 100644 --- a/FusionIIIT/applications/ps1/models.py +++ b/FusionIIIT/applications/ps1/models.py @@ -36,6 +36,9 @@ class StockEntry(models.Model): current_stock=models.IntegerField(blank=False) recieved_date=models.DateField(blank=False) bill=models.FileField(blank=False) + transfer = models.BooleanField(default = False, null=True) + dept = models.CharField(max_length=250,null=True, blank=False) + to_dept = models.CharField(max_length=250,null=True, blank=False) class Meta: db_table = 'StockEntry' \ No newline at end of file diff --git a/FusionIIIT/applications/ps1/urls.py b/FusionIIIT/applications/ps1/urls.py index 43f7299a4..fe6324087 100644 --- a/FusionIIIT/applications/ps1/urls.py +++ b/FusionIIIT/applications/ps1/urls.py @@ -7,6 +7,7 @@ urlpatterns = [ url(r'^$', views.ps1, name='ps1'), + url(r'^create_proposal/$', views.create_proposal, name='create_proposal'), # url(r'^compose_indent/$', views.compose_indent, name='compose_indent'), url(r'^composed_indents/$', views.composed_indents, name='composed_indents'), url(r'^indentview/(?P\d+)$', views.indentview, name='indentview'), @@ -25,5 +26,10 @@ url(r'^stock_update/$', views.stock_update, name='stock_update'), url(r'^entry/$', views.entry, name='entry'), url(r'^stock_login/$', views.dealing_assistant, name='dealing_assistant'), - url(r'^generate_report/$', views.generate_report, name='generate_report') + url(r'^generate_report/$', views.generate_report, name='generate_report'), + url(r'^report/$', views.report, name='report'), + url(r'view-bill//$', views.view_bill, name='view_bill'), + url(r'^perform_transfer/$', views.perform_transfer, name='perform_transfer'), + url(r'^stock_transfer/$', views.stock_transfer, name='stock_transfer') + ] diff --git a/FusionIIIT/applications/ps1/views.py b/FusionIIIT/applications/ps1/views.py index b97dc7529..0374c3d6d 100644 --- a/FusionIIIT/applications/ps1/views.py +++ b/FusionIIIT/applications/ps1/views.py @@ -11,18 +11,32 @@ from django.contrib.auth.models import User from timeit import default_timer as time from notification.views import office_module_notif +from django.utils import timezone + + @login_required(login_url = "/accounts/login/") def ps1(request): - # print("-------------------------------------------------") - # print(request.user) - # print("-------------------------------------------------") - # print("-------------------------------------------------") - # print(request.GET) - # print("-------------------------------------------------") - # print("-------------------------------------------------") - # print(request.body) - # print("-------------------------------------------------") + des_obj = HoldsDesignation.objects.filter(user=request.user) + + if des_obj: + designations = [des.designation.name for des in des_obj] + + + if "ps_admin" in designations or "dept_admin" in designations: + return redirect('/purchase-and-store/entry/') + elif not("student" in designations) and str((request.user.extrainfo.department.name)): + return redirect('/purchase-and-store/create_proposal/') + else: + return redirect('/dashboard') + + + + + + +@login_required(login_url = "/accounts/login/") +def create_proposal(request): """ The function is used to create indents by faculty. It adds the indent datails to the indet_table of Purchase and Store module @@ -56,20 +70,8 @@ def ps1(request): purchased =request.POST.get('purchased') """ des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() - print("-------------------------------------------------") - print("designation ") - print(des.designation) - print("-------------------------------------------------") - if str(des.designation) == "student": - return redirect('/dashboard') - - if str(des.designation) == "dept_admin": - return redirect('/purchase-and-store/entry/') - if request.user.extrainfo.id == '132': - return redirect("/purchase-and-store/entry/") - - if request.method =="POST" and str(des.designation) == "Assistant Professor": + if request.method =="POST": try: if 'save' in request.POST: uploader = request.user.extrainfo @@ -128,6 +130,7 @@ def ps1(request): ) if 'send' in request.POST: + uploader = request.user.extrainfo subject = request.POST.get('title') description = request.POST.get('desc') @@ -153,6 +156,13 @@ def ps1(request): director_approval=False financial_approval=False purchased = False + designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user = request.user) + for des in designations: + if str(des.designation) == "Director": + head_approval=True + director_approval=True + financial_approval=True + break @@ -163,18 +173,19 @@ def ps1(request): sender = request.POST.get('design') current_design = HoldsDesignation.objects.select_related('user','working','designation').get(id=sender) + receiver = request.POST.get('receiver') try: receiver_id = User.objects.get(username=receiver) except Exception as e: messages.error(request, 'Enter a valid Username') return redirect('/filetracking/') - receive = request.POST.get('recieve') + receive = request.POST.get('receive') try: receive_design = Designation.objects.get(name=receive) except Exception as e: messages.error(request, 'Enter a valid Designation') - return redirect('/ps1/') + return redirect('/create_proposal/') file_id = create_file( @@ -186,10 +197,6 @@ def ps1(request): src_object_id="", file_extra_JSON={"value": 2}, attached_file=request.FILES.get('myfile') - # description=description, - # subject=subject, - # designation=designation, - # upload_file=upload_file ) IndentFile.objects.create( @@ -213,17 +220,6 @@ def ps1(request): purchased =purchased, ) - - - # Tracking.objects.create( - # file_id=file, - # current_id=current_id, - # current_design=current_design, - # receive_design=receive_design, - # receiver_id=receiver_id, - # remarks=remarks, - # upload_file=upload_file, - # ) office_module_notif(request.user, receiver_id) messages.success(request,'Indent Filed Successfully!') @@ -234,12 +230,31 @@ def ps1(request): extrainfo = ExtraInfo.objects.select_related('user','department').all() holdsdesignations = HoldsDesignation.objects.select_related('user','working','designation').all() designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user = request.user) + today = timezone.now().strftime('%Y-%m-%d') + + Receiver_designation = "HOD (" + get_ExtraInfo_object_from_username(request.user.username).department.name + ")" + + for des in designations: + if str(des.designation) == Receiver_designation: + Receiver_designation = "Director" + break + elif str(des.designation) == "Director": + Receiver_designation = "ps_admin" + break + + + users_with_designation = HoldsDesignation.objects.filter(designation__name=Receiver_designation) + Forward_to = [user_designation.user for user_designation in users_with_designation] context = { 'file': file, 'extrainfo': extrainfo, 'holdsdesignations': holdsdesignations, 'designations': designations, + 'today': today, + 'receiver':Receiver_designation, + 'forwardto': Forward_to + } return render(request, 'ps1/composeIndent.html', context) @@ -477,9 +492,6 @@ def forwardindent(request, id): # sender = request.POST.get('sender') # sender = request.user.id - print("-----------------------------------------------") - print(request.user.id) - print("-----------------------------------------------") # current_design = HoldsDesignation.objects.select_related('user','working','designation').get(id=sender) current_design = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() receiver = request.POST.get('receiver') @@ -566,14 +578,14 @@ def forwardindent(request, id): if val=="accept": - if any(d in designs for d in ("HOD (ME)", "HOD (ECE)", "CSE HOD", "HOD (Design)", "HOD (NS)")): + if any(d in designs for d in ("HOD (ME)", "HOD (ECE)", "HOD (CSE)", "HOD (Design)", "HOD (NS)")): indent.head_approval=True elif "Director" in designs: indent.director_approval=True indent.financial_approval=True else: - if any(d in designs for d in ("HOD (ME)", "HOD (ECE)", "CSE HOD", "HOD (Design)", "HOD (NS)")): + if any(d in designs for d in ("HOD (ME)", "HOD (ECE)", "HOD (CSE)", "HOD (Design)", "HOD (NS)")): indent.head_approval=False elif "Director" in designs: indent.director_approval=False @@ -589,6 +601,14 @@ def forwardindent(request, id): holdsdesignations = HoldsDesignation.objects.select_related('user','working','designation').all() designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) + Receiver_designation = "dept_admin "+get_ExtraInfo_object_from_username(request.user.username).department.name + users_with_designation = HoldsDesignation.objects.filter(designation__name=Receiver_designation) + Forward_to = [user_designation.user for user_designation in users_with_designation] + + + + + context = { # 'extrainfo': extrainfo, # 'holdsdesignations': holdsdesignations, @@ -596,6 +616,8 @@ def forwardindent(request, id): 'file': file, 'track': track, 'indent':indent, + 'receiver':Receiver_designation, + 'forwardto': Forward_to } return render(request, 'ps1/forwardindent.html', context) @@ -854,6 +876,7 @@ def stock_update(request): stocks.current_stock=request.POST.get('current_stock') #stocks.recieved_date=request.POST.get('recieved_date') stocks.bill=request.FILES.get('bill') + stocks.dept = request.POST.get('dept') stocks.save() return HttpResponseRedirect('../stock_view') @@ -886,8 +909,6 @@ def stock_view(request): if temp.item_id.purchased: print("Purchase Succesful") - print() - print() return render(request,'ps1/stock_view.html',{'sto':sto}) @login_required(login_url = "/accounts/login") @@ -937,10 +958,60 @@ def dealing_assistant(request): @login_required(login_url = "/accounts/login") def generate_report(request): - # stock_entries = StockEntry.objects.filter( - # item_id__file_info__designation__name='Professor' - # ) - # print(stock_entries) + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + department = request.user.extrainfo.department.name + + if str(des.designation) == "dept_admin": + sto=StockEntry.objects.filter(item_id__file_info__uploader__department__name=department) + else: + sto=StockEntry.objects.all() + + return render(request,'ps1/generate_report.html',{'sto':sto}) + + +@login_required(login_url = "/accounts/login") +def report(request): + id=request.POST.get('id') + designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) + indent=IndentFile.objects.select_related('file_info').get(file_info=id) + sto=StockEntry.objects.select_related('item_id').get(item_id=indent) + file=indent.file_info + total_stock = indent.quantity + indent.present_stock + + print(sto.recieved_date) + + context = { + 'designations':designations, + 'file': file, + 'indent':indent, + 'sto' : sto, + 'total_stock': total_stock + } + + return render(request,'ps1/report.html',context) + + +def view_bill(request, stock_entry_id): + stock_entry = get_object_or_404(StockEntry, pk=stock_entry_id) + + # Check if the bill file exists + if stock_entry.bill: + # Read the contents of the bill file + bill_content = stock_entry.bill.read() + + # Return the bill file as a response + response = HttpResponse(bill_content, content_type='application/pdf') + response['Content-Disposition'] = f'attachment; filename="{stock_entry.bill.name}"' + return response + else: + # If the bill file does not exist, return a 404 response + return HttpResponse("Bill not found", status=404) + + + + +@login_required(login_url = "/accounts/login") +def perform_transfer(request): des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() department = request.user.extrainfo.department.name @@ -950,4 +1021,21 @@ def generate_report(request): else: sto=StockEntry.objects.all() - return render(request,'ps1/generate_report.html',{'sto':sto}) \ No newline at end of file + return render(request,'ps1/perform_transfer1.html',{'sto':sto}) + + + +@login_required(login_url = "/accounts/login") +def stock_transfer(request): + # stocks=StockEntry.objects.get(pk=id) + # return render(request,'ps1/stock_edit.html',{'StockEntry':stocks}) + + + if request.method =="POST": + id=request.POST.get('id') + temp=File.objects.get(id=id) + temp1=IndentFile.objects.get(file_info=temp) + stocks=StockEntry.objects.get(item_id=temp1) + return render(request,'ps1/stock_transfer.html',{'StockEntry':stocks}) + + return HttpResponseRedirect('../stock_transfer') \ No newline at end of file diff --git a/FusionIIIT/templates/ps1/composeIndent.html b/FusionIIIT/templates/ps1/composeIndent.html index 8fa6269ad..716ae415e 100644 --- a/FusionIIIT/templates/ps1/composeIndent.html +++ b/FusionIIIT/templates/ps1/composeIndent.html @@ -87,7 +87,7 @@

- +
@@ -169,20 +169,24 @@

Replaced*