diff --git a/FusionIIIT/Fusion/middleware/custom_middleware.py b/FusionIIIT/Fusion/middleware/custom_middleware.py index f77873534..fd8528e6e 100644 --- a/FusionIIIT/Fusion/middleware/custom_middleware.py +++ b/FusionIIIT/Fusion/middleware/custom_middleware.py @@ -19,8 +19,10 @@ def user_logged_in_handler(sender, user, request, **kwargs): design = HoldsDesignation.objects.select_related('user','designation').filter(working=request.user) designation=[] - - designation.append(str(user.extrainfo.user_type)) + if str(user.extrainfo.user_type) == "student": + designation.append(str(user.extrainfo.user_type)) + + for i in design: if str(i.designation) != str(user.extrainfo.user_type): print('-------') diff --git a/FusionIIIT/applications/academic_information/migrations/0001_initial.py b/FusionIIIT/applications/academic_information/migrations/0001_initial.py index f75d3119c..4b0f359c3 100644 --- a/FusionIIIT/applications/academic_information/migrations/0001_initial.py +++ b/FusionIIIT/applications/academic_information/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.db import migrations, models import django.db.models.deletion @@ -9,8 +9,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('programme_curriculum', '0001_initial'), ('globals', '0001_initial'), + ('programme_curriculum', '0001_initial'), ] operations = [ @@ -117,8 +117,8 @@ class Migration(migrations.Migration): ('batch', models.IntegerField(default=2016)), ('cpi', models.FloatField(default=0)), ('category', models.CharField(choices=[('GEN', 'General'), ('SC', 'Scheduled Castes'), ('ST', 'Scheduled Tribes'), ('OBC', 'Other Backward Classes')], max_length=10)), - ('father_name', models.CharField(default='', max_length=40)), - ('mother_name', models.CharField(default='', max_length=40)), + ('father_name', models.CharField(default='', max_length=40, null=True)), + ('mother_name', models.CharField(default='', max_length=40, null=True)), ('hall_no', models.IntegerField(default=0)), ('room_no', models.CharField(blank=True, max_length=10, null=True)), ('specialization', models.CharField(choices=[('Power and Control', 'Power and Control'), ('Microwave and Communication Engineering', 'Microwave and Communication Engineering'), ('Micro-nano Electronics', 'Micro-nano Electronics'), ('CAD/CAM', 'CAD/CAM'), ('Design', 'Design'), ('Manufacturing', 'Manufacturing'), ('CSE', 'CSE'), ('Mechatronics', 'Mechatronics'), ('MDes', 'MDes'), ('None', 'None')], default='', max_length=40, null=True)), diff --git a/FusionIIIT/applications/academic_procedures/migrations/0001_initial.py b/FusionIIIT/applications/academic_procedures/migrations/0001_initial.py index b873390df..42142593d 100644 --- a/FusionIIIT/applications/academic_procedures/migrations/0001_initial.py +++ b/FusionIIIT/applications/academic_procedures/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.db import migrations, models @@ -11,9 +11,9 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('globals', '0001_initial'), ('academic_information', '0001_initial'), ('programme_curriculum', '0001_initial'), - ('globals', '0001_initial'), ] operations = [ @@ -188,7 +188,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('month', models.CharField(choices=[('Jan', 'January'), ('Feb', 'Febuary'), ('Mar', 'March'), ('Apr', 'April'), ('May', 'May'), ('Jun', 'June'), ('Jul', 'July'), ('Aug', 'August'), ('Sep', 'September'), ('Oct', 'October'), ('Nov', 'November'), ('Dec', 'December')], max_length=10)), - ('year', models.IntegerField(choices=[(2023, 2023), (2022, 2022)])), + ('year', models.IntegerField(choices=[(2024, 2024), (2023, 2023)])), ('description', models.CharField(choices=[('Stu_paid', 'Paid'), ('Stu_due', 'Due')], max_length=15)), ('amount', models.IntegerField()), ('remaining_amount', models.IntegerField()), @@ -243,7 +243,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('semester', models.IntegerField()), - ('batch', models.IntegerField(default=2023)), + ('batch', models.IntegerField(default=2024)), ('verified', models.BooleanField(default=False)), ('curr_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.curriculum')), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), @@ -334,7 +334,7 @@ class Migration(migrations.Migration): name='course_registration', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('working_year', models.IntegerField(blank=True, choices=[(2023, 2023), (2022, 2022)], null=True)), + ('working_year', models.IntegerField(blank=True, choices=[(2024, 2024), (2023, 2023)], null=True)), ('course_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='programme_curriculum.course')), ('course_slot_id', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='programme_curriculum.courseslot')), ('semester_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='programme_curriculum.semester')), @@ -374,7 +374,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('date', models.DateTimeField(auto_now_add=True)), ('month', models.CharField(choices=[('Jan', 'January'), ('Feb', 'Febuary'), ('Mar', 'March'), ('Apr', 'April'), ('May', 'May'), ('Jun', 'June'), ('Jul', 'July'), ('Aug', 'August'), ('Sep', 'September'), ('Oct', 'October'), ('Nov', 'November'), ('Dec', 'December')], max_length=10)), - ('year', models.IntegerField(choices=[(2023, 2023), (2022, 2022)])), + ('year', models.IntegerField(choices=[(2024, 2024), (2023, 2023)])), ('bank_account', models.CharField(max_length=11)), ('applicability', models.CharField(choices=[('GATE', 'GATE'), ('NET', 'NET'), ('CEED', 'CEED')], max_length=5)), ('ta_supervisor_remark', models.BooleanField(default=False)), @@ -392,7 +392,7 @@ class Migration(migrations.Migration): name='Register', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('year', models.IntegerField(default=2023)), + ('year', models.IntegerField(default=2024)), ('semester', models.IntegerField()), ('curr_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.curriculum')), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), @@ -402,4 +402,4 @@ class Migration(migrations.Migration): 'unique_together': {('curr_id', 'student_id')}, }, ), - ] + ] \ No newline at end of file diff --git a/FusionIIIT/applications/central_mess/migrations/0001_initial.py b/FusionIIIT/applications/central_mess/migrations/0001_initial.py index 2a5bce41c..c197e0231 100644 --- a/FusionIIIT/applications/central_mess/migrations/0001_initial.py +++ b/FusionIIIT/applications/central_mess/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import applications.central_mess.models import datetime @@ -19,7 +19,7 @@ class Migration(migrations.Migration): name='Menu', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('mess_option', models.CharField(choices=[('mess1', 'Veg_mess'), ('mess2', 'Non_veg_mess')], default='mess2', max_length=20)), + ('mess_option', models.CharField(choices=[('mess1', 'Mess1'), ('mess2', 'Mess2')], default='mess2', max_length=20)), ('meal_time', models.CharField(choices=[('MB', 'Monday Breakfast'), ('ML', 'Monday Lunch'), ('MD', 'Monday Dinner'), ('TB', 'Tuesday Breakfast'), ('TL', 'Tuesday Lunch'), ('TD', 'Tuesday Dinner'), ('WB', 'Wednesday Breakfast'), ('WL', 'Wednesday Lunch'), ('WD', 'Wednesday Dinner'), ('THB', 'Thursday Breakfast'), ('THL', 'Thursday Lunch'), ('THD', 'Thursday Dinner'), ('FB', 'Friday Breakfast'), ('FL', 'Friday Lunch'), ('FD', 'Friday Dinner'), ('SB', 'Saturday Breakfast'), ('SL', 'Saturday Lunch'), ('SD', 'Saturday Dinner'), ('SUB', 'Sunday Breakfast'), ('SUL', 'Sunday Lunch'), ('SUD', 'Sunday Dinner')], max_length=20)), ('dish', models.CharField(max_length=200)), ], @@ -51,15 +51,6 @@ class Migration(migrations.Migration): ('timestamp', models.DateTimeField(auto_now_add=True)), ], ), - migrations.CreateModel( - name='Nonveg_menu', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('dish', models.CharField(max_length=20)), - ('price', models.IntegerField()), - ('order_interval', models.CharField(choices=[('Breakfast', 'Breakfast'), ('Lunch', 'Lunch'), ('Dinner', 'Dinner')], default='Breakfast', max_length=20)), - ], - ), migrations.CreateModel( name='Vacation_food', fields=[ @@ -80,33 +71,68 @@ class Migration(migrations.Migration): ('end_date', models.DateField(default=datetime.date.today)), ('request', models.TextField()), ('status', models.CharField(choices=[('0', 'rejected'), ('1', 'pending'), ('2', 'accepted')], default='1', max_length=20)), - ('item1', models.CharField(max_length=50)), - ('item2', models.CharField(max_length=50)), + ('item1', models.CharField(choices=[('dal_chawal', 'Dal Chawal'), ('khicdi', 'Khicdi'), ('tomato_soup', 'Tomato Soup')], default='dal_chawal', max_length=50)), + ('item2', models.CharField(choices=[('breakfast', 'Breakfast'), ('lunch', 'Lunch'), ('dinner', 'Dinner')], default='breakfast', max_length=50)), ('app_date', models.DateField(default=datetime.date.today)), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], ), migrations.CreateModel( - name='Rebate', + name='Semdates', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('start_date', models.DateField(default=datetime.date.today)), ('end_date', models.DateField(default=datetime.date.today)), - ('purpose', models.TextField()), - ('status', models.CharField(choices=[('0', 'rejected'), ('1', 'pending'), ('2', 'accepted')], default='1', max_length=20)), - ('app_date', models.DateField(default=datetime.date.today)), - ('leave_type', models.CharField(choices=[('casual', 'Casual'), ('vacation', 'Vacation')], default='casual', max_length=20)), + ], + options={ + 'unique_together': {('start_date', 'end_date')}, + }, + ), + migrations.CreateModel( + name='Registration_Request', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('Txn_no', models.CharField(max_length=20)), + ('img', models.ImageField(default=None, upload_to='images/')), + ('amount', models.IntegerField(default=0)), + ('status', models.CharField(default='pending', max_length=10)), + ('registration_remark', models.CharField(default='NA', max_length=50)), + ('start_date', models.DateField(default=None, null=True)), + ('payment_date', models.DateField(default=None, null=True)), + ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), + ], + ), + migrations.CreateModel( + name='Reg_records', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('start_date', models.DateField(default=datetime.date.today)), + ('end_date', models.DateField(default=None, null=True)), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], ), migrations.CreateModel( - name='Nonveg_data', + name='Reg_main', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('order_date', models.DateField(default=datetime.date.today)), - ('order_interval', models.CharField(choices=[('Breakfast', 'Breakfast'), ('Lunch', 'Lunch'), ('Dinner', 'Dinner')], default='Breakfast', max_length=20)), + ('program', models.CharField(max_length=10)), + ('current_mess_status', models.CharField(default='Deregistered', max_length=20)), + ('balance', models.IntegerField(default=0)), + ('mess_option', models.CharField(default='mess2', max_length=20)), + ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), + ], + ), + migrations.CreateModel( + name='Rebate', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('start_date', models.DateField(default=datetime.date.today)), + ('end_date', models.DateField(default=datetime.date.today)), + ('purpose', models.TextField()), + ('status', models.CharField(choices=[('0', 'rejected'), ('1', 'pending'), ('2', 'accepted')], default='1', max_length=20)), ('app_date', models.DateField(default=datetime.date.today)), - ('dish', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='central_mess.nonveg_menu')), + ('leave_type', models.CharField(choices=[('casual', 'Casual'), ('vacation', 'Vacation')], default='casual', max_length=20)), + ('rebate_remark', models.CharField(default='NA', max_length=50)), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], ), @@ -134,11 +160,22 @@ class Migration(migrations.Migration): name='Feedback', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('mess', models.CharField(choices=[('mess1', 'Veg_mess'), ('mess2', 'Non_veg_mess')], default='mess1', max_length=10)), + ('mess', models.CharField(choices=[('mess1', 'Mess1'), ('mess2', 'Mess2')], default='mess1', max_length=10)), ('mess_rating', models.PositiveSmallIntegerField(default='5')), ('fdate', models.DateField(default=datetime.date.today)), ('description', models.TextField()), ('feedback_type', models.CharField(choices=[('maintenance', 'Maintenance'), ('food', 'Food'), ('cleanliness', 'Cleanliness & Hygiene'), ('others', 'Others')], max_length=20)), + ('feedback_remark', models.CharField(default='NA', max_length=50)), + ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), + ], + ), + migrations.CreateModel( + name='Deregistration_Request', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.CharField(default='pending', max_length=10)), + ('deregistration_remark', models.CharField(default='NA', max_length=50)), + ('end_date', models.DateField(default=None, null=True)), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], ), @@ -146,13 +183,14 @@ class Migration(migrations.Migration): name='Payments', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('sem', models.IntegerField()), - ('year', models.IntegerField(default=applications.central_mess.models.current_year)), ('amount_paid', models.IntegerField(default=0)), + ('payment_month', models.CharField(default=applications.central_mess.models.current_month, max_length=20)), + ('payment_year', models.IntegerField(default=applications.central_mess.models.current_year)), + ('payment_date', models.DateField(default=datetime.date(2024, 4, 15))), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], options={ - 'unique_together': {('student_id', 'sem', 'year')}, + 'unique_together': {('student_id', 'payment_date')}, }, ), migrations.CreateModel( @@ -164,8 +202,8 @@ class Migration(migrations.Migration): ('amount', models.IntegerField(default=0)), ('rebate_count', models.IntegerField(default=0)), ('rebate_amount', models.IntegerField(default=0)), - ('nonveg_total_bill', models.IntegerField(default=0)), ('total_bill', models.IntegerField(default=0)), + ('paid', models.BooleanField(default=False)), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], options={ @@ -176,7 +214,7 @@ class Migration(migrations.Migration): name='Messinfo', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('mess_option', models.CharField(choices=[('mess1', 'Veg_mess'), ('mess2', 'Non_veg_mess')], default='mess2', max_length=20)), + ('mess_option', models.CharField(choices=[('mess1', 'Mess1'), ('mess2', 'Mess2')], default='mess2', max_length=20)), ('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], options={ diff --git a/FusionIIIT/applications/complaint_system/migrations/0001_initial.py b/FusionIIIT/applications/complaint_system/migrations/0001_initial.py index db74dd14d..44df90d3c 100644 --- a/FusionIIIT/applications/complaint_system/migrations/0001_initial.py +++ b/FusionIIIT/applications/complaint_system/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.db import migrations, models import django.db.models.deletion @@ -15,12 +15,10 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Caretaker', + name='SectionIncharge', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('area', models.CharField(choices=[('hall-1', 'hall-1'), ('hall-3', 'hall-3'), ('hall-4', 'hall-4'), ('CC1', 'CC1'), ('CC2', 'CC2'), ('core_lab', 'core_lab'), ('LHTC', 'LHTC'), ('NR2', 'NR2'), ('Rewa_Residency', 'Rewa_Residency'), ('Maa Saraswati Hostel', 'Maa Saraswati Hostel'), ('Nagarjun Hostel', 'Nagarjun Hostel'), ('Panini Hostel', 'Panini Hostel')], default='hall-3', max_length=20)), - ('rating', models.IntegerField(default=0)), - ('myfeedback', models.CharField(default='this is my feedback', max_length=400)), + ('work_type', models.CharField(choices=[('Electricity', 'Electricity'), ('carpenter', 'carpenter'), ('plumber', 'plumber'), ('garbage', 'garbage'), ('dustbin', 'dustbin'), ('internet', 'internet'), ('other', 'other')], default='Electricity', max_length=20)), ('staff_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), ], ), @@ -32,14 +30,14 @@ class Migration(migrations.Migration): ('age', models.CharField(max_length=10)), ('phone', models.BigIntegerField(blank=True)), ('worker_type', models.CharField(choices=[('Electricity', 'Electricity'), ('carpenter', 'carpenter'), ('plumber', 'plumber'), ('garbage', 'garbage'), ('dustbin', 'dustbin'), ('internet', 'internet'), ('other', 'other')], default='internet', max_length=20)), - ('caretaker_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='complaint_system.caretaker')), + ('secincharge_id', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='complaint_system.sectionincharge')), ], ), migrations.CreateModel( name='Supervisor', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('area', models.CharField(choices=[('hall-1', 'hall-1'), ('hall-3', 'hall-3'), ('hall-4', 'hall-4'), ('CC1', 'CC1'), ('CC2', 'CC2'), ('core_lab', 'core_lab'), ('LHTC', 'LHTC'), ('NR2', 'NR2'), ('Rewa_Residency', 'Rewa_Residency'), ('Maa Saraswati Hostel', 'Maa Saraswati Hostel'), ('Nagarjun Hostel', 'Nagarjun Hostel'), ('Panini Hostel', 'Panini Hostel')], max_length=20)), + ('type', models.CharField(choices=[('Electricity', 'Electricity'), ('carpenter', 'carpenter'), ('plumber', 'plumber'), ('garbage', 'garbage'), ('dustbin', 'dustbin'), ('internet', 'internet'), ('other', 'other')], default='Electricity', max_length=30)), ('sup_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), ], ), @@ -50,7 +48,7 @@ class Migration(migrations.Migration): ('complaint_date', models.DateTimeField(default=django.utils.timezone.now)), ('complaint_finish', models.DateField(blank=True, null=True)), ('complaint_type', models.CharField(choices=[('Electricity', 'Electricity'), ('carpenter', 'carpenter'), ('plumber', 'plumber'), ('garbage', 'garbage'), ('dustbin', 'dustbin'), ('internet', 'internet'), ('other', 'other')], default='internet', max_length=20)), - ('location', models.CharField(choices=[('hall-1', 'hall-1'), ('hall-3', 'hall-3'), ('hall-4', 'hall-4'), ('CC1', 'CC1'), ('CC2', 'CC2'), ('core_lab', 'core_lab'), ('LHTC', 'LHTC'), ('NR2', 'NR2'), ('Rewa_Residency', 'Rewa_Residency'), ('Maa Saraswati Hostel', 'Maa Saraswati Hostel'), ('Nagarjun Hostel', 'Nagarjun Hostel'), ('Panini Hostel', 'Panini Hostel')], max_length=20)), + ('location', models.CharField(choices=[('hall-1', 'hall-1'), ('hall-3', 'hall-3'), ('hall-4', 'hall-4'), ('library', 'CC1'), ('computer center', 'CC2'), ('core_lab', 'core_lab'), ('LHTC', 'LHTC'), ('NR2', 'NR2'), ('NR3', 'NR3'), ('Admin building', 'Admin building'), ('Rewa_Residency', 'Rewa_Residency'), ('Maa Saraswati Hostel', 'Maa Saraswati Hostel'), ('Nagarjun Hostel', 'Nagarjun Hostel'), ('Panini Hostel', 'Panini Hostel')], max_length=20)), ('specific_location', models.CharField(blank=True, max_length=50)), ('details', models.CharField(max_length=100)), ('status', models.IntegerField(default='0')), @@ -64,4 +62,14 @@ class Migration(migrations.Migration): ('worker_id', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='complaint_system.workers')), ], ), + migrations.CreateModel( + name='Caretaker', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('area', models.CharField(choices=[('hall-1', 'hall-1'), ('hall-3', 'hall-3'), ('hall-4', 'hall-4'), ('library', 'CC1'), ('computer center', 'CC2'), ('core_lab', 'core_lab'), ('LHTC', 'LHTC'), ('NR2', 'NR2'), ('NR3', 'NR3'), ('Admin building', 'Admin building'), ('Rewa_Residency', 'Rewa_Residency'), ('Maa Saraswati Hostel', 'Maa Saraswati Hostel'), ('Nagarjun Hostel', 'Nagarjun Hostel'), ('Panini Hostel', 'Panini Hostel')], default='hall-3', max_length=20)), + ('rating', models.IntegerField(default=0)), + ('myfeedback', models.CharField(default='this is my feedback', max_length=400)), + ('staff_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), + ], + ), ] diff --git a/FusionIIIT/applications/counselling_cell/migrations/0001_initial.py b/FusionIIIT/applications/counselling_cell/migrations/0001_initial.py index b87618488..f0214910c 100644 --- a/FusionIIIT/applications/counselling_cell/migrations/0001_initial.py +++ b/FusionIIIT/applications/counselling_cell/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.db import migrations, models @@ -10,8 +10,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('academic_information', '0001_initial'), ('globals', '0001_initial'), + ('academic_information', '0001_initial'), ] operations = [ diff --git a/FusionIIIT/applications/department/migrations/0001_initial.py b/FusionIIIT/applications/department/migrations/0001_initial.py index fc8a34834..cb016ad8b 100644 --- a/FusionIIIT/applications/department/migrations/0001_initial.py +++ b/FusionIIIT/applications/department/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.db import migrations, models diff --git a/FusionIIIT/applications/department/models.py b/FusionIIIT/applications/department/models.py index a78b35171..8f7dba039 100644 --- a/FusionIIIT/applications/department/models.py +++ b/FusionIIIT/applications/department/models.py @@ -4,7 +4,7 @@ # Create your models here. from applications.globals.models import ExtraInfo - + class SpecialRequest(models.Model): request_maker = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE) request_date = models.DateTimeField(default=date.today) diff --git a/FusionIIIT/applications/department/views.py b/FusionIIIT/applications/department/views.py index ef7e71c64..f138c77db 100644 --- a/FusionIIIT/applications/department/views.py +++ b/FusionIIIT/applications/department/views.py @@ -178,7 +178,7 @@ def faculty_view(request): upload_announcement=upload_announcement, department = department, ann_date=ann_date) - # department_notif(usrnm, recipients , message) + department_notif(usrnm, recipients , message) context = browse_announcements() return render(request, 'department/dep_request.html', {"user_designation":user_info.user_type, @@ -223,7 +223,7 @@ def staff_view(request): upload_announcement=upload_announcement, department = department, ann_date=ann_date) - # department_notif(usrnm, recipients , message) + department_notif(usrnm, recipients , message) context = browse_announcements() return render(request, 'department/dep_request.html', {"user_designation":user_info.user_type, diff --git a/FusionIIIT/applications/eis/migrations/0001_initial.py b/FusionIIIT/applications/eis/migrations/0001_initial.py index 2fd2e65d3..f3dbd4bf3 100644 --- a/FusionIIIT/applications/eis/migrations/0001_initial.py +++ b/FusionIIIT/applications/eis/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.conf import settings @@ -49,7 +49,7 @@ class Migration(migrations.Migration): name='emp_techtransfer', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('details', models.CharField(default=' ', max_length=500)), ('date_entry', models.DateField(blank=True, default=datetime.datetime.now, null=True)), ('start_date', models.DateField(blank=True, null=True)), @@ -61,7 +61,7 @@ class Migration(migrations.Migration): name='emp_session_chair', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('name', models.CharField(default=' ', max_length=500)), ('event', models.TextField(default=' ', max_length=2500)), ('s_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017)], null=True, verbose_name='year')), @@ -77,7 +77,7 @@ class Migration(migrations.Migration): name='emp_research_projects', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('ptype', models.CharField(default='Research', max_length=100)), ('pi', models.CharField(default=' ', max_length=1000)), ('co_pi', models.CharField(default=' ', max_length=1500)), @@ -96,7 +96,7 @@ class Migration(migrations.Migration): name='emp_research_papers', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('rtype', models.CharField(choices=[('Journal', 'Journal'), ('Conference', 'Conference')], default='Conference', max_length=500)), ('authors', models.CharField(blank=True, max_length=2500, null=True)), ('co_authors', models.CharField(blank=True, max_length=2500, null=True)), @@ -113,7 +113,7 @@ class Migration(migrations.Migration): ('end_date', models.DateField(blank=True, null=True)), ('date_acceptance', models.DateField(blank=True, null=True)), ('date_publication', models.DateField(blank=True, null=True)), - ('year', models.CharField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], max_length=10, null=True)), + ('year', models.CharField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], max_length=10, null=True)), ('a_month', models.CharField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12)], default=1, max_length=500, null=True)), ('doc_id', models.CharField(blank=True, max_length=50, null=True)), ('doc_description', models.CharField(blank=True, max_length=1000, null=True)), @@ -128,11 +128,11 @@ class Migration(migrations.Migration): name='emp_published_books', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('p_type', models.CharField(choices=[('Book', 'Book'), ('Monograph', 'Monograph'), ('Book Chapter', 'Book Chapter'), ('Handbook', 'Handbook'), ('Technical Report', 'Technical Report')], max_length=16)), ('title', models.CharField(default=' ', max_length=2500)), ('publisher', models.CharField(default=' ', max_length=2500)), - ('pyear', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], null=True, verbose_name='year')), + ('pyear', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year')), ('authors', models.CharField(default=' ', max_length=250)), ('date_entry', models.DateField(blank=True, default=datetime.datetime.now, null=True)), ('publication_date', models.DateField(blank=True, null=True)), @@ -143,12 +143,12 @@ class Migration(migrations.Migration): name='emp_patents', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('p_no', models.CharField(max_length=150)), ('title', models.CharField(max_length=1500)), ('earnings', models.IntegerField(default=0)), ('status', models.CharField(choices=[('Filed', 'Filed'), ('Granted', 'Granted'), ('Published', 'Published'), ('Owned', 'Owned')], max_length=15)), - ('p_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], null=True, verbose_name='year')), + ('p_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year')), ('a_month', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12)], default=1, null=True, verbose_name='Month')), ('date_entry', models.DateField(blank=True, default=datetime.datetime.now, null=True)), ('start_date', models.DateField(blank=True, null=True)), @@ -160,14 +160,14 @@ class Migration(migrations.Migration): name='emp_mtechphd_thesis', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('degree_type', models.IntegerField(default=1)), ('title', models.CharField(max_length=250)), ('supervisors', models.CharField(max_length=250)), ('co_supervisors', models.CharField(blank=True, max_length=250, null=True)), ('rollno', models.CharField(max_length=200)), ('s_name', models.CharField(max_length=5000)), - ('s_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], null=True, verbose_name='year')), + ('s_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year')), ('a_month', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12)], default=1, null=True, verbose_name='Month')), ('date_entry', models.DateField(blank=True, default=datetime.datetime.now, null=True)), ('start_date', models.DateField(blank=True, null=True)), @@ -181,14 +181,14 @@ class Migration(migrations.Migration): name='emp_keynote_address', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('type', models.CharField(choices=[('Keynote', 'Keynote'), ('Plenary Address', 'Plenary Address')], default='Keynote', max_length=140)), ('title', models.CharField(max_length=1000)), ('name', models.CharField(max_length=1000)), ('venue', models.CharField(max_length=1000)), ('page_no', models.CharField(max_length=100)), ('isbn_no', models.CharField(max_length=200)), - ('k_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], null=True, verbose_name='year')), + ('k_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year')), ('a_month', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12)], default=1, null=True, verbose_name='Month')), ('start_date', models.DateField(blank=True, null=True)), ('end_date', models.DateField(blank=True, null=True)), @@ -200,12 +200,12 @@ class Migration(migrations.Migration): name='emp_expert_lectures', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('l_type', models.CharField(choices=[('Expert Lecture', 'Expert Lecture'), ('Invited Talk', 'Invited Talk')], default='Expert Lecture', max_length=14)), ('title', models.CharField(max_length=1000)), ('place', models.CharField(max_length=1000)), ('l_date', models.DateField(blank=True, null=True)), - ('l_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], null=True, verbose_name='year')), + ('l_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year')), ('a_month', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12)], default=1, null=True, verbose_name='Month')), ('date_entry', models.DateField(blank=True, default=datetime.datetime.now, null=True)), ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), @@ -215,7 +215,7 @@ class Migration(migrations.Migration): name='emp_event_organized', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('type', models.CharField(choices=[('Training Program', 'Training Program'), ('Seminar', 'Seminar'), ('Short Term Program', 'Short Term Program'), ('Workshop', 'Workshop'), ('Any Other', 'Any Other')], max_length=180)), ('name', models.CharField(max_length=1000)), ('sponsoring_agency', models.CharField(max_length=150)), @@ -231,7 +231,7 @@ class Migration(migrations.Migration): name='emp_consultancy_projects', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('consultants', models.CharField(max_length=150)), ('title', models.CharField(max_length=1000)), ('client', models.CharField(max_length=1000)), @@ -249,10 +249,10 @@ class Migration(migrations.Migration): name='emp_confrence_organised', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('name', models.CharField(max_length=500)), ('venue', models.CharField(max_length=500)), - ('k_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], null=True, verbose_name='year')), + ('k_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year')), ('a_month', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12)], default=1, null=True, verbose_name='Month')), ('start_date', models.DateField(blank=True, null=True)), ('end_date', models.DateField(blank=True, null=True)), @@ -266,12 +266,12 @@ class Migration(migrations.Migration): name='emp_achievement', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('pf_no', models.IntegerField()), + ('pf_no', models.CharField(max_length=20)), ('a_type', models.CharField(choices=[('Award', 'Award'), ('Honour', 'Honour'), ('Prize', 'Prize'), ('Other', 'Other')], default='Other', max_length=180)), ('details', models.TextField(default=' ', max_length=1550)), ('a_day', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12), (13, 13), (14, 14), (15, 15), (16, 16), (17, 17), (18, 18), (19, 19), (20, 20), (21, 21), (22, 22), (23, 23), (24, 24), (25, 25), (26, 26), (27, 27), (28, 28), (29, 29), (30, 30), (31, 31)], null=True, verbose_name='Day')), ('a_month', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12)], null=True, verbose_name='Month')), - ('a_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023)], null=True, verbose_name='year')), + ('a_year', models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year')), ('date_entry', models.DateField(default=datetime.datetime.now)), ('achievment_date', models.DateField(blank=True, null=True)), ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), diff --git a/FusionIIIT/applications/establishment/migrations/0001_initial.py b/FusionIIIT/applications/establishment/migrations/0001_initial.py index e1449d3b3..d85fe198d 100644 --- a/FusionIIIT/applications/establishment/migrations/0001_initial.py +++ b/FusionIIIT/applications/establishment/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models diff --git a/FusionIIIT/applications/estate_module/migrations/0001_initial.py b/FusionIIIT/applications/estate_module/migrations/0001_initial.py index 478a93b83..899dbfccc 100644 --- a/FusionIIIT/applications/estate_module/migrations/0001_initial.py +++ b/FusionIIIT/applications/estate_module/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models diff --git a/FusionIIIT/applications/feeds/migrations/0001_initial.py b/FusionIIIT/applications/feeds/migrations/0001_initial.py index 30ae94c92..e989d0101 100644 --- a/FusionIIIT/applications/feeds/migrations/0001_initial.py +++ b/FusionIIIT/applications/feeds/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models diff --git a/FusionIIIT/applications/filetracking/migrations/0001_initial.py b/FusionIIIT/applications/filetracking/migrations/0001_initial.py index 6924ae1ff..3375630f7 100644 --- a/FusionIIIT/applications/filetracking/migrations/0001_initial.py +++ b/FusionIIIT/applications/filetracking/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models @@ -24,6 +24,9 @@ class Migration(migrations.Migration): ('upload_date', models.DateTimeField(auto_now_add=True)), ('upload_file', models.FileField(blank=True, upload_to='')), ('is_read', models.BooleanField(default=False)), + ('src_module', models.CharField(default='filetracking', max_length=100)), + ('src_object_id', models.CharField(max_length=100, null=True)), + ('file_extra_JSON', models.JSONField(null=True)), ('designation', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='upload_designation', to='globals.designation')), ('uploader', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='uploaded_files', to='globals.extrainfo')), ], @@ -40,6 +43,7 @@ class Migration(migrations.Migration): ('remarks', models.CharField(blank=True, max_length=250, null=True)), ('upload_file', models.FileField(blank=True, upload_to='')), ('is_read', models.BooleanField(default=False)), + ('tracking_extra_JSON', models.JSONField(null=True)), ('current_design', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='globals.holdsdesignation')), ('current_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), ('file_id', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='filetracking.file')), diff --git a/FusionIIIT/applications/filetracking/models.py b/FusionIIIT/applications/filetracking/models.py index 9d78b24c9..87f91ced8 100644 --- a/FusionIIIT/applications/filetracking/models.py +++ b/FusionIIIT/applications/filetracking/models.py @@ -24,8 +24,8 @@ class File(models.Model): class Meta: db_table = 'File' - #def __str__(self): - #return str(self.ref_id) + # def __str__(self): + # return str(self.ref_id) class Tracking(models.Model): @@ -48,4 +48,4 @@ class Tracking(models.Model): tracking_extra_JSON = models.JSONField(null=True) class Meta: - db_table = 'Tracking' + db_table = 'Tracking' \ No newline at end of file diff --git a/FusionIIIT/applications/finance_accounts/migrations/0001_initial.py b/FusionIIIT/applications/finance_accounts/migrations/0001_initial.py index 4dfa8fed7..8d45f1fc1 100644 --- a/FusionIIIT/applications/finance_accounts/migrations/0001_initial.py +++ b/FusionIIIT/applications/finance_accounts/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.db import migrations, models diff --git a/FusionIIIT/applications/globals/api/urls.py b/FusionIIIT/applications/globals/api/urls.py index 0199f7688..9f4e6c2b5 100644 --- a/FusionIIIT/applications/globals/api/urls.py +++ b/FusionIIIT/applications/globals/api/urls.py @@ -18,4 +18,4 @@ url(r'^notification/read',views.NotificationRead,name='notifications-read') -] \ No newline at end of file +] diff --git a/FusionIIIT/applications/globals/api/views.py b/FusionIIIT/applications/globals/api/views.py index d6fc75321..c6723d0ab 100644 --- a/FusionIIIT/applications/globals/api/views.py +++ b/FusionIIIT/applications/globals/api/views.py @@ -40,8 +40,9 @@ def login(request): designation=[] - - designation.append(str(user.extrainfo.user_type)) + if str(user.extrainfo.user_type) == "student": + designation.append(str(user.extrainfo.user_type)) + for i in design: if str(i.designation) != str(user.extrainfo.user_type): print('-------') @@ -143,6 +144,12 @@ def profile(request, username=None): return Response(data=resp, status=status.HTTP_200_OK) elif profile['user_type'] == 'faculty': return redirect('/eis/api/profile/' + (username+'/' if username else '')) + elif profile['user_type'] == 'staff': + resp = { + 'user' : user_detail, + 'profile' : profile, + } + return Response(data=resp, status=status.HTTP_200_OK) @api_view(['PUT']) def profile_update(request): diff --git a/FusionIIIT/applications/globals/migrations/0001_initial.py b/FusionIIIT/applications/globals/migrations/0001_initial.py index 1fc3a8925..7fc43ccef 100644 --- a/FusionIIIT/applications/globals/migrations/0001_initial.py +++ b/FusionIIIT/applications/globals/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import applications.globals.models import datetime @@ -39,7 +39,7 @@ class Migration(migrations.Migration): ('title', models.CharField(choices=[('Mr.', 'Mr.'), ('Mrs.', 'Mrs.'), ('Ms.', 'Ms.'), ('Dr.', 'Dr.'), ('Professor', 'Prof.'), ('Shreemati', 'Shreemati'), ('Shree', 'Shree')], default='Dr.', max_length=20)), ('sex', models.CharField(choices=[('M', 'Male'), ('F', 'Female'), ('O', 'Other')], default='M', max_length=2)), ('date_of_birth', models.DateField(default=datetime.date(1970, 1, 1))), - ('user_status', models.CharField(choices=[('PRESENT', 'PRESENT'), ('NEW', 'NEW')], default='PRESENT', max_length=50)), + ('user_status', models.CharField(choices=[('NEW', 'NEW'), ('PRESENT', 'PRESENT')], default='PRESENT', max_length=50)), ('address', models.TextField(default='', max_length=1000)), ('phone_no', models.BigIntegerField(default=9999999999, null=True)), ('user_type', models.CharField(choices=[('student', 'student'), ('staff', 'staff'), ('compounder', 'compounder'), ('faculty', 'faculty')], max_length=20)), @@ -106,7 +106,7 @@ class Migration(migrations.Migration): ('working', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_designation', to=settings.AUTH_USER_MODEL)), ], options={ - 'unique_together': {('user', 'designation'), ('working', 'designation')}, + 'unique_together': {('working', 'designation'), ('user', 'designation')}, }, ), ] diff --git a/FusionIIIT/applications/globals/models.py b/FusionIIIT/applications/globals/models.py index 31eedcfb4..d51fbcb69 100644 --- a/FusionIIIT/applications/globals/models.py +++ b/FusionIIIT/applications/globals/models.py @@ -64,8 +64,6 @@ class Constants: DESIGNATIONS = ( ('academic', 'Academic Designation'), ('administrative', 'Administrative Designation'), - - ) USER_STATUS = { ("NEW", "NEW"), diff --git a/FusionIIIT/applications/globals/views.py b/FusionIIIT/applications/globals/views.py index 96caff806..39c6913c1 100644 --- a/FusionIIIT/applications/globals/views.py +++ b/FusionIIIT/applications/globals/views.py @@ -773,9 +773,8 @@ def profile(request, username=None): displays the profile of currently logged-in user """ - print(username) - user = get_object_or_404(User, Q(username=username)) if username else request.user + user = get_object_or_404(User, Q(username=username)) if username else request.user editable = request.user == user print("editable",editable) profile = get_object_or_404(ExtraInfo, Q(user=user)) @@ -1047,7 +1046,8 @@ def profile(request, username=None): return render(request, "globals/student_profile4.html", context) if 'achievementsubmit' in request.POST or 'deleteach' in request.POST: return render(request, "globals/student_profile5.html", context) - # print("context",context) + print("context",context) + return render(request, "globals/student_profile.html", context) else: return redirect("/") diff --git a/FusionIIIT/applications/gymkhana/migrations/0001_initial.py b/FusionIIIT/applications/gymkhana/migrations/0001_initial.py index e140005a1..546d7fb81 100644 --- a/FusionIIIT/applications/gymkhana/migrations/0001_initial.py +++ b/FusionIIIT/applications/gymkhana/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models @@ -11,9 +11,9 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('academic_information', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('globals', '0001_initial'), + ('academic_information', '0001_initial'), ] operations = [ diff --git a/FusionIIIT/applications/health_center/api/serializers.py b/FusionIIIT/applications/health_center/api/serializers.py index 13aa9f049..06fe901c1 100644 --- a/FusionIIIT/applications/health_center/api/serializers.py +++ b/FusionIIIT/applications/health_center/api/serializers.py @@ -54,6 +54,7 @@ class Meta: + class AnnouncementSerializer(serializers.ModelSerializer): class Meta: @@ -98,4 +99,10 @@ class HospitalAdmitSerializer(serializers.ModelSerializer): class Meta: model=Hospital_admit + fields=('__all__') + +class MedicalReliefSerializer(serializers.ModelSerializer): + + class Meta: + model=medical_relief fields=('__all__') \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/api/urls.py b/FusionIIIT/applications/health_center/api/urls.py index 661279c87..49fee2d6e 100644 --- a/FusionIIIT/applications/health_center/api/urls.py +++ b/FusionIIIT/applications/health_center/api/urls.py @@ -7,6 +7,5 @@ url(r'^compounder/$', views.compounder_view_api, name='compounder_view_api'), url(r'^compounder/request$', views.compounder_request_api , name='compounder_request_api'), url(r'^student/$', views.student_view_api, name='student_view'), - url(r'^student/request$', views.student_request_api, name='student_request_api') - -] + url(r'^student/request$', views.student_request_api, name='student_request_api') +] \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/migrations/0001_initial.py b/FusionIIIT/applications/health_center/migrations/0001_initial.py index ee068099e..072d80def 100644 --- a/FusionIIIT/applications/health_center/migrations/0001_initial.py +++ b/FusionIIIT/applications/health_center/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 +import datetime from django.db import migrations, models import django.db.models.deletion @@ -13,14 +14,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.CreateModel( - name='Appointment', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('description', models.CharField(max_length=50)), - ('date', models.DateField()), - ], - ), migrations.CreateModel( name='Counter', fields=[ @@ -28,14 +21,15 @@ class Migration(migrations.Migration): ('count', models.IntegerField(default=0)), ('fine', models.IntegerField(default=0)), ('doc_count', models.IntegerField(default=0)), + ('patho_count', models.IntegerField(default=0)), ], ), migrations.CreateModel( name='Doctor', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('doctor_name', models.IntegerField(choices=[(0, 'Dr.Sharma'), (1, 'Dr.Vinay')])), - ('doctor_phone', models.CharField(max_length=10)), + ('doctor_name', models.CharField(choices=[(0, 'Dr.Sharma'), (1, 'Dr.Vinay')], max_length=50)), + ('doctor_phone', models.CharField(max_length=15)), ('specialization', models.CharField(max_length=100)), ('active', models.BooleanField(default=True)), ], @@ -48,6 +42,27 @@ class Migration(migrations.Migration): ('phone', models.CharField(max_length=10)), ], ), + migrations.CreateModel( + name='medical_relief', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.CharField(max_length=200)), + ('file', models.FileField(upload_to='medical_files/')), + ('file_id', models.IntegerField(default=0)), + ('compounder_forward_flag', models.BooleanField(default=False)), + ('acc_admin_forward_flag', models.BooleanField(default=False)), + ], + ), + migrations.CreateModel( + name='Pathologist', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('pathologist_name', models.CharField(choices=[(0, 'Dr.Ajay'), (1, 'Dr.Rahul')], max_length=50)), + ('pathologist_phone', models.CharField(max_length=15)), + ('specialization', models.CharField(max_length=100)), + ('active', models.BooleanField(default=True)), + ], + ), migrations.CreateModel( name='Stock', fields=[ @@ -58,15 +73,17 @@ class Migration(migrations.Migration): ], ), migrations.CreateModel( - name='Schedule', + name='SpecialRequest', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('day', models.IntegerField(choices=[(0, 'Monday'), (1, 'Tuesday'), (2, 'Wednesday'), (3, 'Thursday'), (4, 'Friday'), (5, 'Saturday'), (6, 'Sunday')])), - ('from_time', models.TimeField(blank=True, null=True)), - ('to_time', models.TimeField(blank=True, null=True)), - ('room', models.IntegerField()), - ('date', models.DateField(auto_now=True)), - ('doctor_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor')), + ('request_date', models.DateTimeField(default=datetime.date.today)), + ('brief', models.CharField(default='--', max_length=20)), + ('request_details', models.CharField(max_length=200)), + ('upload_request', models.FileField(blank=True, upload_to='')), + ('status', models.CharField(default='Pending', max_length=50)), + ('remarks', models.CharField(default='--', max_length=300)), + ('request_receiver', models.CharField(default='--', max_length=30)), + ('request_ann_maker', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='special_requests_made', to='globals.extrainfo')), ], ), migrations.CreateModel( @@ -76,7 +93,7 @@ class Migration(migrations.Migration): ('details', models.CharField(max_length=100)), ('date', models.DateField()), ('test', models.CharField(blank=True, max_length=200, null=True)), - ('appointment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.appointment')), + ('file_id', models.IntegerField(default=0)), ('doctor_id', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor')), ('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), ], @@ -92,6 +109,18 @@ class Migration(migrations.Migration): ('prescription_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.prescription')), ], ), + migrations.CreateModel( + name='Pathologist_Schedule', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('day', models.CharField(choices=[(0, 'Monday'), (1, 'Tuesday'), (2, 'Wednesday'), (3, 'Thursday'), (4, 'Friday'), (5, 'Saturday'), (6, 'Sunday')], max_length=10)), + ('from_time', models.TimeField(blank=True, null=True)), + ('to_time', models.TimeField(blank=True, null=True)), + ('room', models.IntegerField()), + ('date', models.DateField(auto_now=True)), + ('pathologist_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.pathologist')), + ], + ), migrations.CreateModel( name='Medicine', fields=[ @@ -129,6 +158,18 @@ class Migration(migrations.Migration): ('medicine_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.stock')), ], ), + migrations.CreateModel( + name='Doctors_Schedule', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('day', models.CharField(choices=[(0, 'Monday'), (1, 'Tuesday'), (2, 'Wednesday'), (3, 'Thursday'), (4, 'Friday'), (5, 'Saturday'), (6, 'Sunday')], max_length=10)), + ('from_time', models.TimeField(blank=True, null=True)), + ('to_time', models.TimeField(blank=True, null=True)), + ('room', models.IntegerField()), + ('date', models.DateField(auto_now=True)), + ('doctor_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor')), + ], + ), migrations.CreateModel( name='Complaint', fields=[ @@ -139,20 +180,29 @@ class Migration(migrations.Migration): ('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), ], ), - migrations.AddField( - model_name='appointment', - name='doctor_id', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor'), - ), - migrations.AddField( - model_name='appointment', - name='schedule', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.schedule'), + migrations.CreateModel( + name='Appointment', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.CharField(max_length=50)), + ('date', models.DateField()), + ('doctor_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor')), + ('schedule', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.doctors_schedule')), + ('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), + ], ), - migrations.AddField( - model_name='appointment', - name='user_id', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo'), + migrations.CreateModel( + name='Announcements', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('ann_date', models.DateTimeField(default='04-04-2021')), + ('message', models.CharField(max_length=200)), + ('batch', models.CharField(default='Year-1', max_length=40)), + ('department', models.CharField(default='ALL', max_length=40)), + ('programme', models.CharField(max_length=10)), + ('upload_announcement', models.FileField(default=' ', null=True, upload_to='health_center/upload_announcement')), + ('anno_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='announcements_made', to='globals.extrainfo')), + ], ), migrations.CreateModel( name='Ambulance_request', diff --git a/FusionIIIT/applications/health_center/models.py b/FusionIIIT/applications/health_center/models.py index b22410cd4..37f076d08 100644 --- a/FusionIIIT/applications/health_center/models.py +++ b/FusionIIIT/applications/health_center/models.py @@ -1,8 +1,10 @@ + from django.db import models from datetime import date from applications.globals.models import ExtraInfo + # Create your models here. @@ -112,8 +114,6 @@ class Pathologist_Schedule(models.Model): room = models.IntegerField() date = models.DateField(auto_now=True) - - class Counter(models.Model): count=models.IntegerField(default=0) @@ -170,6 +170,7 @@ class Prescription(models.Model): details = models.CharField(max_length=100) date = models.DateField() test = models.CharField(max_length=200, null=True, blank=True) + file_id=models.IntegerField(default=0) # appointment = models.ForeignKey(Appointment, on_delete=models.CASCADE,null=True, blank=True) def __str__(self): @@ -226,4 +227,12 @@ class SpecialRequest(models.Model): request_receiver = models.CharField(max_length=30, default="--") def __str__(self): - return str(self.request_ann_maker.user.username) \ No newline at end of file + return str(self.request_ann_maker.user.username) + +class medical_relief(models.Model): + description = models.CharField(max_length=200) + file = models.FileField(upload_to='medical_files/') + file_id=models.IntegerField(default=0) + compounder_forward_flag = models.BooleanField(default=False) + acc_admin_forward_flag = models.BooleanField(default=False) + diff --git a/FusionIIIT/applications/health_center/urls.py b/FusionIIIT/applications/health_center/urls.py index a3969188e..77d89dd0a 100644 --- a/FusionIIIT/applications/health_center/urls.py +++ b/FusionIIIT/applications/health_center/urls.py @@ -1,7 +1,7 @@ from django import views from django.conf.urls import url,include -from .views import compounder_view, healthcenter, student_view, schedule_entry,doctor_entry,compounder_entry,announcement +from .views import * app_name = 'healthcenter' @@ -16,10 +16,11 @@ url(r'announcement/', announcement, name='announcement'), #database entry - - + url(r'^schedule_entry', schedule_entry, name='schedule_entry'), url(r'^doctor_entry', doctor_entry, name='doctor_entry'), url(r'^compounder_entry', compounder_entry, name='compounder_entry'), + # url(r'^fetch_designations', fetch_designations, name='fetch_designations'), + url(r'^medical_relief', medicalrelief, name='medical_relief'), #api url(r'^api/',include('applications.health_center.api.urls')) diff --git a/FusionIIIT/applications/health_center/utils.py b/FusionIIIT/applications/health_center/utils.py index e0ec56c75..c47f90d06 100644 --- a/FusionIIIT/applications/health_center/utils.py +++ b/FusionIIIT/applications/health_center/utils.py @@ -2,12 +2,15 @@ from datetime import datetime, timedelta from applications.globals.models import ExtraInfo from django.core import serializers +from applications.filetracking.models import File +from applications.globals.models import ExtraInfo, HoldsDesignation, Designation, DepartmentInfo from django.http import HttpResponse, JsonResponse from notification.views import healthcare_center_notif from .models import (Ambulance_request, Appointment, Complaint, Doctor, Expiry, Hospital, Hospital_admit, Medicine, Prescribed_medicine, Prescription, Doctors_Schedule,Pathologist_Schedule, - Stock, Announcements, SpecialRequest, Pathologist) + Stock, Announcements, SpecialRequest, Pathologist, medical_relief) +from applications.filetracking.sdk.methods import * def datetime_handler(date): ''' @@ -377,14 +380,32 @@ def compounder_view_handler(request): # appointment = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').get(user_id=user_id,date=datetime.now()) # else: # appointment = None - Prescription.objects.create( + designation=request.POST.get('user') + uploaded_file = request.FILES.get('file') + d = HoldsDesignation.objects.get(user__username=designation) + form_object=Prescription( user_id=user, doctor_id=doctor, details=details, date=datetime.now(), - test=tests, + test=tests, # appointment=appointment ) + form_object.save() + request_object = Prescription.objects.get(pk=form_object.pk) + send_file_id = create_file( + uploader=request.user.username, + uploader_designation=request.session['currentDesignationSelected'], + receiver=designation, + receiver_designation=d.designation, + src_module="health_center", + src_object_id=str(request_object.id), + file_extra_JSON={"value": 2}, + attached_file=uploaded_file + ) + request_object.file_id=send_file_id + request_object.save() + query = Medicine.objects.select_related('patient','patient__user','patient__department').filter(patient=user) prescribe = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().last() for medicine in query: @@ -425,13 +446,18 @@ def compounder_view_handler(request): else: status = 0 Medicine.objects.select_related('patient','patient__user','patient__department').all().delete() + healthcare_center_notif(request.user, user.user, 'presc') data = {'status': status} return JsonResponse(data) elif 'cancel_presc' in request.POST: presc_id = request.POST.get('cancel_presc') - Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').filter(pk=presc_id).delete() + prescription=Prescription.objects.filter(pk=presc_id) + is_deleted = delete_file(id=presciption.file_id) + prescription.delete() + + data = {'status': 1} return JsonResponse(data) elif 'medicine' in request.POST: @@ -439,6 +465,35 @@ def compounder_view_handler(request): thresh = Stock.objects.get(id=med_id).threshold data = {'thresh': thresh} return JsonResponse(data) + elif 'compounder_forward' in request.POST: + acc_admin_des_id = Designation.objects.get(name="Accounts Admin") + user_ids = HoldsDesignation.objects.filter(designation_id=acc_admin_des_id.id).values_list('user_id', flat=True) + acc_admins = ExtraInfo.objects.get(user_id=user_ids[0]) + user=ExtraInfo.objects.get(pk=acc_admins.id) + forwarded_file_id=forward_file( + file_id=request.POST['file_id'], + receiver=acc_admins.id, + receiver_designation="Accounts Admin", + file_extra_JSON= {"value": 2}, + remarks="Forwarded File with id: "+ str(request.POST['file_id'])+"to Accounts Admin "+str(acc_admins.id), + file_attachment=None, + ) + + medical_relief_instance = medical_relief.objects.get(file_id=request.POST['file_id']) + medical_relief_instance.compounder_forward_flag = True + medical_relief_instance.save() + + healthcare_center_notif(request.user,user.user,'rel_approve') + + + + + data = {'status': 1} + return JsonResponse(data) + + + + def student_view_handler(request): @@ -531,4 +586,73 @@ def student_view_handler(request): app_id = request.POST.get('cancel_app') Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(pk=app_id).delete() data = {'status': 1} - return JsonResponse(data) \ No newline at end of file + return JsonResponse(data) + elif 'medical_relief_submit' in request.POST: + designation = request.POST.get('designation') + # print("# #") + # print(designation) + user=ExtraInfo.objects.get(pk=designation) + description = request.POST.get('description') + + # Retrieve the uploaded file from request.FILES + uploaded_file = request.FILES.get('file') + + # Create an instance of the medical_relief model + form_object = medical_relief( + description=description, + file=uploaded_file + ) + + # Save the form object + form_object.save() + + # Retrieve the form object you just saved + request_object = medical_relief.objects.get(pk=form_object.pk) + + # Retrieve HoldsDesignation instances + d = HoldsDesignation.objects.get(user__username=designation) + d1 = HoldsDesignation.objects.get(user__username=request.user) + + # Create a file entry using the create_file utility function + send_file_id = create_file( + uploader=request.user.username, + uploader_designation=request.session['currentDesignationSelected'], + receiver=designation, + receiver_designation=d.designation, + src_module="health_center", + src_object_id=str(request_object.id), + file_extra_JSON={"value": 2}, + attached_file=uploaded_file + ) + healthcare_center_notif(request.user,user.user,'rel_forward') + request_object.file_id = send_file_id + request_object.save() + + # file_details_dict = view_file(file_id=send_file_id) + # print(file_details_dict) + return JsonResponse({'status': 1}) + + elif 'acc_admin_forward' in request.POST: + file_id=request.POST['file_id'] + rec=File.objects.get(id=file_id) + des=Designation.objects.get(pk=rec.designation_id) + user=ExtraInfo.objects.get(pk=rec.uploader_id) + + forwarded_file_id=forward_file( + file_id=request.POST['file_id'], + receiver=rec.uploader_id, + receiver_designation=des.name, + file_extra_JSON= {"value": 2}, + remarks="Forwarded File with id: "+ str(request.POST['file_id'])+"to"+str(rec.id), + file_attachment=None, + ) + medical_relief_instance = medical_relief.objects.get(file_id=request.POST['file_id']) + medical_relief_instance.acc_admin_forward_flag = True + medical_relief_instance.save() + + healthcare_center_notif(request.user,user.user,'rel_approved') + + return JsonResponse({'status':1}) + + + \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/views.py b/FusionIIIT/applications/health_center/views.py index 8ded8b462..3af92e083 100644 --- a/FusionIIIT/applications/health_center/views.py +++ b/FusionIIIT/applications/health_center/views.py @@ -10,11 +10,13 @@ from django.http import HttpResponse, HttpResponseRedirect, JsonResponse from django.shortcuts import get_object_or_404, render, redirect from notification.views import healthcare_center_notif +from applications.health_center.api.serializers import MedicalReliefSerializer from .models import (Ambulance_request, Appointment, Complaint, Constants, Counter, Doctor,Pathologist, Expiry, Hospital, Hospital_admit, Medicine, Prescribed_medicine, Prescription, Doctors_Schedule,Pathologist_Schedule, - Stock,SpecialRequest,Announcements) + Stock,SpecialRequest,Announcements,medical_relief) from .utils import datetime_handler, compounder_view_handler, student_view_handler +from applications.filetracking.sdk.methods import * @@ -65,12 +67,14 @@ def compounder_view(request): doctors: retrieve Doctor class objects from database ''' # compounder view starts here + usertype = ExtraInfo.objects.select_related('user','department').get(user=request.user).user_type if usertype == 'compounder': if request.method == 'POST': return compounder_view_handler(request) else: + notifs = request.user.notifications.all() all_complaints = Complaint.objects.select_related('user_id','user_id__user','user_id__department').all() all_hospitals = Hospital_admit.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().order_by('-admission_date') hospitals_list = Hospital.objects.all().order_by('hospital_name') @@ -79,14 +83,16 @@ def compounder_view(request): appointments_future=Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(date__gt=datetime.now()).order_by('date') users = ExtraInfo.objects.select_related('user','department').filter(user_type='student') stocks = Stock.objects.all() + days = Constants.DAYS_OF_WEEK schedule=Doctors_Schedule.objects.select_related('doctor_id').all().order_by('doctor_id') schedule1=Pathologist_Schedule.objects.select_related('pathologist_id').all().order_by('pathologist_id') expired=Expiry.objects.select_related('medicine_id').filter(expiry_date__lt=datetime.now(),returned=False).order_by('expiry_date') live_meds=Expiry.objects.select_related('medicine_id').filter(returned=False).order_by('quantity') count=Counter.objects.all() - presc_hist=Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().order_by('-date') + medicines_presc=Prescribed_medicine.objects.select_related('prescription_id','prescription_id__user_id','prescription_id__user_id__user','prescription_id__user_id__department','prescription_id__doctor_id').all() + print(medicines_presc) if count: Counter.objects.all().delete() Counter.objects.create(count=0,fine=0) @@ -97,16 +103,54 @@ def compounder_view(request): doctors=Doctor.objects.filter(active=True).order_by('id') pathologists=Pathologist.objects.filter(active=True).order_by('id') - - doct= ["Dr. G S Sandhu", "Dr. Jyoti Garg", "Dr. Arvind Nath Gupta"] + prescription= Prescription.objects.all() + report=[] + for pre in prescription: + dic={} + dic['id']=pre.pk + dic['user_id']=pre.user_id_id + dic['doctor_id'] = pre.doctor_id # Use dot notation + dic['date'] = pre.date # Use dot notation + dic['details'] = pre.details # Use dot notation + dic['test'] = pre.test # Use dot notation + if pre.file_id: + dic['file'] = view_file(file_id=pre.file_id)['upload_file'] + else: + dic['file']=None + report.append(dic) + + + + - + #adding file tracking inbox part for compounder + + inbox_files=view_inbox(username=request.user.username,designation='Compounder',src_module='health_center') + medicalrelief=medical_relief.objects.all() + + inbox=[] + for ib in inbox_files: + dic={} + for mr in medicalrelief: + if mr.file_id==int(ib['id']): + dic['id']=ib['id'] + dic['uploader']=ib['uploader'] + dic['upload_date']=datetime.fromisoformat(ib['upload_date']).date() + dic['desc']=mr.description + dic['file']=view_file(file_id=ib['id'])['upload_file'] + dic['status']=mr.compounder_forward_flag + dic['status1']=mr.acc_admin_forward_flag + inbox.append(dic) + + # print(inbox_files) + + return render(request, 'phcModule/phc_compounder.html', {'days': days, 'users': users, 'count': count,'expired':expired, 'stocks': stocks, 'all_complaints': all_complaints, 'all_hospitals': all_hospitals, 'hospitals':hospitals, 'all_ambulances': all_ambulances, - 'appointments_today': appointments_today, 'doctors': doctors, 'pathologists':pathologists, 'doct': doct, - 'appointments_future': appointments_future, 'schedule': schedule, 'schedule1': schedule1, 'live_meds': live_meds, 'presc_hist': presc_hist, 'medicines_presc': medicines_presc, 'hospitals_list': hospitals_list}) + 'appointments_today': appointments_today, 'doctors': doctors, 'pathologists':pathologists, + 'appointments_future': appointments_future, 'schedule': schedule, 'schedule1': schedule1, 'live_meds': live_meds, 'presc_hist': report, 'medicines_presc': medicines_presc, 'hospitals_list': hospitals_list,'inbox_files':inbox}) elif usertype == 'student': return HttpResponseRedirect("/healthcenter/student") # compounder view ends @@ -131,18 +175,20 @@ def student_view(request): doctors: retrieve Doctor class objects from database ''' # student view starts here + usertype = ExtraInfo.objects.select_related('user','department').get(user=request.user).user_type if usertype == 'student' or usertype == 'faculty' or usertype == 'staff': if request.method == 'POST': return student_view_handler(request) else: + notifs = request.user.notifications.all() users = ExtraInfo.objects.all() user_id = ExtraInfo.objects.select_related('user','department').get(user=request.user) hospitals = Hospital_admit.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').filter(user_id=user_id).order_by('-admission_date') appointments = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(user_id=user_id).order_by('-date') ambulances = Ambulance_request.objects.select_related('user_id','user_id__user','user_id__department').filter(user_id=user_id).order_by('-date_request') - prescription = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').filter(user_id=user_id).order_by('-date') + medicines = Prescribed_medicine.objects.select_related('prescription_id','prescription_id__user_id','prescription_id__user_id__user','prescription_id__user_id__department','prescription_id__doctor_id','medicine_id').all() complaints = Complaint.objects.select_related('user_id','user_id__user','user_id__department').filter(user_id=user_id).order_by('-date') days = Constants.DAYS_OF_WEEK @@ -151,6 +197,24 @@ def student_view(request): doctors=Doctor.objects.filter(active=True) pathologists=Pathologist.objects.filter(active=True) + #prescription + prescription= Prescription.objects.filter(user_id=request.user.username) + report=[] + for pre in prescription: + dic={} + dic['id']=pre.id + dic['doctor_id'] = pre.doctor_id # Use dot notation + dic['date'] = pre.date # Use dot notation + dic['details'] = pre.details # Use dot notation + dic['test'] = pre.test # Use dot notation + if pre.file_id: + dic['file'] = view_file(file_id=pre.file_id)['upload_file'] + else: + dic['file']=None + + + report.append(dic) + count=Counter.objects.all() if count: @@ -158,14 +222,58 @@ def student_view(request): Counter.objects.create(count=0,fine=0) count=Counter.objects.get() - doct= ["Dr. G S Sandhu", "Dr. Jyoti Garg", "Dr. Arvind Nath Gupta"] - + designations = Designation.objects.filter() + holdsDesignations = [] + for d in designations: + if d.name == "Compounder": + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + acc_admin_inbox=view_inbox(username=request.user.username,designation='Accounts Admin',src_module='health_center') + medicalrelief=medical_relief.objects.all() + acc_ib=[] + for ib in acc_admin_inbox: + dic={} + + for mr in medicalrelief: + if mr.file_id == int(ib['id']): + dic['id']=ib['id'] + dic['uploader']=ib['uploader'] + dic['upload_date']=datetime.fromisoformat(ib['upload_date']).date() + dic['desc']=mr.description + dic['file']=view_file(file_id=ib['id'])['upload_file'] + dic['status']=mr.acc_admin_forward_flag + acc_ib.append(dic) + uploader_outbox=view_outbox(username=request.user.username,designation=request.session['currentDesignationSelected'] ,src_module='health_center') + + + uploader_inbox=view_inbox(username=request.user.username,designation=request.session['currentDesignationSelected'],src_module='health_center') + medicalRelief=[] + + for out in uploader_outbox: + dic={} + + for mr in medicalrelief: + if mr.file_id==int(out['id']): + dic['id']=out['id'] + dic['upload_date']=datetime.fromisoformat(out['upload_date']).date() + dic['desc']=mr.description + dic['file']=view_file(file_id=out['id'])['upload_file'] + dic['status']=mr.acc_admin_forward_flag + dic['approval_date']='' + + for inb in uploader_inbox: + if dic['id']==inb['id']: + dic['approval_date']=datetime.fromisoformat(inb['upload_date']).date() + medicalRelief.append(dic) + + return render(request, 'phcModule/phc_student.html', {'complaints': complaints, 'medicines': medicines, 'ambulances': ambulances, 'doctors': doctors, 'pathologists':pathologists, 'days': days,'count':count, 'hospitals': hospitals, 'appointments': appointments, - 'prescription': prescription, 'schedule': schedule, 'schedule1': schedule1,'users': users,'doct': doct, 'curr_date': datetime.now().date()}) + 'prescription': report, 'schedule': schedule, 'schedule1': schedule1,'users': users, 'curr_date': datetime.now().date(),'holdsDesignations':holdsDesignations,'acc_admin_inbox':acc_ib,'medicalRelief':medicalRelief}) elif usertype == 'compounder': return HttpResponseRedirect("/healthcenter/compounder") # student view ends @@ -459,4 +567,43 @@ def announcement(request): return render(request, 'health_center/make_announce_comp.html', {"user_designation":user_info.user_type, "announcements":context, "request_to":requests_received - }) \ No newline at end of file + }) + +# def fetch_designations(request): +# designations = Designation.objects.all() + +# holdsDesignations = [] + +# for d in designations: +# if d.name == "Compounder" or d.name == "Accounts Admin": +# list = HoldsDesignation.objects.filter(designation=d) +# holdsDesignations.append(list) + +# return render(request, 'phcModule/medical_relief.html', {'holdsDesignations' : holdsDesignations}) + +def medicalrelief(request): + print(request) + + + if request.method == 'POST': + # print(request.POST['name']) + formObject = medical_relief() + formObject.description = request.POST['description'] + formObject.file = request.POST['file'] + formObject.save() + request_object = medical_relief.objects.get(pk=formObject.pk) + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + print(d) + print(d1) + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="health_center", + src_object_id= str(request_object.id), + file_extra_JSON= {"value": 2}, + attached_file = None) + + + return render(request, 'phcModule/medical_relief.html', {'holdsDesignations' : holdsDesignations}) \ No newline at end of file diff --git a/FusionIIIT/applications/hostel_management/migrations/0001_initial.py b/FusionIIIT/applications/hostel_management/migrations/0001_initial.py index ef1639d4c..8659d1649 100644 --- a/FusionIIIT/applications/hostel_management/migrations/0001_initial.py +++ b/FusionIIIT/applications/hostel_management/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models @@ -12,9 +12,9 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('academic_information', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('globals', '0001_initial'), + ('academic_information', '0001_initial'), ] operations = [ diff --git a/FusionIIIT/applications/hr2/migrations/0001_initial.py b/FusionIIIT/applications/hr2/migrations/0001_initial.py index 83b197c8f..733f5b0bb 100644 --- a/FusionIIIT/applications/hr2/migrations/0001_initial.py +++ b/FusionIIIT/applications/hr2/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import django.core.validators from django.db import migrations, models diff --git a/FusionIIIT/applications/income_expenditure/migrations/0001_initial.py b/FusionIIIT/applications/income_expenditure/migrations/0001_initial.py index 1501efdb9..e772edafa 100644 --- a/FusionIIIT/applications/income_expenditure/migrations/0001_initial.py +++ b/FusionIIIT/applications/income_expenditure/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.db import migrations, models import django.db.models.deletion diff --git a/FusionIIIT/applications/iwdModuleV2/migrations/0001_initial.py b/FusionIIIT/applications/iwdModuleV2/migrations/0001_initial.py index bbde8386c..b86a5c530 100644 --- a/FusionIIIT/applications/iwdModuleV2/migrations/0001_initial.py +++ b/FusionIIIT/applications/iwdModuleV2/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.db import migrations, models import django.db.models.deletion diff --git a/FusionIIIT/applications/iwdModuleV2/models.py b/FusionIIIT/applications/iwdModuleV2/models.py index a5c40c7b2..a0834f1bb 100644 --- a/FusionIIIT/applications/iwdModuleV2/models.py +++ b/FusionIIIT/applications/iwdModuleV2/models.py @@ -1,5 +1,5 @@ from django.db import models - +from datetime import date # Create your models here. @@ -160,3 +160,51 @@ class NoOfTechnicalBidTimes(models.Model): key = models.ForeignKey(Projects, on_delete=models.CASCADE, unique=True) number = models.IntegerField() +class Requests(models.Model): + 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(default=0) + directorApproval = models.IntegerField(default=0) + deanProcessed = models.IntegerField(default=0) + status = models.CharField(max_length=200) + issuedWorkOrder = models.IntegerField(default=0) + workCompleted = models.IntegerField(default=0) + billGenerated = models.IntegerField(default=0) + billProcessed = models.IntegerField(default=0) + billSettled = models.IntegerField(default=0) + +class WorkOrder(models.Model): + # request_id = models.IntegerField() + request_id = models.ForeignKey(Requests, on_delete=models.CASCADE) + name = models.CharField(max_length=200) + date = models.DateField(default=date.today) + agency = models.CharField(max_length=200) + amount = models.IntegerField(default=0) + deposit = models.IntegerField(default=0) + alloted_time = models.CharField(max_length=200) + start_date = models.DateField() + completion_date = models.DateField() + +class Inventory(models.Model): + name = models.CharField(max_length=200) + quantity = models.IntegerField(default=0) + cost = models.IntegerField(default=0) + +class UsedItems(models.Model): + # requestId = models.IntegerField() + request_id = models.ForeignKey(Requests, on_delete=models.CASCADE) + itemName = models.CharField(max_length=200) + cost = models.IntegerField(default=0) + quantity = models.IntegerField(default=0) + date = models.DateField(default=date.today) + +class Bills(models.Model): + # requestId = models.IntegerField() + request_id = models.ForeignKey(Requests, on_delete=models.CASCADE) + file = models.FileField() + +class Budget(models.Model): + name = models.CharField(max_length=200) + budgetIssued = models.IntegerField(default=0) diff --git a/FusionIIIT/applications/iwdModuleV2/urls.py b/FusionIIIT/applications/iwdModuleV2/urls.py index 6ad401098..0c0830cea 100644 --- a/FusionIIIT/applications/iwdModuleV2/urls.py +++ b/FusionIIIT/applications/iwdModuleV2/urls.py @@ -36,5 +36,46 @@ 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('updateRejectedRequests/', views.updateRejectedRequests, name='Update-Rejected-Requests'), + url('handleUpdateRequests/', views.handleUpdateRequests, name='Handle-Update-Requests'), + # url('rejectedRequests/', views.rejectedRequests, name='Rejected-Requests'), + url('rejectedRequestsView/',views.rejectedRequests, name='Rejected Requests view'), + url('requestsStatus/', views.requestsStatus, name='Requests-Status'), + url('fetchDesignations/', views.fetchDesignations, name='Fetch-Designations'), + url('fetchRequest/', views.fetchRequest, name='Fetch-Request'), + url('issueWorkOrder/', views.issueWorkOrder, name='Issue Work Order'), + url('workOrder/', views.workOrder, name='Work Order'), + url('inventory/', views.inventory, name='Inventory'), + url('addItemsView/', views.addItemsView, name='Add Items View'), + url('addItems/', views.addItems, name='Add Items'), + url('editInventoryView/', views.editInventoryView, name='Edit Inventory View'), + url('editInventory/', views.editInventory, name='Edit Inventory'), + url('requestsInProgess/', views.requestsInProgess, name='Requests In Progress'), + url('workCompleted/', views.workCompleted, name='Work Completed'), + url('requestFromInventory/', views.requestFromInventory, name='Request From Inventory'), + url('editInventoryAfterRequest/', views.editInventoryAfterRequest, name='Edit-Inventory-After-Request'), + url('generateFinalBill/', views.generateFinalBill, name='Generate-Final-Bill'), + url('handleBillGeneratedRequests/', views.handleBillGeneratedRequests, name='Handle-Bill-Generated-Requests'), + url('generatedBillsView/', views.generatedBillsView, name='Generated-Bills-View'), + url('handleProcessedBills/', views.handleProcessedBills, name='Handle-Processed-Bills'), + url('auditDocumentView/', views.auditDocumentView, name='Audit-Document-View'), + url('auditDocument/', views.auditDocument, name='Audit-Document'), + url('settleBillsView/', views.settleBillsView, name='Settle-Bills-View'), + url('handleSettleBillRequests/', views.handleSettleBillRequests, name='Handle-Settle-Bill-Requests'), + url('viewBudget/', views.viewBudget, name='View-Budget'), + url('budget/', views.budget, name='Budget'), + url('addBudget/', views.addBudget, name='Add-Budget'), + url('editBudgetView/', views.editBudgetView, name='Edit-Budget-View'), + url('editBudget/', views.editBudget, name='Edit-Budget'), + # url('billsView/',views.billsView, name='Bills View'), + ] diff --git a/FusionIIIT/applications/iwdModuleV2/views.py b/FusionIIIT/applications/iwdModuleV2/views.py index 2b36550fc..38a7e4ee7 100644 --- a/FusionIIIT/applications/iwdModuleV2/views.py +++ b/FusionIIIT/applications/iwdModuleV2/views.py @@ -1,9 +1,20 @@ from django.shortcuts import render, redirect - +from django.urls import reverse +from django.db.models import Q from applications.globals.models import * +from django.contrib.auth.decorators import login_required from .models import * from django.http import HttpResponseRedirect - +from applications.filetracking.sdk.methods import * +from applications.globals.models import ExtraInfo, HoldsDesignation, Designation +from datetime import datetime +from reportlab.lib.pagesizes import letter +from reportlab.pdfgen import canvas +from reportlab.platypus import Table, TableStyle +from reportlab.lib import colors +from django.http import HttpResponse +from io import BytesIO +from django.core.files.base import File as DjangoFile # Create your views here. @@ -17,17 +28,27 @@ # 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}) + +#Junior Engineer, Electrical Engineer (Civil), Electrical_AE, Electrical_JE, EE, Civil_AE, Civil_JE + 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 + print(eligible) return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) - def page1_1(request): if request.method == 'POST': formObject = PageOneDetails() @@ -107,7 +128,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 +150,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 +168,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 +185,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 +200,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 +212,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 +228,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 +250,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 +261,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 +279,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 +303,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 +328,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 +359,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 +404,976 @@ 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}) + +designations_list = ["Junior Engineer", "Executive Engineer (Civil)", "Electrical_AE", "Electrical_JE", "EE", "Civil_AE", "Civil_JE", "Dean (P&D)", "Director", "Accounts Admin", "Admin IWD", "Auditor"] + +@login_required +def fetchDesignations(request): + designations = Designation.objects.filter() + + holdsDesignations = [] + + for d in designations: + for x in designations_list: + if d.name == x: + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/requestsView.html', {'holdsDesignations' : holdsDesignations}) + +@login_required +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.issuedWorkOrder = 0 + formObject.workCompleted = 0 + formObject.billGenerated = 0 + formObject.billProcessed = 0 + formObject.billSettled = 0 + formObject.save() + print(request.user) + print(request.user.username) + request_object = Requests.objects.get(pk=formObject.pk) + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + print(d) + print(d1) + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(request_object.id), + file_extra_JSON= {"value": 2}, + attached_file = None) + + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + return render(request, 'iwdModuleV2/dashboard.html', {'eligible' : eligible}) + +@login_required +def createdRequests(request): + obj = [] + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + for result in inbox_files: + src_object_id = result['src_object_id'] + request_object = Requests.objects.filter(id=src_object_id).first() + if request_object: + element = [request_object.id, request_object.name, request_object.area, request_object.description, request_object.requestCreatedBy] + obj.append(element) + + designations = Designation.objects.filter() + + holdsDesignations = [] + + for d in designations: + for x in designations_list: + if d.name == x: + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/createdRequests.html', {'obj' : obj, 'holdsDesignations' : holdsDesignations}) + +@login_required +def handleEngineerProcessRequests(request): + if request.method == 'POST': + + request_id = request.POST.get("id", 0) + + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(request_id), + file_extra_JSON= {"value": 2}, + attached_file = None) + + Requests.objects.filter(id=request_id).update(engineerProcessed=1, status="Approved by the engineer") + + inbox_files = view_inbox( + username=request.user, + designation=d1.designation, + src_module="IWD" + ) + + for p in inbox_files: + if p['src_object_id'] == request_id: + delete_file(file_id = p['id']) + break + + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + + return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) + +@login_required +def engineerProcessedRequests(request): + + obj = [] + + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + for result in inbox_files: + src_object_id = result['src_object_id'] + request_object = Requests.objects.filter(id=src_object_id).first() + if request_object: + element = [request_object.id, request_object.name, request_object.area, request_object.description, request_object.requestCreatedBy] + obj.append(element) + + designations = Designation.objects.filter() + + holdsDesignations = [] + + for d in designations: + for x in designations_list: + if d.name == x: + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/engineerProcessedRequests.html', {'obj' : obj, 'holdsDesignations' : holdsDesignations}) + +@login_required +def handleDeanProcessRequests(request): + if request.method == 'POST': + + request_id = request.POST.get("id", 0) + + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(request_id), + file_extra_JSON= {"value": 2}, + attached_file = None) + + Requests.objects.filter(id=request_id).update(deanProcessed=1, status="Approved by the dean") + + inbox_files = view_inbox( + username=request.user, + designation=d1.designation, + src_module="IWD" + ) + + for p in inbox_files: + if p['src_object_id'] == request_id: + delete_file(file_id = p['id']) + break + + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) + +@login_required +def deanProcessedRequests(request): + obj = [] + + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + for result in inbox_files: + src_object_id = result['src_object_id'] + request_object = Requests.objects.filter(id=src_object_id).first() + if request_object: + element = [request_object.id, request_object.name, request_object.area, request_object.description, request_object.requestCreatedBy] + obj.append(element) + + designations = Designation.objects.filter() + + holdsDesignations = [] + + for d in designations: + for x in designations_list: + if d.name == x: + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/deanProcessedRequests.html', {'obj' : obj, 'holdsDesignations' : holdsDesignations}) + +@login_required +def handleDirectorApprovalRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(request_id), + file_extra_JSON= {"value": 2}, + attached_file = None) + + Requests.objects.filter(id=request_id).update(directorApproval=1, status="Approved by the director") + + inbox_files = view_inbox( + username=request.user, + designation=d1.designation, + src_module="IWD" + ) + + for p in inbox_files: + if p['src_object_id'] == request_id: + delete_file(file_id = p['id']) + break + + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) + +@login_required +def handleDirectorRejectionRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(request_id), + file_extra_JSON= {"value": 2}, + attached_file = None) + + Requests.objects.filter(id=request_id).update(directorApproval=-1, status="Rejected by the director") + + inbox_files = view_inbox( + username=request.user, + designation=d1.designation, + src_module="IWD" + ) + + for p in inbox_files: + if p['src_object_id'] == request_id: + delete_file(file_id = p['id']) + break + + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) + +@login_required +def rejectedRequests(request): + obj = [] + + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + for result in inbox_files: + src_object_id = result['src_object_id'] + request_object = Requests.objects.filter(id=src_object_id).first() + if request_object.directorApproval == -1: + element = [request_object.id, request_object.name, request_object.area, request_object.description, request_object.requestCreatedBy] + obj.append(element) + + designations = Designation.objects.filter() + + holdsDesignations = [] + + for d in designations: + for x in designations_list: + if d.name == x: + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/rejectedRequests.html', {'obj' : obj, 'holdsDesignations' : holdsDesignations}) + +@login_required +def updateRejectedRequests(request): + request_id = request.POST.get("id", 0) + + d1 = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d1.designation, + src_module="IWD" + ) + + for p in inbox_files: + if p['src_object_id'] == request_id: + delete_file(file_id = p['id']) + break + + designations = Designation.objects.filter() + + holdsDesignations = [] + obj = [] + + request_object = Requests.objects.get(id=request_id) + + obj = [request_object.id, request_object.name, request_object.description, request_object.area] + + for d in designations: + for x in designations_list: + if d.name == x: + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/updateRequests.html', {'obj' : obj, 'holdsDesignations' : holdsDesignations}) + +@login_required +def handleUpdateRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + Requests.objects.filter(id=request_id).update(name=request.POST['name'], + description=request.POST['description'], + area=request.POST['area'], + engineerProcessed=0, + directorApproval=0, + deanProcessed=0, + requestCreatedBy=request.user.username, + status="Pending", + issuedWorkOrder=0, + workCompleted=0, + billGenerated=0, + billProcessed=0, + billSettled=0) + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(request_id), + file_extra_JSON= {"value": 2}, + attached_file = None) + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + return render(request, 'iwdModuleV2/dashboard.html', {'eligible' : eligible}) + +@login_required +def issueWorkOrder(request): + obj = [] + + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + for result in inbox_files: + uploader = result['sent_by_designation'] + if uploader == 'Director': + src_object_id = result['src_object_id'] + request_object = Requests.objects.filter(id=src_object_id).first() + if request_object: + element = [request_object.id, request_object.name, request_object.area, request_object.description, request_object.requestCreatedBy] + obj.append(element) + + return render(request, 'iwdModuleV2/issueWorkOrder.html', {'obj' : obj}) + +@login_required +def fetchRequest(request): + request_id = request.POST.get("id", 0) + req_request = Requests.objects.get(id=request_id) + return render(request, 'iwdModuleV2/workOrder.html', {'req' : req_request}) + +@login_required +def workOrder(request): + if request.method == 'POST': + request_instance = Requests.objects.get(pk=request.POST['id']) + formObject = WorkOrder() + formObject.request_id = request_instance + formObject.name = request.POST['name'] + formObject.date = request.POST['date'] + formObject.agency = request.POST['agency'] + formObject.amount = request.POST['amount'] + formObject.deposit = request.POST['deposit'] + formObject.alloted_time = request.POST['time'] + formObject.start_date = request.POST['startDate'] + formObject.completion_date = request.POST['completionDate'] + formObject.save() + + Requests.objects.filter(id=request.POST['id']).update(status="Work Order issued", issuedWorkOrder=1) + + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + for result in inbox_files: + if result['src_object_id'] == request.POST['id'] and result['sent_by_designation'] == 'Director': + delete_file(file_id = result['id']) + break + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + obj = [] + + for result in inbox_files: + uploader = result['sent_by_designation'] + if uploader == 'Director': + src_object_id = result['src_object_id'] + request_object = Requests.objects.filter(id=src_object_id).first() + if request_object: + element = [request_object.id, request_object.name, request_object.area, request_object.description, request_object.requestCreatedBy] + obj.append(element) + + return render(request, 'iwdModuleV2/issueWorkOrder.html', {'obj' : obj}) + +@login_required +def requestsStatus(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}) + +@login_required +def inventory(request): + items = Inventory.objects.filter() + obj = [] + for i in items: + element = [i.id, i.name, i.quantity, i.cost] + obj.append(element) + return render(request, 'iwdModuleV2/inventory.html', {'obj' : obj}) + +@login_required +def addItemsView(request): + return render(request, 'iwdModuleV2/addItemsView.html') + +@login_required +def addItems(request): + if request.method == "POST": + formObject = Inventory() + formObject.name = request.POST['name'] + formObject.quantity = request.POST['quantity'] + formObject.cost = request.POST['cost'] + formObject.save() + return render(request, 'iwdModuleV2/addItemsView.html') + +@login_required +def editInventoryView(request): + items = Inventory.objects.filter() + obj = [] + for i in items: + element = [i.id, i.name, i.quantity, i.cost] + obj.append(element) + return render(request, 'iwdModuleV2/editInventory.html', {'obj' : obj}) + +@login_required +def editInventory(request): + if request.method == "POST": + itemId = request.POST['id'] + itemName = request.POST['name'] + itemQuantity = request.POST['quantity'] + itemCost = request.POST['cost'] + if itemQuantity == "0": + Inventory.objects.filter(id=itemId).delete() + else: + Inventory.objects.filter(id=itemId).update(name=itemName, quantity=itemQuantity, cost=itemCost) + items = Inventory.objects.filter() + obj = [] + for i in items: + element = [i.id, i.name, i.quantity, i.cost] + obj.append(element) + return render(request, 'iwdModuleV2/editInventory.html', {'obj' : obj}) + +@login_required +def requestsInProgess(request): + obj = [] + requestsObject = Requests.objects.filter(issuedWorkOrder=1, billGenerated=0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy, x.workCompleted] + obj.append(element) + return render(request, 'iwdModuleV2/requestsInProgress.html', {'obj' : obj}) + +@login_required +def workCompleted(request): + if request.method == 'POST': + Requests.objects.filter(id=request.POST['id']).update(workCompleted=1, status="Work Completed") + obj = [] + requestsObject = Requests.objects.filter(issuedWorkOrder=1, billGenerated=0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy, x.workCompleted] + obj.append(element) + return render(request, 'iwdModuleV2/requestsInProgress.html', {'obj' : obj}) + +@login_required +def requestFromInventory(request): + if request.method == 'POST': + requestId = request.POST['id'] + Req = Requests.objects.filter(id=requestId) + Items = Inventory.objects.filter() + req = [] + items = [] + for x in Req: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy, x.workCompleted] + req.append(element) + + for x in Items: + element = [x.id, x.name, x.quantity, x.cost] + items.append(element) + print(items) + return render(request, 'iwdModuleV2/requestFromInventory.html', {'req' : req, 'items' : items}) + +@login_required +def editInventoryAfterRequest(request): + if request.method == 'POST': + selectedItem = Inventory.objects.get(id=request.POST['selected_item_id']) + q = int(selectedItem.quantity) + if q == int(request.POST['quantity']): + Inventory.objects.filter(id=request.POST['selected_item_id']).delete() + else: + Inventory.objects.filter(id=request.POST['selected_item_id']).update(quantity=(q-int(request.POST['quantity']))) + formObject = UsedItems() + request_instance = Requests.objects.get(pk=request.POST['id']) + formObject.request_id = request_instance + formObject.itemName = selectedItem.name + formObject.cost = selectedItem.cost + formObject.quantity = request.POST['quantity'] + formObject.date = datetime.now().date() + formObject.save() + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + return render(request, 'iwdModuleV2/dashboard.html', {'eligible': eligible}) + +@login_required +def generateFinalBill(request): + if request.method == 'POST': + requestId = request.POST.get("id", 0) + + usedItems = UsedItems.objects.filter(request_id=requestId) + workOrder = WorkOrder.objects.get(request_id=requestId) + + itemsList = [] + + for used in usedItems: + element = [used.itemName, used.quantity, used.cost, used.date] + itemsList.append(element) + + filename = f"Request_id_{requestId}_final_bill.pdf" + + buffer = BytesIO() + + c = canvas.Canvas(buffer, pagesize=letter) + + c.setFont("Helvetica", 12) + + y_position = 750 + + rid = f"Request Id : {requestId}" + agency = f"Agency : {workOrder.agency}" + + c.drawString(100, y_position, rid) + y_position -= 20 + + c.drawString(100, y_position, agency) + y_position -= 20 + + c.drawString(100, y_position - 40, "Items:") + + data = [["Item Name", "Quantity", "Cost (in Rupees)", "Date of Purchase", "Total Amount"]] + for item in itemsList: + data.append([item[0], str(item[1]), "{:.2f}".format(item[2]), item[3], "{:.2f}".format(item[1] * item[2])]) + + total_amount_to_be_paid = sum(item[1] * item[2] for item in itemsList) + + c.drawString(100, y_position - 80, f"Total Amount (in Rupees): {total_amount_to_be_paid:.2f}") + + table = Table(data) + table.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, 0), colors.grey), + ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke), + ('ALIGN', (0, 0), (-1, -1), 'CENTER'), + ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'), + ('BOTTOMPADDING', (0, 0), (-1, 0), 12), + ('BACKGROUND', (0, 1), (-1, -1), colors.beige), + ('GRID', (0, 0), (-1, -1), 1, colors.black)])) + + table.wrapOn(c, 400, 600) + table.drawOn(c, 100, y_position - 60) + + c.save() + + buffer.seek(0) + + response = HttpResponse(content_type='application/pdf') + response['Content-Disposition'] = f'attachment; filename="{filename}"' + response.write(buffer.getvalue()) + + return response + +@login_required +def handleBillGeneratedRequests(request): + if request.method == 'POST': + requestId = request.POST.get("id", 0) + Requests.objects.filter(id=requestId).update(status="Bill Generated", billGenerated=1) + obj = [] + requestsObject = Requests.objects.filter(issuedWorkOrder=1, billGenerated=0) + for x in requestsObject: + element = [x.id, x.name, x.area, x.description, x.requestCreatedBy, x.workCompleted] + obj.append(element) + return render(request, 'iwdModuleV2/requestsInProgress.html', {'obj' : obj}) + +@login_required +def generatedBillsView(request): + request_object = Requests.objects.filter(billGenerated=1, billProcessed=0) + obj = [] + for x in request_object: + element = [x.id, x.name, x.description, x.area, x.requestCreatedBy] + obj.append(element) + designations = Designation.objects.filter() + + holdsDesignations = [] + + for d in designations: + for x in designations_list: + if d.name == x: + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/generatedBillsRequestsView.html', {'obj' : obj, 'holdsDesignations' : holdsDesignations}) + +@login_required +def handleProcessedBills(request): + if request.method == 'POST': + requestId = request.POST.get("id", 0) + request_instance = Requests.objects.get(pk=requestId) + + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(requestId), + file_extra_JSON= {"value": 2}, + attached_file = request.FILES['bill']) + + formObject = Bills() + formObject.request_id = request_instance + formObject.file = request.FILES['bill'] + formObject.save() + + Requests.objects.filter(id=requestId).update(status="Final Bill Processed", billProcessed=1) + + request_object = Requests.objects.filter(billGenerated=1, billProcessed=0) + obj = [] + for x in request_object: + element = [x.id, x.name, x.description, x.area, x.requestCreatedBy] + obj.append(element) + + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + + return render(request, 'iwdModuleV2/dashboard.html', {'obj' : obj, 'eligible': eligible}) + +@login_required +def auditDocumentView(request): + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + obj = [] + + for x in inbox_files: + requestId = x['src_object_id'] + files = Bills.objects.get(request_id=requestId) + element = [files.request_id.id, files.file, files.file.url] + obj.append(element) + + designations = Designation.objects.filter() + + holdsDesignations = [] + + for d in designations: + if d.name == "Engineer" or d.name == "Dean" or d.name == "Director" or d.name == "Accounts Admin" or d.name == "Admin IWD": + list = HoldsDesignation.objects.filter(designation=d) + holdsDesignations.append(list) + + return render(request, 'iwdModuleV2/auditDocumentView.html', {'obj' : obj, 'holdsDesignations' : holdsDesignations}) + +@login_required +def auditDocument(request): + if request.method == 'POST': + requestId = request.POST.get("id", 0) + + d = HoldsDesignation.objects.get(user__username=request.POST['designation']) + d1 = HoldsDesignation.objects.get(user__username=request.user) + + create_file(uploader=request.user.username, + uploader_designation=d1.designation, + receiver=request.POST['designation'], + receiver_designation=d.designation, + src_module="IWD", + src_object_id= str(requestId), + file_extra_JSON= {"value": 2}, + attached_file = None) + + inbox_files = view_inbox( + username=request.user, + designation=d1.designation, + src_module="IWD" + ) + + for result in inbox_files: + print(result['src_object_id']) + if result['src_object_id'] == requestId: + delete_file(file_id = result['id']) + break + + Requests.objects.filter(id=requestId).update(status="Bill Audited") + + eligible = "" + userObj = request.user + userDesignationObjects = HoldsDesignation.objects.filter(user=userObj) + for p in userDesignationObjects: + eligible = p.designation.name + + return render(request, 'iwdModuleV2/dashboard.html', {'eligible' : eligible}) + +@login_required +def settleBillsView(request): + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + obj = [] + + for x in inbox_files: + requestId = x['src_object_id'] + bills_object = Bills.objects.filter(request_id=requestId).first() + element = [bills_object.request_id.id, bills_object.file, bills_object.file.url] + obj.append(element) + + return render(request, 'iwdModuleV2/settleBillsView.html', {'obj' : obj}) + +@login_required +def handleSettleBillRequests(request): + if request.method == 'POST': + request_id = request.POST.get("id", 0) + + d = HoldsDesignation.objects.get(user__username=request.user) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + for p in inbox_files: + if p['src_object_id'] == request_id: + delete_file(file_id = p['id']) + break + + Requests.objects.filter(id=request_id).update(status="Final Bill Settled", billSettled=1) + + inbox_files = view_inbox( + username=request.user, + designation=d.designation, + src_module="IWD" + ) + + obj = [] + + for x in inbox_files: + request_id = x['src_object_id'] + bills_object = Bills.objects.get(request_id=request_id) + element = [request_id, bills_object.file, bills_object.file.url] + obj.append(element) + + return render(request, 'iwdModuleV2/settleBillsView.html', {'obj' : obj}) + +@login_required +def viewBudget(request): + + budget_object = Budget.objects.filter() + + obj = [] + + for x in budget_object: + element = [x.id, x.name, x.budgetIssued] + obj.append(element) + + return render(request, 'iwdModuleV2/viewBudget.html', {'obj' : obj}) + +@login_required +def budget(request): + budget_object = Budget.objects.filter() + + obj = [] + + for x in budget_object: + element = [x.id, x.name, x.budgetIssued] + obj.append(element) + + return render(request, 'iwdModuleV2/budget.html', {'obj' : obj}) + +@login_required +def addBudget(request): + if request.method == 'POST': + formObject = Budget() + formObject.name = request.POST['name'] + formObject.budgetIssued = request.POST['budget'] + formObject.save() + return render(request, 'iwdModuleV2/addBudget.html', {}) + +@login_required +def editBudgetView(request): + budget_object = Budget.objects.filter() + + obj = [] + + for x in budget_object: + element = [x.id, x.name, x.budgetIssued] + obj.append(element) + + return render(request, 'iwdModuleV2/editBudget.html', {'obj' : obj}) + +@login_required +def editBudget(request): + if request.method == "POST": + budgetId = request.POST['id'] + budgetName = request.POST['name'] + budgetIssued = request.POST['budget'] + Budget.objects.filter(id=budgetId).update(name=budgetName, budgetIssued=budgetIssued) + items = Budget.objects.filter() + obj = [] + for i in items: + element = [i.id, i.name, i.budgetIssued] + obj.append(element) + return render(request, 'iwdModuleV2/editBudget.html', {'obj' : obj}) + + diff --git a/FusionIIIT/applications/leave/migrations/0001_initial.py b/FusionIIIT/applications/leave/migrations/0001_initial.py index d9ce4e044..b6fa10f0c 100644 --- a/FusionIIIT/applications/leave/migrations/0001_initial.py +++ b/FusionIIIT/applications/leave/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models diff --git a/FusionIIIT/applications/notifications_extension/api/serializers.py b/FusionIIIT/applications/notifications_extension/api/serializers.py new file mode 100644 index 000000000..899c50e57 --- /dev/null +++ b/FusionIIIT/applications/notifications_extension/api/serializers.py @@ -0,0 +1,6 @@ +from rest_framework import serializers +from notifications.models import Notification +class NotificationSerializer(serializers.ModelSerializer): + class Meta: + model = Notification + fields = '__all__' \ No newline at end of file diff --git a/FusionIIIT/applications/notifications_extension/api/urls.py b/FusionIIIT/applications/notifications_extension/api/urls.py new file mode 100644 index 000000000..1b420e336 --- /dev/null +++ b/FusionIIIT/applications/notifications_extension/api/urls.py @@ -0,0 +1,51 @@ +# urls.py +from django.urls import path +from .views import ( + LeaveModuleNotificationAPIView, + PlacementCellNotificationAPIView, + AcademicsModuleNotificationAPIView, + OfficeModuleNotificationAPIView, + CentralMessNotificationAPIView, + VisitorsHostelNotificationAPIView, + HealthcareCenterNotificationAPIView, + FileTrackingNotificationAPIView, + ScholarshipPortalNotificationAPIView, + ComplaintSystemNotificationAPIView, + OfficeDeanPnDNotificationAPIView, + OfficeDeanSNotificationAPIView, + GymkhanaVotingNotificationAPIView, + GymkhanaSessionNotificationAPIView, + GymkhanaEventNotificationAPIView, + AssistantshipClaimNotificationAPIView, + DepartmentNotificationAPIView, + OfficeDeanRSPCNotificationAPIView, + ResearchProceduresNotificationAPIView, + MarkAsRead, + Delete, + NotificationsList, +) + +urlpatterns = [ + path('notifications/', NotificationsList.as_view(), name='notifications' ), + path('delete/', Delete.as_view(),name='delete'), + path('mark_as_read/', MarkAsRead.as_view(),name='mark_as_read'), + path('leave_module_notification/', LeaveModuleNotificationAPIView.as_view(), name='leave_module_notification'), + path('placement_cell_notification/', PlacementCellNotificationAPIView.as_view(), name='placement_cell_notification'), + path('academics_module_notification/', AcademicsModuleNotificationAPIView.as_view(), name='academics_module_notification'), + path('office_module_notification/', OfficeModuleNotificationAPIView.as_view(), name='office_module_notification'), + path('central_mess_notification/', CentralMessNotificationAPIView.as_view(), name='central_mess_notification'), + path('visitors_hostel_notification/', VisitorsHostelNotificationAPIView.as_view(), name='visitors_hostel_notification'), + path('healthcare_center_notification/', HealthcareCenterNotificationAPIView.as_view(), name='healthcare_center_notification'), + path('file_tracking_notification/', FileTrackingNotificationAPIView.as_view(), name='file_tracking_notification'), + path('scholarship_portal_notification/', ScholarshipPortalNotificationAPIView.as_view(), name='scholarship_portal_notification'), + path('complaint_system_notification/', ComplaintSystemNotificationAPIView.as_view(), name='complaint_system_notification'), + path('office_dean_PnD_notification/', OfficeDeanPnDNotificationAPIView.as_view(), name='office_dean_PnD_notification'), + path('office_dean_S_notification/', OfficeDeanSNotificationAPIView.as_view(), name='office_dean_S_notification'), + path('gymkhana_voting/', GymkhanaVotingNotificationAPIView.as_view(), name='gymkhana_voting'), + path('gymkhana_session/', GymkhanaSessionNotificationAPIView.as_view(), name='gymkhana_session'), + path('gymkhana_event/', GymkhanaEventNotificationAPIView.as_view(), name='gymkhana_event'), + path('assistantship_claim/', AssistantshipClaimNotificationAPIView.as_view(), name='assistantship_claim'), + path('department_notification/', DepartmentNotificationAPIView.as_view(), name='department_notification'), + path('office_dean_RSPC_notification/', OfficeDeanRSPCNotificationAPIView.as_view(), name='office_dean_RSPC_notification'), + path('research_procedures_notification/', ResearchProceduresNotificationAPIView.as_view(), name='research_procedures_notification'), +] diff --git a/FusionIIIT/applications/notifications_extension/api/views.py b/FusionIIIT/applications/notifications_extension/api/views.py new file mode 100644 index 000000000..b87b488da --- /dev/null +++ b/FusionIIIT/applications/notifications_extension/api/views.py @@ -0,0 +1,357 @@ +# views.py +from rest_framework.views import APIView +from django.contrib.auth import get_user_model +from rest_framework.response import Response +from notifications.utils import slug2id +from django.shortcuts import get_object_or_404 +from rest_framework.generics import ListAPIView +from notifications.models import Notification +from rest_framework import status +from .serializers import NotificationSerializer +from notification.views import (leave_module_notif, + placement_cell_notif, + academics_module_notif, + office_module_notif, + central_mess_notif, + visitors_hostel_notif, + healthcare_center_notif, + file_tracking_notif, + scholarship_portal_notif, + complaint_system_notif, + office_dean_PnD_notif, + office_module_DeanS_notif, + gymkhana_voting, + gymkhana_session, + gymkhana_event, + AssistantshipClaim_notify, + AssistantshipClaim_faculty_notify, + AssistantshipClaim_acad_notify, + AssistantshipClaim_account_notify, + department_notif, + office_module_DeanRSPC_notif, + research_procedures_notif) + + + +class LeaveModuleNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + date = request.data.get('date') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + leave_module_notif(sender, recipient, type, date) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class PlacementCellNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + placement_cell_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class AcademicsModuleNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + academics_module_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class OfficeModuleNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + office_module_notif(sender, recipient) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) +class CentralMessNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + message = request.data.get('message') + + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + + # Trigger the notification function + central_mess_notif(sender, recipient, type, message) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class VisitorsHostelNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + visitors_hostel_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class HealthcareCenterNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + + # Trigger the notification function + healthcare_center_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class FileTrackingNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + title = request.data.get('title') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + file_tracking_notif(sender, recipient, title) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) +class ScholarshipPortalNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + scholarship_portal_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class ComplaintSystemNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + complaint_id = request.data.get('complaint_id') + student = request.data.get('student') + message = request.data.get('message') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + complaint_system_notif(sender, recipient, type, complaint_id, student, message) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class OfficeDeanPnDNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + office_dean_PnD_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class OfficeDeanSNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + office_module_DeanS_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class GymkhanaVotingNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + title = request.data.get('title') + desc = request.data.get('desc') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + gymkhana_voting(sender, recipient, type, title, desc) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class GymkhanaSessionNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + club = request.data.get('club') + desc = request.data.get('desc') + venue = request.data.get('venue') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + gymkhana_session(sender, recipient, type, club, desc, venue) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class GymkhanaEventNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + club = request.data.get('club') + event_name = request.data.get('event_name') + desc = request.data.get('desc') + venue = request.data.get('venue') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + gymkhana_event(sender, recipient, type, club, event_name, desc, venue) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class AssistantshipClaimNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + month = request.data.get('month') + year = request.data.get('year') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + AssistantshipClaim_notify(sender, recipient, month, year) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) +class AssistantshipClaimFacultyNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + AssistantshipClaim_faculty_notify(sender, recipient) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class AssistantshipClaimAcadNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + AssistantshipClaim_acad_notify(sender, recipient) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class AssistantshipClaimAccountNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + stu = request.data.get('stu') + recipient_id = request.data.get('recipient') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + AssistantshipClaim_account_notify(sender, stu, recipient) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class DepartmentNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + department_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) +class OfficeDeanRSPCNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + office_module_DeanRSPC_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class ResearchProceduresNotificationAPIView(APIView): + def post(self, request, *args, **kwargs): + # Extract data from the request, you can customize this based on your needs + sender = request.user + recipient_id = request.data.get('recipient') + type = request.data.get('type') + User = get_user_model() + recipient = User.objects.get(pk=recipient_id) + # Trigger the notification function + research_procedures_notif(sender, recipient, type) + + return Response({'message': 'Notification sent successfully'}, status=status.HTTP_201_CREATED) + +class MarkAsRead(APIView): + + def put(self,request,**args): + notification_id = self.request.query_params.get('id') + notification = get_object_or_404( + Notification, recipient=request.user, id=notification_id) + + notification.mark_as_read() + + return Response({'message': "Successfully marked as read"}, status=status.HTTP_200_OK) + +class Delete(APIView): + + def delete(self,request, **args): + notification_id = self.request.query_params.get('id') + notification = get_object_or_404( + Notification, recipient=request.user, id=notification_id) + + notification.delete() + + return Response({'message': "Notification deleted succesfully"}, status=status.HTTP_200_OK) + +class NotificationsList(ListAPIView): + # queryset = Notification.objects.all(actor_object_id=) + serializer_class = NotificationSerializer + def get_queryset(self): + return Notification.objects.all().filter(recipient_id=self.request.user.id) \ No newline at end of file diff --git a/FusionIIIT/applications/notifications_extension/urls.py b/FusionIIIT/applications/notifications_extension/urls.py index c5b2da49d..b5690994b 100644 --- a/FusionIIIT/applications/notifications_extension/urls.py +++ b/FusionIIIT/applications/notifications_extension/urls.py @@ -4,8 +4,12 @@ from django.conf.urls import include, url from . import views +# from .api import urls + app_name = 'notifications' urlpatterns = [ pattern(r'^mark-as-read-and-redirect/(?P\d+)/$', views.mark_as_read_and_redirect, name='mark_as_read_and_redirect'), + pattern(r'^delete/(?P\d+)/$', views.delete, name='delete'), + url(r'^api/',include('applications.notifications_extension.api.urls')), ] + urlpatterns diff --git a/FusionIIIT/applications/notifications_extension/views.py b/FusionIIIT/applications/notifications_extension/views.py index fc482ef77..59a37547a 100644 --- a/FusionIIIT/applications/notifications_extension/views.py +++ b/FusionIIIT/applications/notifications_extension/views.py @@ -3,9 +3,16 @@ from notifications.utils import id2slug, slug2id from django.shortcuts import get_object_or_404, redirect from notifications.models import Notification - - - +import Fusion.settings as FusionIIIT_settings +def delete(request, slug=None): + notification_id = slug2id(slug) + notification = get_object_or_404( + Notification, recipient=request.user, id=notification_id) + notification.delete() + previous_page = request.META.get('HTTP_REFERER', '/') + # Redirect to the previous page or the home page if the referrer is not available + return HttpResponseRedirect(previous_page) + # return HttpResponseRedirect('dashboard/') def mark_as_read_and_redirect(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404( @@ -14,8 +21,9 @@ def mark_as_read_and_redirect(request, slug=None): # This conditional statement is True only in # case of complaint_module. + # return redirect('notifications:all') - if(notification.data['module'] == 'Complaint System'): + if(notification.data['module'] == 'Complaint System'): complaint_id=notification.description return HttpResponseRedirect(reverse(notification.data['url'],kwargs={'detailcomp_id1':complaint_id})) else: diff --git a/FusionIIIT/applications/office_module/migrations/0001_initial.py b/FusionIIIT/applications/office_module/migrations/0001_initial.py index 521c8e886..c488a504c 100644 --- a/FusionIIIT/applications/office_module/migrations/0001_initial.py +++ b/FusionIIIT/applications/office_module/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.db import migrations, models @@ -10,10 +10,10 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('academic_information', '0001_initial'), ('filetracking', '0001_initial'), - ('leave', '0001_initial'), ('globals', '0001_initial'), + ('academic_information', '0001_initial'), + ('leave', '0001_initial'), ] operations = [ diff --git a/FusionIIIT/applications/online_cms/migrations/0001_initial.py b/FusionIIIT/applications/online_cms/migrations/0001_initial.py index 4e3377ab7..2990b152b 100644 --- a/FusionIIIT/applications/online_cms/migrations/0001_initial.py +++ b/FusionIIIT/applications/online_cms/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.db import migrations, models import django.db.models.deletion @@ -9,8 +9,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('academic_information', '0001_initial'), ('globals', '0001_initial'), + ('academic_information', '0001_initial'), ] operations = [ diff --git a/FusionIIIT/applications/placement_cell/migrations/0001_initial.py b/FusionIIIT/applications/placement_cell/migrations/0001_initial.py index 257c98609..95f070aef 100644 --- a/FusionIIIT/applications/placement_cell/migrations/0001_initial.py +++ b/FusionIIIT/applications/placement_cell/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.db import migrations, models diff --git a/FusionIIIT/applications/programme_curriculum/migrations/0001_initial.py b/FusionIIIT/applications/programme_curriculum/migrations/0001_initial.py index b01ec58a7..bb794c796 100644 --- a/FusionIIIT/applications/programme_curriculum/migrations/0001_initial.py +++ b/FusionIIIT/applications/programme_curriculum/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 +import django.core.validators from django.db import migrations, models import django.db.models.deletion @@ -18,7 +19,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=100)), - ('version', models.PositiveIntegerField(default=1)), + ('version', models.DecimalField(decimal_places=1, default=1.0, max_digits=2, validators=[django.core.validators.MinValueValidator(1.0), django.core.validators.DecimalValidator(decimal_places=1, max_digits=2)])), ('working_curriculum', models.BooleanField(default=True)), ('no_of_semester', models.PositiveIntegerField(default=1)), ('min_credit', models.PositiveIntegerField(default=0)), @@ -30,7 +31,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('category', models.CharField(choices=[('UG', 'Undergraduate'), ('PG', 'Postgraduate'), ('PHD', 'Doctor of Philosophy')], max_length=3)), ('name', models.CharField(max_length=70, unique=True)), - ('programme_begin_year', models.PositiveIntegerField(default=2023)), + ('programme_begin_year', models.PositiveIntegerField(default=2024)), ], ), migrations.CreateModel( @@ -66,8 +67,9 @@ class Migration(migrations.Migration): name='Course', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('code', models.CharField(max_length=10, unique=True)), - ('name', models.CharField(max_length=100, unique=True)), + ('code', models.CharField(max_length=10)), + ('name', models.CharField(max_length=100)), + ('version', models.DecimalField(decimal_places=1, default=1.0, max_digits=5, validators=[django.core.validators.MinValueValidator(1.0), django.core.validators.DecimalValidator(decimal_places=1, max_digits=5)])), ('credit', models.PositiveIntegerField(default=0)), ('lecture_hours', models.PositiveIntegerField(null=True)), ('tutorial_hours', models.PositiveIntegerField(null=True)), @@ -85,11 +87,12 @@ class Migration(migrations.Migration): ('percent_course_attendance', models.PositiveIntegerField(default=5)), ('ref_books', models.TextField()), ('working_course', models.BooleanField(default=True)), + ('latest_version', models.BooleanField(default=True)), ('disciplines', models.ManyToManyField(blank=True, to='programme_curriculum.Discipline')), ('pre_requisit_courses', models.ManyToManyField(blank=True, related_name='_course_pre_requisit_courses_+', to='programme_curriculum.Course')), ], options={ - 'unique_together': {('code', 'name')}, + 'unique_together': {('code', 'version')}, }, ), migrations.CreateModel( @@ -97,7 +100,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(choices=[('B.Tech', 'B.Tech'), ('M.Tech', 'M.Tech'), ('B.Des', 'B.Des'), ('M.Des', 'M.Des'), ('Phd', 'Phd')], max_length=50)), - ('year', models.PositiveIntegerField(default=2023)), + ('year', models.PositiveIntegerField(default=2024)), ('running_batch', models.BooleanField(default=True)), ('curriculum', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='programme_curriculum.curriculum')), ('discipline', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='programme_curriculum.discipline')), @@ -106,6 +109,39 @@ class Migration(migrations.Migration): 'unique_together': {('name', 'discipline', 'year')}, }, ), + migrations.CreateModel( + name='UpdateCourseProposal', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('faculty_name', models.CharField(max_length=100)), + ('faculty_code', models.CharField(max_length=10)), + ('code', models.CharField(max_length=10)), + ('name', models.CharField(max_length=100)), + ('credit', models.PositiveIntegerField(default=0)), + ('lecture_hours', models.PositiveIntegerField(null=True)), + ('tutorial_hours', models.PositiveIntegerField(null=True)), + ('pratical_hours', models.PositiveIntegerField(null=True)), + ('discussion_hours', models.PositiveIntegerField(null=True)), + ('project_hours', models.PositiveIntegerField(null=True)), + ('pre_requisits', models.TextField(blank=True, null=True)), + ('syllabus', models.TextField()), + ('percent_quiz_1', models.PositiveIntegerField(default=10)), + ('percent_midsem', models.PositiveIntegerField(default=20)), + ('percent_quiz_2', models.PositiveIntegerField(default=10)), + ('percent_endsem', models.PositiveIntegerField(default=30)), + ('percent_project', models.PositiveIntegerField(default=15)), + ('percent_lab_evaluation', models.PositiveIntegerField(default=10)), + ('percent_course_attendance', models.PositiveIntegerField(default=5)), + ('ref_books', models.TextField()), + ('working_course', models.BooleanField(default=True)), + ('status', models.PositiveIntegerField(default=0)), + ('disciplines', models.ManyToManyField(blank=True, to='programme_curriculum.Discipline')), + ('pre_requisit_courses', models.ManyToManyField(blank=True, to='programme_curriculum.Course')), + ], + options={ + 'unique_together': {('code', 'faculty_code')}, + }, + ), migrations.AlterUniqueTogether( name='curriculum', unique_together={('name', 'version')}, @@ -115,7 +151,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=100)), - ('type', models.CharField(choices=[('Professional Core', 'Professional Core'), ('Professional Elective', 'Professional Elective'), ('Professional Lab', 'Professional Lab'), ('Engineering Science', 'Engineering Science'), ('Natural Science', 'Natural Science'), ('Humanities', 'Humanities'), ('Design', 'Design'), ('Manufacturing', 'Manufacturing'), ('Management Science', 'Management Science'), ('Optional Elective', 'Optional Elective'), ('Project', 'Project'), ('Optional', 'Optional'), ('Others', 'Others')], max_length=70)), + ('type', models.CharField(choices=[('Professional Core', 'Professional Core'), ('Professional Elective', 'Professional Elective'), ('Professional Lab', 'Professional Lab'), ('Engineering Science', 'Engineering Science'), ('Natural Science', 'Natural Science'), ('Humanities', 'Humanities'), ('Design', 'Design'), ('Manufacturing', 'Manufacturing'), ('Management Science', 'Management Science'), ('Open Elective', 'Open Elective'), ('Swayam', 'Swayam'), ('Project', 'Project'), ('Optional', 'Optional'), ('Others', 'Others')], max_length=70)), ('course_slot_info', models.TextField(null=True)), ('duration', models.PositiveIntegerField(default=1)), ('min_registration_limit', models.PositiveIntegerField(default=0)), @@ -127,6 +163,38 @@ class Migration(migrations.Migration): 'unique_together': {('semester', 'name', 'type')}, }, ), + migrations.CreateModel( + name='CourseProposal', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('faculty_name', models.CharField(max_length=100)), + ('faculty_code', models.CharField(max_length=10)), + ('code', models.CharField(max_length=10)), + ('name', models.CharField(max_length=100)), + ('credit', models.PositiveIntegerField(default=3)), + ('lecture_hours', models.PositiveIntegerField(default=3, null=True)), + ('tutorial_hours', models.PositiveIntegerField(default=0, null=True)), + ('pratical_hours', models.PositiveIntegerField(default=0, null=True)), + ('discussion_hours', models.PositiveIntegerField(default=0, null=True)), + ('project_hours', models.PositiveIntegerField(default=0, null=True)), + ('pre_requisits', models.TextField(blank=True, null=True)), + ('syllabus', models.TextField()), + ('percent_quiz_1', models.PositiveIntegerField(default=10)), + ('percent_midsem', models.PositiveIntegerField(default=20)), + ('percent_quiz_2', models.PositiveIntegerField(default=10)), + ('percent_endsem', models.PositiveIntegerField(default=30)), + ('percent_project', models.PositiveIntegerField(default=15)), + ('percent_lab_evaluation', models.PositiveIntegerField(default=10)), + ('percent_course_attendance', models.PositiveIntegerField(default=5)), + ('ref_books', models.TextField()), + ('status', models.PositiveIntegerField(default=0)), + ('disciplines', models.ManyToManyField(blank=True, to='programme_curriculum.Discipline')), + ('pre_requisit_courses', models.ManyToManyField(blank=True, to='programme_curriculum.Course')), + ], + options={ + 'unique_together': {('code', 'faculty_code')}, + }, + ), migrations.CreateModel( name='CourseInstructor', fields=[ diff --git a/FusionIIIT/applications/programme_curriculum/models.py b/FusionIIIT/applications/programme_curriculum/models.py index fec405b5a..86f67c708 100644 --- a/FusionIIIT/applications/programme_curriculum/models.py +++ b/FusionIIIT/applications/programme_curriculum/models.py @@ -32,7 +32,7 @@ ('Manufacturing', 'Manufacturing'), ('Management Science', 'Management Science'), ('Open Elective', 'Open Elective'), - ('Swayam','Swayam'), + ('Swayam', 'Swayam'), ('Project', 'Project'), ('Optional', 'Optional'), ('Others', 'Others') @@ -41,16 +41,17 @@ BATCH_NAMES = [ ('B.Tech', 'B.Tech'), ('M.Tech', 'M.Tech'), - ('B.Des','B.Des'), - ('M.Des','M.Des'), + ('B.Des', 'B.Des'), + ('M.Des', 'M.Des'), ('Phd', 'Phd') ] + class Programme(models.Model): ''' Current Purpose : To store the details regardina a programme - - + + ATTRIBUTES : @@ -61,12 +62,15 @@ class Programme(models.Model): ! - the name attribute has ambiguous entries ''' - category = models.CharField(max_length=3, choices=PROGRAMME_CATEGORY_CHOICES, null=False, blank=False) - name = models.CharField(max_length=70, null=False, unique=True, blank=False) - programme_begin_year = models.PositiveIntegerField(default=datetime.date.today().year, null=False) + category = models.CharField( + max_length=3, choices=PROGRAMME_CATEGORY_CHOICES, null=False, blank=False) + name = models.CharField(max_length=70, null=False, + unique=True, blank=False) + programme_begin_year = models.PositiveIntegerField( + default=datetime.date.today().year, null=False) def __str__(self): - return str(self.category + " - "+ self.name) + return str(self.category + " - " + self.name) @property def curriculums(self): @@ -80,8 +84,8 @@ def get_discipline_objects(self): class Discipline(models.Model): ''' Current Purpose : To store the details regarding a discipline - - + + ATTRIBUTES : @@ -91,26 +95,27 @@ class Discipline(models.Model): ''' + name = models.CharField(max_length=100, null=False, + unique=True, blank=False) + acronym = models.CharField( + max_length=10, null=False, default="", blank=False) + programmes = models.ManyToManyField(Programme, blank=True) - name = models.CharField(max_length=100, null=False, unique=True, blank=False) - acronym = models.CharField(max_length=10, null=False, default="", blank=False) - programmes = models.ManyToManyField(Programme, blank=True) - def __str__(self): return str(self.name) + " " + str(self.acronym) @property def batches(self): return Batch.objects.filter(discipline=self.id).order_by('year') - + class Curriculum(models.Model): ''' Current Purpose : To store the details regarding a curriculum Curriculum definition : a set of all courses offered by the institute within a programme - - + + ATTRIBUTES : @@ -121,7 +126,8 @@ class Curriculum(models.Model): no_of_semester(Integer) - the number of semesters defined for the curriculum min_credit(Integer) - the minimum credits required for the curriculum ''' - programme = models.ForeignKey(Programme, on_delete=models.CASCADE, null=False) + programme = models.ForeignKey( + Programme, on_delete=models.CASCADE, null=False) name = models.CharField(max_length=100, null=False, blank=False) # version = models.FloatField(default=1.0, null=False) # version = models.PositiveIntegerField(default=1, null=False) @@ -138,7 +144,7 @@ class Curriculum(models.Model): class Meta: unique_together = ('name', 'version',) - + def __str__(self): return str(self.name + " v" + str(self.version)) @@ -146,20 +152,18 @@ def __str__(self): def batches(self): return Batch.objects.filter(curriculum=self.id).order_by('year') - @property def semesters(self): return Semester.objects.filter(curriculum=self.id).order_by('semester_no') - class Semester(models.Model): ''' Current Purpose : To store the details regarding a semester - - - + + + ATTRIBUTES : @@ -170,7 +174,8 @@ class Semester(models.Model): end_semester(DateTime) - to store the end date of the semester ''' - curriculum = models.ForeignKey(Curriculum, null=False, on_delete=models.CASCADE) + curriculum = models.ForeignKey( + Curriculum, null=False, on_delete=models.CASCADE) semester_no = models.PositiveIntegerField(null=False) instigate_semester = models.BooleanField(default=False, null=True) start_semester = models.DateField(blank=True, null=True) @@ -179,7 +184,7 @@ class Semester(models.Model): class Meta: unique_together = ('curriculum', 'semester_no',) - + def __str__(self): return str(Curriculum.__str__(self.curriculum) + ", sem-" + str(self.semester_no)) @@ -187,13 +192,14 @@ def __str__(self): def courseslots(self): return CourseSlot.objects.filter(semester=self.id).order_by("id") + class Course(models.Model): ''' Current Purpose : To store the details regarding a course - - - + + + ATTRIBUTES : @@ -224,10 +230,10 @@ class Course(models.Model): code = models.CharField(max_length=10, null=False, blank=False) name = models.CharField(max_length=100, null=False, blank=False) version = models.DecimalField( - max_digits=5, - decimal_places=1, - default=1.0, - validators=[MinValueValidator(1.0), DecimalValidator(max_digits=5, decimal_places=1)]) + max_digits=5, + decimal_places=1, + default=1.0, + validators=[MinValueValidator(1.0), DecimalValidator(max_digits=5, decimal_places=1)]) credit = models.PositiveIntegerField(default=0, null=False, blank=False) lecture_hours = PositiveIntegerField(null=True, ) tutorial_hours = PositiveIntegerField(null=True) @@ -237,39 +243,44 @@ class Course(models.Model): pre_requisits = models.TextField(null=True, blank=True) pre_requisit_courses = models.ManyToManyField('self', blank=True) syllabus = models.TextField() - percent_quiz_1 = models.PositiveIntegerField(default=10, null=False, blank=False) - percent_midsem = models.PositiveIntegerField(default=20, null=False, blank=False) - percent_quiz_2 = models.PositiveIntegerField(default=10, null=False, blank=False) - percent_endsem = models.PositiveIntegerField(default=30, null=False, blank=False) - percent_project = models.PositiveIntegerField(default=15, null=False, blank=False) - percent_lab_evaluation = models.PositiveIntegerField(default=10, null=False, blank=False) - percent_course_attendance = models.PositiveIntegerField(default=5, null=False, blank=False) + percent_quiz_1 = models.PositiveIntegerField( + default=10, null=False, blank=False) + percent_midsem = models.PositiveIntegerField( + default=20, null=False, blank=False) + percent_quiz_2 = models.PositiveIntegerField( + default=10, null=False, blank=False) + percent_endsem = models.PositiveIntegerField( + default=30, null=False, blank=False) + percent_project = models.PositiveIntegerField( + default=15, null=False, blank=False) + percent_lab_evaluation = models.PositiveIntegerField( + default=10, null=False, blank=False) + percent_course_attendance = models.PositiveIntegerField( + default=5, null=False, blank=False) ref_books = models.TextField() working_course = models.BooleanField(default=True) disciplines = models.ManyToManyField(Discipline, blank=True) latest_version = models.BooleanField(default=True) - + class Meta: - unique_together = ('code','version') - - def __str__(self): - return str(self.code + " - " +self.name+"- v"+str(self.version)) + unique_together = ('code', 'version') + def __str__(self): + return str(self.code + " - " + self.name+"- v"+str(self.version)) @property def courseslots(self): return CourseSlot.objects.filter(courses=self.id) -class Batch(models.Model): - +class Batch(models.Model): ''' Current Purpose : To store the details regarding a batch(eg details of curriculum assigned for batch) - - - + + + ATTRIBUTES : @@ -280,10 +291,14 @@ class Batch(models.Model): running_batch(Boolean) - to denote whether the batch is currently active or has graduated ''' - name = models.CharField(choices=BATCH_NAMES, max_length=50, null=False, blank=False) - discipline = models.ForeignKey(Discipline, null=False, on_delete=models.CASCADE) - year = models.PositiveIntegerField(default=datetime.date.today().year, null=False) - curriculum = models.ForeignKey(Curriculum, null=True, blank=True, on_delete=models.SET_NULL) + name = models.CharField(choices=BATCH_NAMES, + max_length=50, null=False, blank=False) + discipline = models.ForeignKey( + Discipline, null=False, on_delete=models.CASCADE) + year = models.PositiveIntegerField( + default=datetime.date.today().year, null=False) + curriculum = models.ForeignKey( + Curriculum, null=True, blank=True, on_delete=models.SET_NULL) running_batch = models.BooleanField(default=True) class Meta: @@ -292,7 +307,7 @@ class Meta: def __str__(self): return str(self.name) + " " + str(self.discipline.acronym) + " " + str(self.year) - + class CourseSlot(models.Model): ''' Current Purpose : To store the details regarding a course slot @@ -310,15 +325,16 @@ class CourseSlot(models.Model): maximum_registration_limit(integer) - maximum students required for a course ''' - semester = models.ForeignKey(Semester, null=False, on_delete=models.CASCADE) + semester = models.ForeignKey( + Semester, null=False, on_delete=models.CASCADE) name = models.CharField(max_length=100, null=False, blank=False) - type = models.CharField(max_length=70, choices=COURSESLOT_TYPE_CHOICES, null=False) + type = models.CharField( + max_length=70, choices=COURSESLOT_TYPE_CHOICES, null=False) course_slot_info = models.TextField(null=True) courses = models.ManyToManyField(Course, blank=True) duration = models.PositiveIntegerField(default=1) - min_registration_limit = models.PositiveIntegerField(default = 0) - max_registration_limit = models.PositiveIntegerField(default = 1000) - + min_registration_limit = models.PositiveIntegerField(default=0) + max_registration_limit = models.PositiveIntegerField(default=1000) def __str__(self): return str(Semester.__str__(self.semester) + ", " + self.name) @@ -330,20 +346,15 @@ class Meta: def for_batches(self): return ((Semester.objects.get(id=self.semester.id)).curriculum).batches -class CourseInstructor(models.Model): - course_id = models.ForeignKey(Course, on_delete = models.CASCADE) - instructor_id = models.ForeignKey(ExtraInfo, on_delete = models.CASCADE) - batch_id = models.ForeignKey(Batch, on_delete=models.CASCADE, default=1) - #change extra info to faculty(globals) - - class Meta: - unique_together = ('course_id', 'instructor_id', 'batch_id') - +class CourseInstructor(models.Model): + course_id = models.ForeignKey(Course, on_delete=models.CASCADE) + instructor_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE) + batch_id = models.ForeignKey(Batch, on_delete=models.CASCADE, default=1) + # change extra info to faculty(globals) - def __self__(self): - return '{} - {}'.format(self.course_id, self.instructor_id) - + class Meta: + unique_together = ('course_id', 'instructor_id', 'batch_id') #new class NewProposalFile(models.Model): @@ -351,23 +362,30 @@ class NewProposalFile(models.Model): uploader = models.CharField(max_length=100, null=False, blank=False) designation = models.CharField(max_length=100, null=False, blank=False) code = models.CharField(max_length=10, null=False, blank=False) - name = models.CharField(max_length=100, null=False,blank=False) + name = models.CharField(max_length=100, null=False, blank=False) credit = models.PositiveIntegerField(default=3, null=False, blank=False) - lecture_hours = PositiveIntegerField(default=3,null=True, ) - tutorial_hours = PositiveIntegerField(default=0,null=True) - pratical_hours = PositiveIntegerField(default=0,null=True) - discussion_hours = PositiveIntegerField(default=0,null=True) - project_hours = PositiveIntegerField(default=0,null=True) + lecture_hours = PositiveIntegerField(default=3, null=True, ) + tutorial_hours = PositiveIntegerField(default=0, null=True) + pratical_hours = PositiveIntegerField(default=0, null=True) + discussion_hours = PositiveIntegerField(default=0, null=True) + project_hours = PositiveIntegerField(default=0, null=True) pre_requisits = models.TextField(null=True, blank=True) pre_requisit_courses = models.ManyToManyField(Course, blank=True) syllabus = models.TextField() - percent_quiz_1 = models.PositiveIntegerField(default=10, null=False, blank=False) - percent_midsem = models.PositiveIntegerField(default=20, null=False, blank=False) - percent_quiz_2 = models.PositiveIntegerField(default=10, null=False, blank=False) - percent_endsem = models.PositiveIntegerField(default=30, null=False, blank=False) - percent_project = models.PositiveIntegerField(default=15, null=False, blank=False) - percent_lab_evaluation = models.PositiveIntegerField(default=10, null=False, blank=False) - percent_course_attendance = models.PositiveIntegerField(default=5, null=False, blank=False) + percent_quiz_1 = models.PositiveIntegerField( + default=10, null=False, blank=False) + percent_midsem = models.PositiveIntegerField( + default=20, null=False, blank=False) + percent_quiz_2 = models.PositiveIntegerField( + default=10, null=False, blank=False) + percent_endsem = models.PositiveIntegerField( + default=30, null=False, blank=False) + percent_project = models.PositiveIntegerField( + default=15, null=False, blank=False) + percent_lab_evaluation = models.PositiveIntegerField( + default=10, null=False, blank=False) + percent_course_attendance = models.PositiveIntegerField( + default=5, null=False, blank=False) ref_books = models.TextField() subject = models.CharField(max_length=100, null=True, blank=True) description = models.CharField(max_length=400, null=True, blank=True) diff --git a/FusionIIIT/applications/ps1/__init__.py b/FusionIIIT/applications/ps1/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/FusionIIIT/applications/ps1/admin.py b/FusionIIIT/applications/ps1/admin.py index 8dd0ad5ee..ec612790d 100644 --- a/FusionIIIT/applications/ps1/admin.py +++ b/FusionIIIT/applications/ps1/admin.py @@ -2,6 +2,8 @@ # Register your models here. -from applications.ps1.models import StockEntry,IndentFile +from applications.ps1.models import StockEntry,IndentFile,StockItem,StockTransfer admin.site.register(StockEntry) -admin.site.register(IndentFile) \ No newline at end of file +admin.site.register(IndentFile) +admin.site.register(StockItem) +admin.site.register(StockTransfer) \ No newline at end of file diff --git a/FusionIIIT/applications/ps1/api/serializers.py b/FusionIIIT/applications/ps1/api/serializers.py new file mode 100644 index 000000000..bdd05635c --- /dev/null +++ b/FusionIIIT/applications/ps1/api/serializers.py @@ -0,0 +1,45 @@ +from rest_framework import serializers #type:ignore +from applications.ps1.models import IndentFile, File ,StockEntry,StockItem,StockTransfer +from applications.globals.models import ExtraInfo, HoldsDesignation +from applications.filetracking.models import Tracking + +class FileSerializer(serializers.ModelSerializer): + class Meta: + model = File + fields = '__all__' + +class IndentFileSerializer(serializers.ModelSerializer): + class Meta: + model = IndentFile + fields = '__all__' + +class ExtraInfoSerializer(serializers.ModelSerializer): + class Meta: + model = ExtraInfo + fields = '__all__' + +class HoldsDesignationSerializer(serializers.ModelSerializer): + class Meta: + model = HoldsDesignation + fields = '__all__' + +class TrackingSerializer(serializers.ModelSerializer): + class Meta: + model = Tracking + fields = '__all__' + +class StockEntrySerializer(serializers.ModelSerializer): + class Meta: + model = StockEntry + fields = '__all__' + +class StockItemSerializer(serializers.ModelSerializer): + class Meta: + model = StockItem + fields = '__all__' + +class StockTransferSerializer(serializers.ModelSerializer): + class Meta: + model = StockTransfer + fields = '__all__' + diff --git a/FusionIIIT/applications/ps1/api/urls.py b/FusionIIIT/applications/ps1/api/urls.py new file mode 100644 index 000000000..df8ec1719 --- /dev/null +++ b/FusionIIIT/applications/ps1/api/urls.py @@ -0,0 +1,53 @@ +from django.conf.urls import url + +from . import views + +urlpatterns = [ + # to create a new indent file + url(r'^create_proposal/', views.createProposal, name='create-proposal'), + + # PENDING : TO CREATE A INDENT FILE DRAFT + + # GET DESIGNATIONS USING USER TOKEN + url(r'^getDesignations/', views.getDesignations, name='get-designations'), + + # to get the indent files created by the user + url(r'^indentview/(?P\d+)$', views.indentView, name='indent-view'), + + # to get the indent Files drafts by a user + url(r'^draftview/(?P\d+)$', views.draftView, name='draft-view'), + + # to get all the indent files inwarded to the user 'id' is holdsDesignation id. + url(r'^inwardIndents/(?P\d+)$', views.inwardIndents, name='inward-indents'), + + # to see the details of a specifc indent file + url(r'^indentFile/(?P\d+)$', views.indentFile, name='indent-file'), + + # to forward a indent File + url(r'^indentFile/forward/(?P\d+)$', views.ForwardIndentFile, name='forward-indent-file'), + + # STOCKS API + # to return all the indent files (GET) as well as to get the information of any specific indent file (POST) to further add stock to it (just info). + url(r'^entry/(?P\d+)$', views.entry, name='entry'), + + # To add stock corresponding to a Indent File + url(r'^stockEntry/(?P\d+)$', views.stockEntry, name='stock-entry'), + + # To view all the stock entry details + url(r'^stock_entry_view/(?P\d+)$', views.stockEntryView, name='stock-entry-view'), + + + # To view the current_stock_view based on filters + url(r'^current_stock_view/(?P\d+)$', views.currentStockView, name='current-stock-view'), + + # to view all the items present in any stock entry + url(r'^stock_entry_item_view/(?P\d+)$', views.stock_entry_item_view, name='stock-entry-item-view'), + + # to delete any stock entry + url(r'^stock_item_delete/(?P\d+)$', views.stockDelete, name='stock-delete'), + + url(r'^stock_transfer/(?P\d+)$', views.stockTransfer, name='stock-transfer'), + + + url(r'^perform_transfer/(?P\d+)$', views.performTransfer, name='perform-transfer'), +] diff --git a/FusionIIIT/applications/ps1/api/views.py b/FusionIIIT/applications/ps1/api/views.py new file mode 100644 index 000000000..37d6546e4 --- /dev/null +++ b/FusionIIIT/applications/ps1/api/views.py @@ -0,0 +1,619 @@ +from rest_framework.permissions import IsAuthenticated #type:ignore +from rest_framework.response import Response #type:ignore +from rest_framework import status #type:ignore +from rest_framework.decorators import api_view, permission_classes #type:ignore +from applications.ps1.models import IndentFile, File,StockTransfer,StockEntry,StockItem +from applications.globals.models import HoldsDesignation, Designation,ExtraInfo,DepartmentInfo +from applications.filetracking.models import Tracking +from .serializers import IndentFileSerializer ,FileSerializer,ExtraInfoSerializer,HoldsDesignationSerializer,TrackingSerializer,StockEntrySerializer,StockItemSerializer,StockTransferSerializer +from django.utils import timezone +from applications.filetracking.sdk.methods import * +from datetime import datetime +from django.http import HttpResponseForbidden +from django.db.models import Q,Count +from django.shortcuts import get_object_or_404 +from django.http import HttpResponse +import ast + +dept_admin_to_dept = { + "deptadmin_cse": "CSE", + "deptadmin_ece": "ECE", + "deptadmin_me": "ME", + "deptadmin_sm": "SM", + "deptadmin_design": "Design", + "deptadmin_liberalarts": "Liberal Arts", + "deptadmin_ns": "Natural Science", +} + +dept_admin_design = ["deptadmin_cse", "deptadmin_ece", "deptadmin_me","deptadmin_sm", "deptadmin_design", "deptadmin_liberalarts","deptadmin_ns" ] + + +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def getDesignations(request): + if request.method == 'GET': + designations = HoldsDesignation.objects.filter(user=request.user) + designations_serialized = HoldsDesignationSerializer(designations,many=True) + return Response(designations_serialized.data) + else: + return Response({"message": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED) + + + +@api_view(['POST']) +@permission_classes([IsAuthenticated]) +def createProposal(request): + if request.method == 'POST': + # print('our requested data :',request.data) + # Process the POST request data + uploader = request.user.extrainfo + subject = request.data.get('title') + description = request.data.get('desc') + design = request.data.get('design') + designation = Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=design).designation_id) + upload_file = request.FILES.get('myfile') + item_name = request.data.get('item_name') + grade = request.data.get('grade') + quantity = request.data.get('quantity') + present_stock = request.data.get('present_stock') + estimated_cost = request.data.get('estimated_cost') + purpose = request.data.get('purpose') + specification = request.data.get('specification') + item_type = request.data.get('item_type') + nature = request.data.get('nature') + indigenous = request.data.get('indigenous') + replaced = request.data.get('replaced') + budgetary_head = request.data.get('budgetary_head') + expected_delivery = request.data.get('expected_delivery') + sources_of_supply = request.data.get('sources_of_supply') + head_approval = False + director_approval = False + financial_approval = False + purchased = False + + # Create File object + file = File.objects.create( + uploader=uploader, + description=description, + subject=subject, + designation=designation, + upload_file=upload_file + ) + + # Create IndentFile object + indent_file = IndentFile.objects.create( + file_info=file, + item_name=item_name, + quantity=quantity, + present_stock=present_stock, + estimated_cost=estimated_cost, + purpose=purpose, + specification=specification, + grade=grade, + item_type=item_type, + nature=nature, + indigenous=indigenous, + replaced=replaced, + budgetary_head=budgetary_head, + expected_delivery=expected_delivery, + sources_of_supply=sources_of_supply, + head_approval=head_approval, + director_approval=director_approval, + financial_approval=financial_approval, + purchased=purchased, + ) + + # Serialize response data + file_serializer = FileSerializer(file) + indent_file_serializer = IndentFileSerializer(indent_file) + + # Return response + return Response({ + 'file': file_serializer.data, + 'indent_file': indent_file_serializer.data, + 'message': 'Indent Filed Successfully!' + }) + + +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def indentView(request, id): + if request.method == 'GET': + tracking_objects = Tracking.objects.all() + tracking_obj_ids = [obj.file_id for obj in tracking_objects] + draft_indent = IndentFile.objects.filter(file_info__in=tracking_obj_ids) + draft = [indent.file_info.id for indent in draft_indent] + draft_files = File.objects.filter(id__in=draft).order_by('-upload_date') + indents = [file.indentfile for file in draft_files] + abcd = HoldsDesignation.objects.get(pk=id) + s = str(abcd).split(" - ") + + serializer = IndentFileSerializer(indents, many=True) + return Response(serializer.data) + else: + return Response({"message": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED) + + +# TO GET ALL THE USER DRAFTS USING HOLDS DESIGNATION ID +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def draftView(request, id): + if request.method == 'GET': + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + if designation == "student": + return Response({"message": "Unauthorized"}, status=status.HTTP_401_UNAUTHORIZED) + + indents = IndentFile.objects.filter(file_info__in=request.user.extrainfo.uploaded_files.all()).select_related('file_info') + indent_ids = [indent.file_info for indent in indents] + filed_indents = Tracking.objects.filter(file_id__in=indent_ids) + filed_indent_ids = [indent.file_id for indent in filed_indents] + draft = list(set(indent_ids) - set(filed_indent_ids)) + draft_indent = IndentFile.objects.filter(file_info__in=draft).values("file_info") + draft_files = File.objects.filter(id__in=draft_indent).order_by('-upload_date') + abcd = HoldsDesignation.objects.get(pk=id) + s = str(abcd).split(" - ") + serializer = FileSerializer(draft_files, many=True) + return Response(serializer.data) + else: + return Response({"message": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED) + + +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def inwardIndents(request, id): + if request.method == 'GET': + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + abcd = HoldsDesignation.objects.get(pk=id) + + data = view_inbox(request.user.username, designation, "ps1") + # outboxd = view_outbox(request.user.username, designations, "ps1") + + data = sorted(data, key=lambda x: datetime.fromisoformat(x['upload_date']), reverse=True) + for item in data: + item['upload_date'] = datetime.fromisoformat(item['upload_date']) + + response_data = { + 'receive_design': str(abcd), + 'in_file': data + } + + return Response(response_data) + else: + return Response({"message": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED) + + +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def indentFile(request, id): + if request.method == 'GET': + try: + indent_file = IndentFile.objects.select_related('file_info').get(file_info=id) + except IndentFile.DoesNotExist: + return Response({"message": "Indent file does not exist"}, status=status.HTTP_404_NOT_FOUND) + + # Retrieve tracking details for the indent file + track = Tracking.objects.select_related('file_id__uploader__user','file_id__uploader__department','file_id__designation','current_id__user','current_id__department','current_design__user','current_design__working','current_design__designation','receiver_id','receive_design').filter(file_id=indent_file.file_info) + + # Retrieve ExtraInfo, HoldsDesignation, and filtered designations + 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) + + + # Serialize the data + indent_serializer = IndentFileSerializer(indent_file) + track_serializer = TrackingSerializer(track, many=True) + extrainfo_serializer = ExtraInfoSerializer(extrainfo, many=True) + holdsdesignations_serializer = HoldsDesignationSerializer(holdsdesignations, many=True) + designations_serializer = HoldsDesignationSerializer(designations, many=True) + + # Construct response data + response_data = { + 'indent_file': indent_serializer.data, + 'track': track_serializer.data, + 'extrainfo': extrainfo_serializer.data, + 'holdsdesignations': holdsdesignations_serializer.data, + 'designations': designations_serializer.data + } + + return Response(response_data) + else: + return Response({"message": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED) + + + +# Forwarding Indent +@api_view(['POST']) +@permission_classes([IsAuthenticated]) +def ForwardIndentFile(request, id): + + if request.method == 'POST': + # print('hdfjaldfalk' , request.data); + try: + indent = IndentFile.objects.select_related('file_info').get(file_info=id) + file = indent.file_info + track = Tracking.objects.select_related('file_id__uploader__user','file_id__uploader__department','file_id__designation','current_id__user','current_id__department','current_design__user','current_design__working','current_design__designation','receiver_id','receive_design').filter(file_id=file) + except IndentFile.DoesNotExist: + return Response({"message": "Indent file does not exist"}, status=status.HTTP_404_NOT_FOUND) + + # Extracting data from request.POST + remarks = request.data.get('remarks') + sender_design_id = request.data.get('sender') + receiverHdid = request.data.get('receive') + upload_file = request.FILES.get('myfile') + + # Retrieving sender and receiver designations + sender_designationobj = HoldsDesignation.objects.get(id=sender_design_id).designation + sender_designation_name = sender_designationobj.name + receiverHdobj = HoldsDesignation.objects.get(id=receiverHdid) + receiver = receiverHdobj.user.username + receive_design = receiverHdobj.designation.name + + try: + receiver_id = User.objects.get(username=receiver) + except User.DoesNotExist: + return Response({"message": "Enter a valid destination"}, status=status.HTTP_400_BAD_REQUEST) + + try: + receive_design = Designation.objects.get(name=receive_design) + except Designation.DoesNotExist: + return Response({"message": "Enter a valid designation"}, status=status.HTTP_400_BAD_REQUEST) + + # Forwarding the file + forwarded_file_id = forward_file( + file_id=file.id, + receiver=receiver_id, + receiver_designation=receive_design, + file_extra_JSON={"key": 2}, + remarks=remarks, + file_attachment=upload_file + ) + + # Updating indent approvals if necessary + if (str(receive_design) in dept_admin_design): + indent.head_approval=True + elif (( + (sender_designation_name in dept_admin_design) + or + (sender_designation_name == "ps_admin") + ) + and (str(receive_design) == "Accounts Admin")): + indent.director_approval=True + indent.financial_approval=True + indent.head_approval=True + + indent.save() + + # Serializing the data + indent_serializer = IndentFileSerializer(indent) + track_serializer = TrackingSerializer(track, many=True) + + # Constructing response data + response_data = { + 'indent_file': indent_serializer.data, + 'track': track_serializer.data, + 'message': 'Indent File Forwarded successfully' + } + + return Response(response_data, status=status.HTTP_200_OK) + else: + return Response({"message": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED) + + +@api_view(['GET', 'POST']) +@permission_classes([IsAuthenticated]) +def entry(request,id): + + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + if request.method == 'GET': + + if designation not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + # Get department name + department = request.user.extrainfo.department.name + + # Filter indent files based on user's designation + if request.session.get('currentDesignationSelected') == "dept_admin": + indent_files = IndentFile.objects.filter(file_info__uploader__department__name=department) + else: + indent_files = IndentFile.objects.all() + + serializer = IndentFileSerializer(indent_files, many=True) + return Response(serializer.data) + + elif request.method == 'POST': + print(designation) + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + id = request.data.get('id') + if not id: + return Response({"message": "ID parameter is required"}, status=status.HTTP_400_BAD_REQUEST) + + try: + request_file = File.objects.select_related('uploader').get(id=id) + requester = request_file.uploader.user + # persons = ExtraInfo.objects.filter(user_type__in=["staff"]) + corresponding_indent_file = IndentFile.objects.get(file_info=request_file) + + serializer = { + 'request_file': FileSerializer(request_file).data, + 'requester': requester.username, + # 'persons': persons.values(), + 'corresponding_indent_file': IndentFileSerializer(corresponding_indent_file).data + } + return Response(serializer) + except File.DoesNotExist: + return Response({"message": "File with given ID does not exist"}, status=status.HTTP_404_NOT_FOUND) + except IndentFile.DoesNotExist: + return Response({"message": "Corresponding indent file does not exist"}, status=status.HTTP_404_NOT_FOUND) + + +@api_view(['POST']) +@permission_classes([IsAuthenticated]) +def stockEntry(request,id): + + # print(request.data); + + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + # print(designation) + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + if request.method == 'POST': + + id = request.POST.get('id') + vendor = request.POST.get('vendor') + current_stock = request.POST.get('current_stock') + # received_date = request.POST.get('received_date') + bill = request.FILES.get('bill') + location = request.POST.get('location') + + try: + temp1 = File.objects.get(id=id) + temp = IndentFile.objects.get(file_info=temp1) + except (File.DoesNotExist, IndentFile.DoesNotExist): + return Response({"message": "File with given ID does not exist"}, status=status.HTTP_404_NOT_FOUND) + + item_id = temp + dealing_assistant_id = request.user.extrainfo + + print(request.data) + + stock_entry = StockEntry.objects.create( + item_id=item_id, + vendor=vendor, + current_stock=current_stock, + dealing_assistant_id=dealing_assistant_id, + bill=bill, + # received_date=received_date, + location=location + ) + + # Marking the indent file as done + temp.purchased = True + temp.save() + + serializer = StockEntrySerializer(stock_entry) + return Response(serializer.data, status=status.HTTP_201_CREATED) + + +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +def stockEntryView(request,id): + # print(request.user.id); + + designation =str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + department = request.user.extrainfo.department + + if designation in dept_admin_design: + stocks = StockEntry.objects.filter(item_id__file_info__uploader__department=department) + elif designation == "ps_admin": + stocks = StockEntry.objects.all() + else: + return Response({"message": "Invalid designation"}, status=status.HTTP_400_BAD_REQUEST) + + serializer = StockEntrySerializer(stocks, many=True) + return Response(serializer.data) + + +# to check the current stock situation in the module +@api_view(['GET', 'POST']) +@permission_classes([IsAuthenticated]) +def currentStockView(request,id): + + designation =str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + + if request.method == 'GET': + # Check if the user is authorized + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + # Handle GET request + department = request.user.extrainfo.department + + if designation in dept_admin_design: + # Only show stocks of the department for department admin + stocks = StockItem.objects.filter(department=department) + elif designation == "ps_admin": + # Show all stocks for PS admin + stocks = StockItem.objects.all() + else: + return Response({"message": "Invalid designation"}, status=status.HTTP_403_FORBIDDEN) + + grouped_items = stocks.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade', 'department').annotate(total_quantity=Count('id')) + + grouped_items_list = [ + { + 'item_type': item['StockEntryId__item_id__item_type'], + 'grade': item['StockEntryId__item_id__grade'], + 'department': DepartmentInfo.objects.get(id=item['department']).name, + 'total_quantity': item['total_quantity'] + } + for item in grouped_items + ] + + return Response(grouped_items_list) + + elif request.method == 'POST': + # Handle POST request + department = request.data.get('department') + grade = request.data.get('grade') + item_type = request.data.get('item_type') + + if not department or not grade or not item_type: + return Response({"message": "Missing required parameters"}, status=status.HTTP_400_BAD_REQUEST) + + # Filter StockItem based on provided filters + StockItems = StockItem.objects.filter( + department=department, + StockEntryId__item_id__grade=grade, + StockEntryId__item_id__item_type=item_type + ) + + grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade', 'department').annotate(total_quantity=Count('id')) + + grouped_items_list = [ + { + 'item_type': item['StockEntryId__item_id__item_type'], + 'grade': item['StockEntryId__item_id__grade'], + 'department': DepartmentInfo.objects.get(id=department).name, + 'total_quantity': item['total_quantity'] + } + for item in grouped_items + ] + + # Serialize the data + # serializer = StockItemSerializer(grouped_items_list, many=True) + + firstStock = StockItemSerializer(StockItems.first()) + + return Response({'stocks': grouped_items_list, 'first_stock': firstStock.data}) + + +@api_view(['POST']) +@permission_classes([IsAuthenticated]) +def stock_entry_item_view(request,id): + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + department = request.data.get('department') + file_id=request.data.get('file_id') + temp=File.objects.get(id=file_id) + temp1=IndentFile.objects.get(file_info=temp) + stock_entry=StockEntry.objects.get(item_id=temp1) + + stocks=StockItem.objects.filter(StockEntryId=stock_entry) + serializer = StockItemSerializer(stocks, many=True) + return Response(serializer.data) + + +@api_view(['POST']) +@permission_classes([IsAuthenticated]) +def stockDelete(request,id): + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + + id = request.POST.get('id') + try: + stock = StockItem.objects.get(id=id) + except StockItem.DoesNotExist: + return Response({"message": 'Stock item with given ID does not exist',"id":id}, status=status.HTTP_404_NOT_FOUND) + + stock.delete() + return Response({"message": "Stock item deleted successfully"}, status=status.HTTP_200_OK) + +@api_view(['POST']) +@permission_classes([IsAuthenticated]) +def stockTransfer(request,id): + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + id=request.POST.get('id') + temp=File.objects.get(id=id) + temp1=IndentFile.objects.get(file_info=temp) + + item_type_required =temp1.item_type + item_grade_required = temp1.grade + + available_items=StockItem.objects.filter( + StockEntryId__item_id__item_type=item_type_required, + StockEntryId__item_id__grade=item_grade_required, + inUse=False + ) + + print(available_items) + serializer = StockItemSerializer(available_items, many=True) + return Response(serializer.data) + + + +@api_view(['POST']) +@permission_classes([IsAuthenticated]) +def performTransfer(request,id): + designation = str(Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=id).designation_id)) + + if str(designation) not in dept_admin_design + ["ps_admin"]: + return Response({"message": "Not authorized"}, status=status.HTTP_403_FORBIDDEN) + + selected_stock_items = request.data.getlist('selected_stock_items[]') + indentId = request.data.get('indentId') + dest_location = request.data.get('dest_location') + + list = selected_stock_items[0]; + stock_items_list = ast.literal_eval(list) + + myIndent = IndentFile.objects.get(file_info=indentId) + + moreStocksRequired = myIndent.quantity - len(stock_items_list) + # print('dest_destination : ', myIndent.file_info.uploader.department) + + stock_transfers = [] + for item in stock_items_list: + stock_item = StockItem.objects.get(id=item) + # print('src dest : ', stock_item.department) + + store_cur_dept = stock_item.department; + store_cur_location = stock_item.location; + + # changing the attributes for this stock item as being transferred. + stock_item.department=myIndent.file_info.uploader.department; + stock_item.location=dest_location; + stock_item.inUse= True + stock_item.isTransferred= True + # if a stock_item is been transferred then obviously it will be put into use. + stock_item.save(); + + + stock_transfer = StockTransfer.objects.create( + indent_file=myIndent, + src_dept=store_cur_dept, + dest_dept=myIndent.file_info.uploader.department, + stockItem=stock_item, + src_location=store_cur_location, + dest_location=dest_location + ) + + stock_transfers.append(stock_transfer) + + + if(moreStocksRequired==0): + myIndent.purchased=True + else: + myIndent.quantity=moreStocksRequired; + + myIndent.save(); + + + serializer = StockTransferSerializer(stock_transfers,many=True) + return Response(serializer.data, status=status.HTTP_201_CREATED) diff --git a/FusionIIIT/applications/ps1/migrations/0001_initial.py b/FusionIIIT/applications/ps1/migrations/0001_initial.py index 4cd74fe33..4d5674c39 100644 --- a/FusionIIIT/applications/ps1/migrations/0001_initial.py +++ b/FusionIIIT/applications/ps1/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.db import migrations, models import django.db.models.deletion @@ -55,4 +55,4 @@ class Migration(migrations.Migration): 'db_table': 'StockEntry', }, ), - ] + ] \ No newline at end of file diff --git a/FusionIIIT/applications/ps1/models.py b/FusionIIIT/applications/ps1/models.py index bee76f36e..d5aa60d93 100644 --- a/FusionIIIT/applications/ps1/models.py +++ b/FusionIIIT/applications/ps1/models.py @@ -1,18 +1,22 @@ from django.db import models from django.contrib.auth.models import User -from applications.globals.models import Staff,ExtraInfo +from applications.globals.models import Staff,ExtraInfo,DepartmentInfo from applications.filetracking.models import File +from django.db.models.signals import post_save +from django.dispatch import receiver +from django.utils import timezone class IndentFile(models.Model): file_info=models.OneToOneField(File, on_delete=models.CASCADE,primary_key=True) - item_name=models.CharField(max_length=250,blank=False) + item_name=models.CharField(max_length=250,blank=False) # Apple pro vision 3.0 quantity= models.IntegerField(blank=False) present_stock=models.IntegerField(blank=False) estimated_cost=models.IntegerField(null=True, blank=False) purpose=models.CharField(max_length=250,blank=False ) specification=models.CharField(max_length=250) - indent_type=models.CharField(max_length=250) + grade = models.CharField(max_length=1, choices=[('A', 'A'), ('B', 'B'), ('C', 'C')],default='A') + item_type=models.CharField(max_length=250) nature=models.BooleanField(default = False) indigenous= models.BooleanField(default = False) replaced =models.BooleanField(default = False) @@ -27,15 +31,85 @@ class IndentFile(models.Model): class Meta: db_table = 'IndentFile' + +class Constants: + Locations = ( + ('H1', 'Vashistha Hostel'), + ('H4', 'Vivekananda Hostel'), + ('H3', 'AryaBhatta Hostel'), + ('SR1', 'Storage Room 1'), + ('SR2', 'Storage Room 2'), + ('SR3', 'Storage Room 3'), + ('SR4', 'Storage Room 4'), + ('SR5', 'Storage Room 5'), + ) + class StockEntry(models.Model): item_id=models.OneToOneField(IndentFile, on_delete=models.CASCADE,primary_key=True) dealing_assistant_id=models.ForeignKey(ExtraInfo, on_delete=models.CASCADE) vendor=models.CharField(max_length=250, blank=False) - item_name=models.CharField(max_length=250, blank=False) current_stock=models.IntegerField(blank=False) - recieved_date=models.DateField(blank=False) + recieved_date = models.DateField(blank=False) bill=models.FileField(blank=False) - + location = models.CharField(max_length=100 ,choices=Constants.Locations,default='SR1') class Meta: - db_table = 'StockEntry' \ No newline at end of file + db_table = 'StockEntry' + +# Individual Stock Item +class StockItem(models.Model): + # this represents the id of the StockEntry instance (StockEntryId_id) + + # this StockEntryId will never ever change onces StockItem instance is created and will therefore be used for obtaining the grade,indentfile etc. details. + + StockEntryId = models.ForeignKey(StockEntry,on_delete=models.CASCADE) + nomenclature = models.CharField(max_length=100, unique=True) # Unique identifier for each StockItem + inUse = models.BooleanField(default=True) + + # as department is going to be a variable field here I have to add a Department fiedl for making our job a bit easir and same goes for location as well. Redundancy Hurts :). + + department = models.ForeignKey( + DepartmentInfo, on_delete=models.CASCADE, null=True, blank=True) + location = models.CharField(max_length=100,choices=Constants.Locations,default='SR1') + isTransferred = models.BooleanField(default=False) + + class Meta: + db_table = 'StockItem' + + def save(self, *args, **kwargs): + # Generate nomenclature when saving the StockItem instance + if not self.nomenclature: + # Construct nomenclature using StockEntry primary key and a sequential number + max_existing_number = StockItem.objects.filter(StockEntryId=self.StockEntryId_id).count() + new_number = max_existing_number + 1 + self.nomenclature = f"{self.StockEntryId.item_id}_{new_number}" + super().save(*args, **kwargs) + + +# this table will be used to keep a track of all the stockTransfer things. +class StockTransfer(models.Model): + indent_file=models.ForeignKey(IndentFile, on_delete=models.CASCADE) + + src_dept= models.ForeignKey( + DepartmentInfo, on_delete=models.CASCADE, null=True, blank=True, related_name='dept_src_transfers') + dest_dept= models.ForeignKey( + DepartmentInfo, on_delete=models.CASCADE, null=True, blank=True, related_name='dept_dest_transfers') + + stockItem= models.ForeignKey(StockItem,on_delete=models.CASCADE) + src_location = models.CharField(max_length=100,choices=Constants.Locations,default='SR1') + dest_location = models.CharField(max_length=100,choices=Constants.Locations,default='SR2') + dateTime = models.DateTimeField(default=timezone.now) + + class Meta : + db_table = 'StockTransfer' + + +@receiver(post_save, sender=StockEntry) +def create_stock_items(sender, instance, created, **kwargs): + if created: + # Automatically create 'n' number of StockItem instances based on current_stock of StockEntry + # instance is stockEntry + current_stock = int(instance.current_stock) + for _ in range(current_stock): + StockItem.objects.create(StockEntryId=instance,location=instance.location,department=instance.item_id.file_info.uploader.department) + diff --git a/FusionIIIT/applications/ps1/urls.py b/FusionIIIT/applications/ps1/urls.py index e8b3ad417..793d34ec5 100644 --- a/FusionIIIT/applications/ps1/urls.py +++ b/FusionIIIT/applications/ps1/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.conf.urls import url,include from . import views @@ -7,22 +7,68 @@ 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'), + + # here id is the Holdsdesignation id. url(r'^indentview/(?P\d+)$', views.indentview, name='indentview'), + url(r'^drafts/$', views.drafts, name='drafts'), url(r'^draftview/(?P\d+)$', views.draftview, name='draftview'), url(r'^inwardIndent/$', views.inward, name='inward'), + + # indentview2 is to get all the indentFiles inwarded towards the request.user. + url(r'^indentview2/(?P\d+)$', views.indentview2, name='indentview2'), url(r'^confirmdelete/(?P\d+)$', views.confirmdelete, name='confirm_delete'), url(r'^delete/(?P\d+)$',views.delete, name='delete'), + # forward Indent is to see a specific forwarded indent to ourselves url(r'^forwardindent/(?P\d+)/$', views.forwardindent, name='forwardindent'), url(r'^createdindent/(?P\d+)/$', views.createdindent, name='createdindent'), + + + url(r'^entry/$', views.entry, name='entry'), url(r'^StockEntry/$', views.Stock_Entry, name='Stock_Entry'), - url(r'^stock_view/$', views.stock_view, name='stock_view'), + + # stock_view is now stock_entry_view which will tell us about the new stock that is entered in any department via a new StockEntry + url(r'^stock_entry_view/$', views.stock_entry_view, name='stock_view'), + + # current_stock_view will tell us about the current situation of stocks present in any department (both transferred to the department and new stocks added in the department) + url(r'^current_stock_view/$', views.current_stock_view, name='current_stock_view'), + + # to display individual items belonging to a certain stock entry record. + url(r'^stock_entry_item_view/$', views.stock_entry_item_view, name='stock_entry_item_view'), + + # to display stock items which are having similar item_type ,grade and department.(used in current_stock_view) + url(r'^stock_item_view/$', views.stock_item_view, name='stock_item_view'), + + + + + url(r'^stock_delete/$', views.stock_delete, name='stock_delete'), url(r'^stock_edit/$', views.stock_edit, name='stock_edit'), 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'^stock_login/$', views.dealing_assistant, name='dealing_assistant'), + + + url(r'^generate_report/$', views.generate_report, name='generate_report'), + url(r'^report/$', views.report, name='report'), # !not clear + 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'), + url(r'^view_transfer/$', views.view_transfer, name='view_transfer'), + + url(r'^outboxview2/$', views.outboxview2, name='outboxview2'), + url(r'^outboxview/$', views.outboxview, name='outboxview'), + + + url(r'^update_stock_item_inUse/$', views.updateStockItemInUse, name='outboxview'), + + # BASE API + url(r'^api/',include('applications.ps1.api.urls')), + ] diff --git a/FusionIIIT/applications/ps1/views.py b/FusionIIIT/applications/ps1/views.py index 15168a6b9..f3e603ec5 100644 --- a/FusionIIIT/applications/ps1/views.py +++ b/FusionIIIT/applications/ps1/views.py @@ -1,7 +1,7 @@ from django.contrib import messages from django.shortcuts import render, get_object_or_404, redirect -from applications.filetracking.models import File, Tracking -from applications.ps1.models import IndentFile,StockEntry +from applications.filetracking.sdk.methods import * +from applications.ps1.models import IndentFile,StockEntry,StockItem,StockTransfer from applications.globals.models import ExtraInfo, HoldsDesignation, Designation from django.template.defaulttags import csrf_token from django.http import HttpResponse, HttpResponseRedirect, JsonResponse @@ -11,9 +11,51 @@ 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 +from datetime import datetime +from applications.globals.models import DepartmentInfo +import re +import json + +from django.db.models import Q,Count + +dept_admin_to_dept = { + "deptadmin_cse": "CSE", + "deptadmin_ece": "ECE", + "deptadmin_me": "ME", + "deptadmin_sm": "SM", + "deptadmin_design": "Design", + "deptadmin_liberalarts": "Liberal Arts", + "deptadmin_ns": "Natural Science", +} + +dept_admin_design = ["deptadmin_cse", "deptadmin_ece", "deptadmin_me","deptadmin_sm", "deptadmin_design", "deptadmin_liberalarts","deptadmin_ns" ] + @login_required(login_url = "/accounts/login/") def ps1(request): + des_obj = HoldsDesignation.objects.filter(user=request.user) + + if des_obj: + designations = [des.designation.name for des in des_obj] + + # request.session['currentDesignationSelected'] + currentDes = request.session['currentDesignationSelected'] + + print('currentDes : ',currentDes); + + isdept_admin = any(designation in dept_admin_to_dept for designation in designations) + + if(isdept_admin or currentDes=="ps_admin"): + 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 @@ -34,7 +76,7 @@ def ps1(request): estimated_cost=request.POST.get('estimated_cost') purpose=request.POST.get('purpose') specification=request.POST.get('specification') - indent_type=request.POST.get('indent_type') + item_type=request.POST.get('item_type') nature=request.POST.get('nature') indigenous=request.POST.get('indigenous') replaced =request.POST.get('replaced') @@ -46,11 +88,8 @@ def ps1(request): financial_approval=False purchased =request.POST.get('purchased') """ - des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() - if str(des.designation) == "student": - return redirect('/dashboard') - if request.user.extrainfo.id == '132': - return redirect("/purchase-and-store/entry/") + print("request.user.id : ", request.user.id) + if request.method =="POST": try: if 'save' in request.POST: @@ -60,15 +99,13 @@ def ps1(request): design = request.POST.get('design') designation = Designation.objects.get(id = HoldsDesignation.objects.select_related('user','working','designation').get(id = design).designation_id) upload_file = request.FILES.get('myfile') - - item_name=request.POST.get('item_name') quantity= request.POST.get('quantity') present_stock=request.POST.get('present_stock') estimated_cost=request.POST.get('estimated_cost') purpose=request.POST.get('purpose') specification=request.POST.get('specification') - indent_type=request.POST.get('indent_type') + item_type=request.POST.get('item_type') nature=request.POST.get('nature') indigenous=request.POST.get('indigenous') replaced =request.POST.get('replaced') @@ -96,7 +133,7 @@ def ps1(request): estimated_cost=estimated_cost, purpose=purpose, specification=specification, - indent_type=indent_type, + item_type=item_type, nature=nature, indigenous=indigenous, replaced = replaced , @@ -110,21 +147,24 @@ def ps1(request): ) if 'send' in request.POST: + + + print('request.POST : ',request.POST); + uploader = request.user.extrainfo subject = request.POST.get('title') description = request.POST.get('desc') design = request.POST.get('design') designation = Designation.objects.get(id = HoldsDesignation.objects.select_related('user','working','designation').get(id = design).designation_id) - upload_file = request.FILES.get('myfile') - item_name=request.POST.get('item_name') quantity= request.POST.get('quantity') present_stock=request.POST.get('present_stock') estimated_cost=request.POST.get('estimated_cost') purpose=request.POST.get('purpose') specification=request.POST.get('specification') - indent_type=request.POST.get('indent_type') + item_type=request.POST.get('item_type') + grade=request.POST.get('grade') nature=request.POST.get('nature') indigenous=request.POST.get('indigenous') replaced =request.POST.get('replaced') @@ -135,26 +175,62 @@ 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 request.session['currentDesignationSelected'] == "Director": + head_approval=True + director_approval=True + financial_approval=True + break + - file = File.objects.create( - uploader=uploader, - description=description, - subject=subject, - designation=designation, - upload_file=upload_file - ) + # current_id = request.user.extrainfo + # remarks = request.POST.get('remarks') + + 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/') + recieve = request.POST.get('recieve') + try: + receive_design = Designation.objects.get(name=recieve) + except Exception as e: + receive_design = Designation.objects.get(name=recieve) + messages.error(request, 'Enter a valid Designation') + return redirect('/purchase-and-store/create_proposal/') + + + file_id = create_file( + uploader=request.user, + uploader_designation=designation, + receiver= receiver_id, + receiver_designation=receive_design, + src_module="ps1", + src_object_id="", + file_extra_JSON={"value": 2}, + attached_file=upload_file + ) + IndentFile.objects.create( - file_info=file, + file_info=get_object_or_404(File, pk=file_id), item_name= item_name, quantity=quantity, present_stock=present_stock, estimated_cost=estimated_cost, purpose=purpose, specification=specification, - indent_type=indent_type, + item_type=item_type, nature=nature, + grade=grade, indigenous=indigenous, replaced = replaced , budgetary_head=budgetary_head, @@ -166,37 +242,6 @@ def ps1(request): purchased =purchased, ) - - current_id = request.user.extrainfo - remarks = request.POST.get('remarks') - - 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') - try: - receive_design = Designation.objects.get(name=receive) - except Exception as e: - messages.error(request, 'Enter a valid Designation') - return redirect('/ps1/') - - upload_file = request.FILES.get('myfile') - - 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!') @@ -207,12 +252,19 @@ 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') + + currDesig = request.session['currentDesignationSelected'] + dept_admin_design = ['dept_admin1', 'dept_admin2', 'dept_admin3'] # Replace with actual department admin designations + isAdmin = currDesig == 'ps_admin' or currDesig in dept_admin_design context = { 'file': file, 'extrainfo': extrainfo, 'holdsdesignations': holdsdesignations, 'designations': designations, + 'today': today, + 'isAdmin': isAdmin, } return render(request, 'ps1/composeIndent.html', context) @@ -231,6 +283,9 @@ def ps1(request): # } # return render(request, 'ps1/composeIndent.html', context) + + + @login_required(login_url = "/accounts/login") def composed_indents(request): @@ -255,6 +310,9 @@ def composed_indents(request): # print(File.objects) # extrainfo = ExtraInfo.objects.all() # designation = Designation.objects.get(id=HoldsDesignation.objects.get(user=request.user).designation_id) + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') designation = HoldsDesignation.objects.filter(user=request.user) context = { # 'draft': draft, @@ -263,6 +321,29 @@ def composed_indents(request): } return render(request, 'ps1/composed_indents.html', context) + + +@login_required(login_url = "/accounts/login") +def drafts_for_multiple_item(request): + """ + The function is used to get all the designations hold by the user. + + @param: + request - trivial. + + @variables: + context - Holds data needed to make necessary changes in the template. + """ + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + designation = HoldsDesignation.objects.filter(user=request.user) + context = { + 'designation': designation, + } + return render(request, 'ps1/drafts1.html', context) + + def drafts(request): """ The function is used to get all the files created by user(employee). @@ -285,6 +366,9 @@ def drafts(request): # print(File.objects) # extrainfo = ExtraInfo.objects.all() # designation = Designation.objects.get(id=HoldsDesignation.objects.get(user=request.user).designation_id) + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') designation = HoldsDesignation.objects.filter(user=request.user) context = { # 'draft': draft, @@ -295,7 +379,7 @@ def drafts(request): @login_required(login_url = "/accounts/login") def indentview(request,id): - + print("id : ",id); tracking_objects=Tracking.objects.all() tracking_obj_ids=[obj.file_id for obj in tracking_objects] @@ -315,9 +399,57 @@ def indentview(request,id): } return render(request, 'ps1/indentview.html', context) + +# @login_required(login_url = "/accounts/login") +# def draftview_multiple_items_indent(request,id): +# """ +# The function is used to get all the files created by user(employee). +# It gets all files created by user by filtering file(table) object by user i.e, uploader. +# It displays user and file details of a file(table) of filetracking(model) in the +# template of 'Saved files (new)' tab for indentfile with multiple items. + +# @param: +# request - trivial. + +# @variables: +# draft - The File object filtered by uploader(user). +# extrainfo - The Extrainfo object. +# context - Holds data needed to make necessary changes in the template. +# """ + + +# des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() +# if request.session['currentDesignationSelected'] == "student": +# return redirect('/dashboard') + +# indents= IndentFile2.objects.filter(file_info__in=request.user.extrainfo.uploaded_files.all()).select_related('file_info') +# indent_ids=[indent.file_info for indent in indents] +# filed_indents=Tracking.objects.filter(file_id__in=indent_ids) +# filed_indent_ids=[indent.file_id for indent in filed_indents] +# draft = list(set(indent_ids) - set(filed_indent_ids)) +# draft_indent=IndentFile2.objects.filter(file_info__in=draft).values("file_info") +# draft_files=File.objects.filter(id__in=draft_indent).order_by('-upload_date') +# extrainfo = ExtraInfo.objects.all() +# abcd = HoldsDesignation.objects.get(pk=id) +# s = str(abcd).split(" - ") +# designations = s[1] + +# context = { +# 'draft':draft_files, +# 'extrainfo': extrainfo, +# 'designations': designations, +# } +# return render(request, 'ps1/draftview1.html', context) + + + @login_required(login_url = "/accounts/login") def draftview(request,id): + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + indents= IndentFile.objects.filter(file_info__in=request.user.extrainfo.uploaded_files.all()).select_related('file_info') indent_ids=[indent.file_info for indent in indents] filed_indents=Tracking.objects.filter(file_id__in=indent_ids) @@ -339,26 +471,33 @@ def draftview(request,id): @login_required(login_url = "/accounts/login") def indentview2(request,id): - - - - indent_files = IndentFile.objects.all().values('file_info') - print(indent_files) - in_file = Tracking.objects.filter(file_id__in=indent_files,receiver_id=request.user).order_by("-receive_date") - - #print (File.designation) abcd = HoldsDesignation.objects.get(pk=id) s = str(abcd).split(" - ") designations = s[1] + data = view_inbox(request.user.username, designations, "ps1") - context = { + outboxd = view_outbox(request.user.username, designations, "ps1") - 'in_file': in_file, - 'designations': designations, + data = sorted(data, key=lambda x: datetime.fromisoformat(x['upload_date']), reverse=True) + + for item in data: + item['upload_date'] = datetime.fromisoformat(item['upload_date']) + + context = { + 'receive_design':abcd, + 'in_file': data, } return render(request, 'ps1/indentview2.html', context) + + + + + + + + @login_required(login_url = "/accounts/login") def inward(request): """ @@ -372,18 +511,27 @@ def inward(request): in_file - The Tracking object filtered by receiver_id i.e, present working user. context - Holds data needed to make necessary changes in the template. """ + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if str(des.designation) == "student": + return redirect('/dashboard') + designation = HoldsDesignation.objects.filter(user=request.user) - in_file=Tracking.objects.filter(receiver_id=request.user).order_by('-receive_date') - - context = { - 'in_file': in_file, 'designation': designation, } return render(request, 'ps1/inwardIndent.html', context) + + + + + + @login_required(login_url = "/accounts/login") def confirmdelete(request,id): + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') file = File.objects.get(pk = id) context = { @@ -419,6 +567,8 @@ def forwardindent(request, id): # start = timer() # end = timer() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') indent=IndentFile.objects.select_related('file_info').get(file_info=id) file=indent.file_info # start = timer() @@ -426,10 +576,9 @@ def forwardindent(request, id): 'current_design__user','current_design__working','current_design__designation','receiver_id','receive_design').filter(file_id=file) # end = timer() - - - if request.method == "POST": + # print('Mohit Will Win : ' , request.POST); + if 'finish' in request.POST: file.complete_flag = True file.save() @@ -437,11 +586,15 @@ def forwardindent(request, id): if 'send' in request.POST: current_id = request.user.extrainfo remarks = request.POST.get('remarks') + sender_design_id = request.POST.get('sender') + sender_designationobj = HoldsDesignation.objects.get(id=sender_design_id).designation + sender_designation_name = sender_designationobj.name - sender = request.POST.get('sender') - current_design = HoldsDesignation.objects.select_related('user','working','designation').get(id=sender) + receiverHdid = request.POST.get('receive') + receiverHdobj = HoldsDesignation.objects.get(id=receiverHdid) + receiver = receiverHdobj.user.username + receive_design = receiverHdobj.designation.name - receiver = request.POST.get('receiver') try: receiver_id = User.objects.get(username=receiver) except Exception as e: @@ -449,102 +602,73 @@ def forwardindent(request, id): designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) context = { - # 'extrainfo': extrainfo, - # 'holdsdesignations': holdsdesignations, 'designations': designations, 'file': file, 'track': track, } return render(request, 'ps1/forwardindent.html', context) - receive = request.POST.get('recieve') try: - receive_design = Designation.objects.get(name=receive) + receive_design = Designation.objects.get(name=receive_design) except Exception as e: messages.error(request, 'Enter a valid Designation') designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) context = { - # 'extrainfo': extrainfo, - # 'holdsdesignations': holdsdesignations, 'designations': designations, 'file': file, 'track': track, } return render(request, 'ps1/forwardindent.html', context) - # receive_design = receive_designation[0] + upload_file = request.FILES.get('myfile') - # return HttpResponse ("success") - Tracking.objects.create( - file_id=file, - current_id=current_id, - current_design=current_design, - receive_design=receive_design, - receiver_id=receiver_id, + forwarded_file_id = forward_file( + file_id=file.id, + receiver=receiver_id, + receiver_designation=receive_design, + file_extra_JSON={"key": 2}, remarks=remarks, - upload_file=upload_file, + file_attachment=upload_file ) - check=str(request.user) - val=str(request.POST.get('approval')) - - - # if val=="accept": - # print("correct") - # if check=="ptandon" or check=="atul" or check=="prabin16" or check=="subirs" or check=="prabir": - # indent.head_approval=True - # elif check=="director": - # indent.director_approval=True - # elif check=="rizwan": - # indent.financial_approval=True - - # else: - # if check=="ptandon" or check=="atul" or check=="prabin16" or check=="subirs" or check=="prabir": - # indent.head_approval=False - # elif check=="director": - # indent.director_approval=False - # elif check=="rizwan": - # indent.financial_approval=False - - - designs =[] - designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) - for designation in designations : - s = str(designation).split(" - ") - designs.append(s[1]) - if val=="accept": - if any(d in designs for d in ("HOD (ME)", "HOD (ECE)", "CSE HOD", "HOD (Design)", "HOD (NS)")): + if (str(receive_design) in dept_admin_design): indent.head_approval=True - elif "Director" in designs: + elif (( + (sender_designation_name in dept_admin_design) + or + (sender_designation_name == "ps_admin") + ) + and (str(receive_design) == "Accounts Admin")): 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)")): - indent.head_approval=False - elif "Director" in designs: - indent.director_approval=False - indent.financial_approval=False - + indent.head_approval=True + + designs =[] + designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) + for designation in designations : + s = str(designation).split(" - ") + designs.append(s[1]) indent.save() - messages.success(request, 'Indent File sent successfully') - # start = timer() + messages.success(request, 'Indent File Forwarded successfully') 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) + + + context = { - # 'extrainfo': extrainfo, - # 'holdsdesignations': holdsdesignations, + 'extrainfo': extrainfo, + 'holdsdesignations': holdsdesignations, 'designations':designations, 'file': file, 'track': track, - 'indent':indent, + 'indent':indent } return render(request, 'ps1/forwardindent.html', context) @@ -567,6 +691,9 @@ def createdindent(request, id): holdsdesignations = HoldsDesignation objects. context - Holds data needed to make necessary changes in the template. """ + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') # start = timer() # end = timer() @@ -622,8 +749,6 @@ def createdindent(request, id): 'track': track, } return render(request, 'ps1/createdindent.html', context) - - # receive_design = receive_designation[0] upload_file = request.FILES.get('myfile') # return HttpResponse ("success") Tracking.objects.create( @@ -638,14 +763,9 @@ def createdindent(request, id): messages.success(request, 'Indent File sent successfully') - # start = timer() - 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) context = { - # 'extrainfo': extrainfo, - # 'holdsdesignations': holdsdesignations, 'designations':designations, 'file': file, 'track': track, @@ -656,9 +776,10 @@ def createdindent(request, id): - def AjaxDropdown1(request): - print('brefore post') + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') if request.method == 'POST': value = request.POST.get('value') # print(value) @@ -676,7 +797,6 @@ def AjaxDropdown1(request): def AjaxDropdown(request): - print('asdasdasdasdasdasdasdas---------------\n\n') # Name = ['student','co-ordinator','co co-ordinator'] # design = Designation.objects.filter(~Q(name__in=(Name))) # hold = HoldsDesignation.objects.filter(Q(designation__in=(design))) @@ -685,6 +805,9 @@ def AjaxDropdown(request): # for h in hold: # arr.append(ExtraInfo.objects.filter(user=h.user)) + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') if request.method == 'POST': value = request.POST.get('value') @@ -703,6 +826,9 @@ def test(request): @login_required(login_url = "/accounts/login") def delete(request,id): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') file = File.objects.get(pk = id) file.delete() @@ -721,76 +847,40 @@ def delete(request,id): return redirect('/ps1/composed_indents/') -@login_required(login_url = "/accounts/login") -def Stock_Entry(request): - - - if request.method=='GET' : - - return HttpResponseRedirect('../stock_view') - if request.method =="POST": - - - #dealing_assistant_id=request.POST.get('dealing_assistant_id') - id=request.POST.get('id') - - - temp1=File.objects.get(id=id) - temp=IndentFile.objects.get(file_info=temp1) - - - - dealing_assistant_id=request.user.extrainfo - - item_id=temp - item_name=request.POST.get('item_name') - vendor=request.POST.get('vendor') - current_stock=request.POST.get('current_stock') - recieved_date=request.POST.get('recieved_date') - bill=request.FILES.get('bill') - - - # staff=Staff.objects.get(id=request.user.extrainfo) - - StockEntry.objects.create(item_id=item_id,item_name= item_name,vendor=vendor,current_stock=current_stock,dealing_assistant_id=dealing_assistant_id,bill=bill,recieved_date=recieved_date,) - IndentFile.objects.filter(file_info=temp).update(purchased=True) - - return HttpResponseRedirect('../stock_view') - - - - - - +# stock Edit will provide the prepoulated form for updation of information. @login_required(login_url = "/accounts/login") def stock_edit(request): - # stocks=StockEntry.objects.get(pk=id) - # return render(request,'ps1/stock_edit.html',{'StockEntry':stocks}) - + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') 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_edit.html',{'StockEntry':stocks}) - - # if 'save' in request.POST: - # stocks.item_name=request.POST.get('item_name') - # stocks.vendor=request.POST.get('vendor') - # stocks.current_stock=request.POST.get('current_stock') - # stocks.recieved_date=request.POST.get('recieved_date') - # stocks.bill=request.FILES.get('bill') - # stocks.save() - - return HttpResponseRedirect('../stock_view') + Stock_Entry=StockEntry.objects.get(item_id=temp1) + + print(Stock_Entry.recieved_date); + formatted_received_date = Stock_Entry.recieved_date.strftime("%Y-%m-%d") + + persons = ExtraInfo.objects.filter(user_type__in=["staff"]) + return render(request,'ps1/stock_edit.html',{'StockEntry':Stock_Entry,'persons':persons,'formatted_received_date': formatted_received_date}) + + return HttpResponseRedirect('../stock_entry_view') #else: # print("ELSE") # return render(request,'ps1/stock_edit.html',{'StockEntry':stocks}) - + + +# This view defines the logic for stock +@login_required(login_url = "/accounts/login") def stock_update(request): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + if request.method =="POST": if 'save' in request.POST: id=request.POST.get('id') @@ -798,36 +888,179 @@ def stock_update(request): temp1=IndentFile.objects.get(file_info=temp) stocks=StockEntry.objects.get(item_id=temp1) - stocks.item_name=request.POST.get('item_name') + # Retrieve the ExtraInfo instance based on the provided string value + + print(request.POST); + + dealing_assistant_id_str = request.POST.get('dealing_assistant_id').split('-')[0].strip(); + print({dealing_assistant_id_str}) + + dealing_assistant_instance = ExtraInfo.objects.get(id=dealing_assistant_id_str) + + stocks.dealing_assistant_id = dealing_assistant_instance + stocks.vendor=request.POST.get('vendor') stocks.current_stock=request.POST.get('current_stock') - #stocks.recieved_date=request.POST.get('recieved_date') + # stocks.recieved_date=request.POST.get('recieved_date') stocks.bill=request.FILES.get('bill') + stocks.location = request.POST.get('location') + stocks.recieved_date = request.POST.get('recieved_date') + stocks.save() - return HttpResponseRedirect('../stock_view') - + return HttpResponseRedirect('../stock_entry_view') - +# this is know the current situation of stocks present in any department. -# def stock_view(request): -# sto=StockEntry.objects.all() -# return render(request,'ps1/stock_view.html',{'StockEntry':sto}) -# @login_required(login_url = "/accounts/login") -def stock_view(request): +@login_required(login_url = "/accounts/login") +def current_stock_view(request): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') - sto=StockEntry.objects.all() - if sto: - temp=sto.first() + # for handling the search after submission of filters form + if request.method=="POST": + print('the requested data : ', request.POST) + department = request.POST.get('department') + grade = request.POST.get('grade') + type = request.POST.get('type') + + # StockEntryId__item_id__file_info_grade + StockItems = StockItem.objects.filter( + department=department, + StockEntryId__item_id__grade=grade, + StockEntryId__item_id__item_type=type + ) + + grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade','department').annotate(total_quantity=Count('id')) + + grouped_items_list = [ + { + 'item_type': item['StockEntryId__item_id__item_type'], + 'grade': item['StockEntryId__item_id__grade'], + 'department': DepartmentInfo.objects.get(id=department), + 'total_quantity': item['total_quantity'] + } + for item in grouped_items + ] + + + firstStock=StockItems.first() - if temp.item_id.purchased: - print("Purchase Succesful") - print() - print() - - return render(request,'ps1/stock_view.html',{'sto':sto}) + return render(request,'ps1/current_stock_view.html',{'stocks':grouped_items_list,'first_stock':firstStock, + 'stockItems':StockItems}) + # return render(request,'ps1/current_stock_view.html',{'stocks':StockItems,'quantity':StockItems.count()}) + + + # THIS IS HARDCODED FOR NOW . + itemsTypes=['Equipment','Machinery','Furniture','Fixture'] + grades=['A','B','C'] + departmentUser=request.user.extrainfo.department + + if request.session['currentDesignationSelected'] in dept_admin_design: + # if department admin then only show the stocks of that department to them + + print(dept_admin_to_dept[request.session['currentDesignationSelected']]); + deptId = DepartmentInfo.objects.get(name=dept_admin_to_dept[request.session['currentDesignationSelected']]) + + departments=[deptId] + + StockItems = StockItem.objects.filter(department=deptId) + + elif request.session['currentDesignationSelected'] == "ps_admin": + departments=DepartmentInfo.objects.all() + StockItems = StockItem.objects.all() + else : + return redirect('/dashboard') + + + grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade','department').annotate(total_quantity=Count('id')) + + grouped_items_list = [ + { + 'item_type': item['StockEntryId__item_id__item_type'], + 'grade': item['StockEntryId__item_id__grade'], + 'department': DepartmentInfo.objects.get(id=item['department']), + 'departmentId': item['department'], + 'total_quantity': item['total_quantity'] + } + for item in grouped_items + ] + + + return render(request,'ps1/current_stock_view_filter.html',{'itemsTypes':itemsTypes,'grades':grades,'departments':departments,'stocks':grouped_items_list}) + +# to display stock items which are having similar item_type ,grade and department.(used in current_stock_view) + +@login_required(login_url = "/accounts/login") +def stock_item_view(request): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + if request.method=="POST": + departmentId = request.POST.get('departmentId') + grade = request.POST.get('grade') + type = request.POST.get('item_type') + + # StockEntryId__item_id__file_info_grade + StockItems = StockItem.objects.filter( + department=departmentId, + StockEntryId__item_id__grade=grade, + StockEntryId__item_id__item_type=type + ) + + return render(request,'ps1/stock_item_view.html',{'stocks':StockItems}) + + +@login_required(login_url = "/accounts/login") +def stock_entry_view(request): + + # ! CHALLENGE HERE IS HOW TO SHOW THE TRANSFERRED STOCKS AND CURRENTLY PRESENT. + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + department = request.user.extrainfo.department + + if request.session['currentDesignationSelected'] in dept_admin_design: + # if department admin then only show the stocks of that department to them + print("I am a department admin "); + deptId = DepartmentInfo.objects.get(name=dept_admin_to_dept[request.session['currentDesignationSelected']]) + stocks=StockEntry.objects.filter(item_id__file_info__uploader__department=deptId) + elif request.session['currentDesignationSelected'] == "ps_admin": + print("I am a PS admin "); + stocks=StockEntry.objects.all() + else : + return redirect('/dashboard') + + print('stocks : ',stocks) + + return render(request,'ps1/stock_entry_view.html',{'stocks':stocks}) + +@login_required(login_url = "/accounts/login") +def stock_entry_item_view(request): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + department = request.user.extrainfo.department + file_id = request.POST.get('id') + temp=File.objects.get(id=file_id) + temp1=IndentFile.objects.get(file_info=temp) + Stock_Entry=StockEntry.objects.get(item_id=temp1) + + + stocks=StockItem.objects.filter(StockEntryId=Stock_Entry) + + return render(request,'ps1/stock_entry_item_view.html',{'stocks':stocks,'first_stock':stocks.first()}) + + + + @login_required(login_url = "/accounts/login") def stock_delete(request): + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') if request.method=='POST': @@ -838,26 +1071,323 @@ def stock_delete(request): temp1=IndentFile.objects.get(file_info=temp) stocks=StockEntry.objects.get(item_id=temp1) stocks.delete() - return HttpResponseRedirect('../stock_view') + return HttpResponseRedirect('../stock_entry_view') + + + + + @login_required(login_url = "/accounts/login") def entry(request): - + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + # To Add stock corresponding to 'id' indent File. if request.method=='POST': + # id is the id of the File Object here id=request.POST.get('id') - temp=File.objects.get(id=id) - temp1=IndentFile.objects.get(file_info=temp) - return render(request,'ps1/StockEntry.html',{'id':id, 'indent':temp1}) + RequestFile = File.objects.select_related('uploader').get(id=id) + + # Requester is the person who uploaded the IndentFile Initially and you can access all of the requesters info available in User model (AbstractUser) like username ,email etc. + Requester = RequestFile.uploader.user + + # RequestFile.uploader contains the Extra information about the uploader of the RequestFile (using ExtraInfo Foreign key) + + + persons = ExtraInfo.objects.filter(user_type__in=["staff"]) + + CorrespondingIndentFile=IndentFile.objects.get(file_info=RequestFile) + return render(request,'ps1/StockEntry.html',{'id':id, 'indent':CorrespondingIndentFile,'RequestFile':RequestFile,'persons':persons}) - - ent=IndentFile.objects.all() - return render(request,'ps1/entry.html',{'ent':ent}) - + # ent=IndentFile.objects.all() + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + department = request.user.extrainfo.department.name + + # this is to filter out the indent files only specific to a department like if A is a department Admin then he should only see the indent files corresponding to his department. + if request.session['currentDesignationSelected'] in dept_admin_design: + IndentFiles=IndentFile.objects.filter(file_info__uploader__department__name=dept_admin_to_dept[request.session['currentDesignationSelected']]) + else : + # otherwise all the indent files will be shown. + IndentFiles=IndentFile.objects.all() + return render(request,'ps1/entry.html',{'IndentFiles':IndentFiles}) + + +@login_required(login_url = "/accounts/login") +def Stock_Entry(request): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + else : + if request.method=='GET' : + return HttpResponseRedirect('../stock_entry_view') + + if request.method =="POST": + + id=request.POST.get('id') + temp1=File.objects.get(id=id) + temp=IndentFile.objects.get(file_info=temp1) + + item_id=temp + dealing_assistant_id=request.user.extrainfo + vendor=request.POST.get('vendor') + current_stock=request.POST.get('current_stock') + recieved_date=request.POST.get('recieved_date') + bill=request.FILES.get('bill') + location= request.POST.get('location') + + StockEntry.objects.create( + item_id=item_id, + vendor=vendor, + current_stock=current_stock, + dealing_assistant_id=dealing_assistant_id, + bill=bill, + recieved_date=recieved_date, + location=location + ) + + # marking the indent file as done + IndentFile.objects.filter(file_info=temp).update(purchased=True) + + return HttpResponseRedirect('../stock_entry_view') + + def dealing_assistant(request): + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') print(request.user.extrainfo.id) print(type(request.user.extrainfo.id)) if request.user.extrainfo.id=='132' : - return redirect('/ps1/entry/') + return redirect('/purchase-and-store/entry/') else: return redirect('/ps1') + + +@login_required(login_url = "/accounts/login") +def generate_report(request): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + department = request.user.extrainfo.department.name + + if request.session['currentDesignationSelected'] in dept_admin_design: + sto=StockEntry.objects.filter(item_id__file_info__uploader__department__name=dept_admin_to_dept[request.session['currentDesignationSelected']]) + 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): + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + print('Hello I am here ' , stock_entry_id) + stock_entry = get_object_or_404(StockEntry, pk=stock_entry_id) + + print(stock_entry); + + # 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) + + + +# This is to return a list of stocks available for transfer. +@login_required(login_url = "/accounts/login") +def perform_transfer(request): + + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + if request.method == "POST": + + selected_stock_items = request.POST.getlist('selected_stock_items[]') + indentId = request.POST.get('indentId') + dest_location = request.POST.get('dest_location') + + # print(selected_stock_items) + # print('dest_location : ',dest_location); + + # Use regular expression to extract the number + match = re.search(r'\((\d+)\)', indentId) + + number = match.group(1) # Extract the number from the match + + myIndent = IndentFile.objects.get(file_info=number) + + moreStocksRequired = myIndent.quantity - len(selected_stock_items) + # print('dest_destination : ', myIndent.file_info.uploader.department) + + for item in selected_stock_items: + stock_item = StockItem.objects.get(id=item) + # print('src dest : ', stock_item.department) + + store_cur_dept = stock_item.department; + store_cur_location = stock_item.location; + + # changing the attributes for this stock item as being transferred. + stock_item.department=myIndent.file_info.uploader.department; + stock_item.location=dest_location; + stock_item.inUse= True + stock_item.isTransferred= True + # if a stock_item is been transferred then obviously it will be put into use. + stock_item.save(); + + StockTransfer.objects.create( + indent_file = myIndent, + src_dept=store_cur_dept, + dest_dept=myIndent.file_info.uploader.department, + stockItem=stock_item, + src_location=store_cur_location, + dest_location=dest_location + ) + + messages.success(request,'Stock Transfer Done Successfully.!') + # if the quantity required for this indent file is fulfilled we should mark this indentfile as done. + if(moreStocksRequired<=0): + myIndent.purchased=True + else : + myIndent.quantity=moreStocksRequired; + + myIndent.save(); + + department = request.user.extrainfo.department.name + + return HttpResponseRedirect('../view_transfer') + +# This is to get the list of all the available stock items for transfer. +@login_required(login_url = "/accounts/login") +def stock_transfer(request): + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + if request.method =="POST": + # id is the of File instance id in db. + id=request.POST.get('id') + + temp=File.objects.get(id=id) + temp1=IndentFile.objects.get(file_info=temp) + + item_type_required =temp1.item_type + item_grade_required = temp1.grade + + available_items = StockItem.objects.filter( + StockEntryId__item_id__item_type=item_type_required, # Foreign key traversal to IndentFile model + StockEntryId__item_id__grade=item_grade_required, # Foreign key traversal to IndentFile model + inUse=False # Filter for inUse=False + ) + + print(available_items) + return render(request,'ps1/stock_transfer.html',{'indentFile': temp1,'available_items':available_items}) + + return HttpResponseRedirect('../stock_transfer') + + +# to view the transfers +@login_required(login_url = "/accounts/login") +def view_transfer(request): + curr_desg = request.session['currentDesignationSelected'] + if curr_desg not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + if curr_desg=="ps_admin": + stockTransfers = StockTransfer.objects.all(); + + elif curr_desg in dept_admin_design: + user_dept = DepartmentInfo.objects.get(name=dept_admin_to_dept[curr_desg]) + stockTransfers = StockTransfer.objects.filter( + Q(src_dept=user_dept) | Q(dest_dept=user_dept) + ) + + # print('stock Transfers : ',stockTransfers); + + return render(request,'ps1/view_transfer.html',{'stockTransfers': stockTransfers}) + + +@login_required(login_url = "/accounts/login") +def outboxview2(request,id): + abcd = HoldsDesignation.objects.get(pk=id) + s = str(abcd).split(" - ") + designations = s[1] + data = view_outbox(request.user.username, designations, "ps1") + data = sorted(data, key=lambda x: datetime.fromisoformat(x['upload_date']), reverse=True) + + for item in data: + item['upload_date'] = datetime.fromisoformat(item['upload_date']) + + context = { + 'receive_design':abcd, + 'in_file': data, + } + return render(request, 'ps1/outboxview2.html', context) + +@login_required(login_url = "/accounts/login") +def outboxview(request): + + designation = HoldsDesignation.objects.filter(user=request.user) + context = { + 'designation': designation, + } + + return render(request, 'ps1/outboxview.html', context) + + +@login_required(login_url="/accounts/login") +def updateStockItemInUse(request): + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + if request.method == "POST": + + # print(request.POST); + + # Get the JSON data from the request body + json_data = json.loads(request.POST.get('selected_stock_items')) + + + # print('jsondata : ', json_data) + + for item in json_data: + item_id = item['id'] + checked = item['checked'] + stock_item = StockItem.objects.get(id=item_id) + stock_item.inUse = checked + stock_item.save() + + return redirect('/purchase-and-store/current_stock_view') \ No newline at end of file diff --git a/FusionIIIT/applications/recruitment/migrations/0001_initial.py b/FusionIIIT/applications/recruitment/migrations/0001_initial.py index 9cf2d3a77..386d6d6fb 100644 --- a/FusionIIIT/applications/recruitment/migrations/0001_initial.py +++ b/FusionIIIT/applications/recruitment/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.conf import settings diff --git a/FusionIIIT/applications/research_procedures/migrations/0001_initial.py b/FusionIIIT/applications/research_procedures/migrations/0001_initial.py index ec4b77a48..2befdff1a 100644 --- a/FusionIIIT/applications/research_procedures/migrations/0001_initial.py +++ b/FusionIIIT/applications/research_procedures/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.conf import settings diff --git a/FusionIIIT/applications/scholarships/migrations/0001_initial.py b/FusionIIIT/applications/scholarships/migrations/0001_initial.py index 176422fd9..13627011e 100644 --- a/FusionIIIT/applications/scholarships/migrations/0001_initial.py +++ b/FusionIIIT/applications/scholarships/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 import datetime from django.db import migrations, models @@ -10,8 +10,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('academic_information', '0001_initial'), ('globals', '0001_initial'), + ('academic_information', '0001_initial'), ] operations = [ @@ -85,7 +85,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('programme', models.CharField(default='B.Tech', max_length=10)), - ('year', models.IntegerField(default=2023)), + ('year', models.IntegerField(default=2024)), ('award_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scholarships.award_and_scholarship')), ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')), ], diff --git a/FusionIIIT/applications/visitor_hostel/migrations/0001_initial.py b/FusionIIIT/applications/visitor_hostel/migrations/0001_initial.py index f4229feb2..96df7d704 100644 --- a/FusionIIIT/applications/visitor_hostel/migrations/0001_initial.py +++ b/FusionIIIT/applications/visitor_hostel/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2023-03-15 18:53 +# Generated by Django 3.1.5 on 2024-04-15 23:58 from django.conf import settings from django.db import migrations, models @@ -89,14 +89,13 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('meal_date', models.DateField()), - ('morning_tea', models.BooleanField(default=False)), - ('eve_tea', models.BooleanField(default=False)), - ('breakfast', models.BooleanField(default=False)), - ('lunch', models.BooleanField(default=False)), - ('dinner', models.BooleanField(default=False)), + ('morning_tea', models.IntegerField(default=0)), + ('eve_tea', models.IntegerField(default=0)), + ('breakfast', models.IntegerField(default=0)), + ('lunch', models.IntegerField(default=0)), + ('dinner', models.IntegerField(default=0)), ('persons', models.IntegerField(default=0)), ('booking', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='visitor_hostel.bookingdetail')), - ('room', models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to='visitor_hostel.roomdetail')), ('visitor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='visitor_hostel.visitordetail')), ], ), @@ -126,6 +125,7 @@ class Migration(migrations.Migration): ('meal_bill', models.IntegerField(default=0)), ('room_bill', models.IntegerField(default=0)), ('payment_status', models.BooleanField(default=False)), + ('bill_date', models.DateField(blank=True, default=django.utils.timezone.now)), ('booking', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='visitor_hostel.bookingdetail')), ('caretaker', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ('room', models.ManyToManyField(to='visitor_hostel.RoomDetail')), diff --git a/FusionIIIT/notification/views.py b/FusionIIIT/notification/views.py index 788b18ce9..23cddf49b 100644 --- a/FusionIIIT/notification/views.py +++ b/FusionIIIT/notification/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render +from requests import Response from notifications.signals import notify - # Create your views here. def leave_module_notif(sender, recipient, type, date=None): @@ -69,6 +69,7 @@ def central_mess_notif(sender, recipient, type, message=None): sender = sender recipient = recipient verb = '' + if type == 'feedback_submitted': verb = 'Your feedback has been successfully submitted.' elif type == 'menu_change_accepted': @@ -122,18 +123,23 @@ def healthcare_center_notif(sender, recipient, type): sender = sender recipient = recipient verb = '' + if type == 'appoint': verb = "Your Appointment has been booked" - if type == 'amb_request': + elif type == 'amb_request': verb = "Your Ambulance request has been placed" - if type == 'Presc': + elif type == 'Presc': verb = "You have been prescribed some medicine" - if type == 'appoint_req': + elif type == 'appoint_req': verb = "You have a new appointment request" - if type == 'amb_req': + elif type == 'amb_req': verb = "You have a new ambulance request" - - + elif type == 'rel_forward': + verb = "You have a new medical relief forward request" + elif type == 'rel_approve': + verb = "You have a new medical relief approval request" + elif type == 'rel_approved': + verb = 'Your medical relief request has been approved' notify.send(sender=sender, recipient=recipient, url=url, module=module, verb=verb) @@ -346,7 +352,21 @@ def department_notif(sender, recipient, type): sender = sender recipient = recipient verb = type - flag = "department" + flag = "announcement" + + notify.send(sender=sender, + recipient=recipient, + url=url, + module=module, + verb=verb, + flag=flag) +def examination_notif(sender, recipient, type): + url='examination:examination' + module='examination' + sender = sender + recipient = recipient + verb = type + flag = "announcement" notify.send(sender=sender, recipient=recipient, @@ -394,4 +414,5 @@ def research_procedures_notif(sender,recipient,type): elif type == "created": verb = "A new Patent has been Created" - notify.send(sender=sender,recipient=recipient,url=url,module=module,verb=verb) \ No newline at end of file + notify.send(sender=sender,recipient=recipient,url=url,module=module,verb=verb) + diff --git a/FusionIIIT/templates/dashboard/alerts.html b/FusionIIIT/templates/dashboard/alerts.html index b63276ecd..42edc5df7 100755 --- a/FusionIIIT/templates/dashboard/alerts.html +++ b/FusionIIIT/templates/dashboard/alerts.html @@ -5,7 +5,7 @@
{% for notice in notifications %} {% comment %}A single notification starts here!{% endcomment %} - {% ifnotequal notice.data.flag "department" %} + {% ifnotequal notice.data.flag "announcement" %} {% if notice.unread %}
{% else %} @@ -14,6 +14,9 @@
{{ notice.timesince }} ago diff --git a/FusionIIIT/templates/dashboard/alerts1.html b/FusionIIIT/templates/dashboard/alerts1.html index e2844039f..442570f29 100644 --- a/FusionIIIT/templates/dashboard/alerts1.html +++ b/FusionIIIT/templates/dashboard/alerts1.html @@ -14,6 +14,9 @@
{{ notice.timesince }} ago @@ -27,7 +30,6 @@ {% endifnotequal %}
- {% if notice.unread %}
Mark as Read
diff --git a/FusionIIIT/templates/dashboard/dashboard.html b/FusionIIIT/templates/dashboard/dashboard.html index acc4230fe..b65710e69 100644 --- a/FusionIIIT/templates/dashboard/dashboard.html +++ b/FusionIIIT/templates/dashboard/dashboard.html @@ -41,7 +41,7 @@ {% comment %}The Tab-Menu starts here!{% endcomment %}