diff --git a/FusionIIIT/applications/research_procedures/migrations/0001_initial.py b/FusionIIIT/applications/research_procedures/migrations/0001_initial.py index 56711cfcd..d365f1537 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 2024-04-27 23:48 +# Generated by Django 3.1.5 on 2024-05-04 03:00 import datetime from django.conf import settings @@ -15,84 +15,76 @@ class Migration(migrations.Migration): ] operations = [ - migrations.CreateModel( - name='category', - fields=[ - ('category_id', models.IntegerField(primary_key=True, serialize=False)), - ('category_name', models.CharField(max_length=500)), - ('sub_category_name', models.CharField(max_length=500)), - ], - options={ - 'ordering': ['-category_id'], - }, - ), - migrations.CreateModel( - name='projects', - fields=[ - ('project_id', models.IntegerField(primary_key=True, serialize=False)), - ('project_name', models.CharField(max_length=600)), - ('project_type', models.CharField(max_length=500)), - ('sponsored_agency', models.CharField(max_length=500)), - ('start_date', models.DateField()), - ('submission_date', models.DateField()), - ('finish_date', models.DateField()), - ('years', models.IntegerField()), - ('status', models.IntegerField(default=0)), - ('project_info_file', models.FileField(blank=True, null=True, upload_to='')), - ('financial_outlay_status', models.IntegerField(default=0)), - ('co_project_investigator_id', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='copi_id', to=settings.AUTH_USER_MODEL)), - ('project_investigator_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pi_id', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['-project_id'], - }, - ), - migrations.CreateModel( - name='staff_allocations', - fields=[ - ('staff_allocation_id', models.IntegerField(primary_key=True, serialize=False)), - ('staff_name', models.CharField(max_length=500)), - ('qualification', models.CharField(max_length=500)), - ('year', models.IntegerField()), - ('stipend', models.IntegerField()), - ('staff_type', models.CharField(default='research', max_length=100)), - ('start_date', models.DateField(default=datetime.date(2024, 4, 27))), - ('end_date', models.DateField(blank=True, null=True)), - ('project_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='research_procedures.projects')), - ('staff_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['-staff_allocation_id'], - }, - ), - migrations.CreateModel( - name='requests', - fields=[ - ('request_id', models.IntegerField(primary_key=True, serialize=False)), - ('request_type', models.CharField(max_length=500)), - ('approval_status', models.IntegerField(default=0)), - ('project_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='research_procedures.projects')), - ('project_investigator_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rj_pi', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['-request_id'], - }, - ), - migrations.CreateModel( - name='financial_outlay', - fields=[ - ('financial_outlay_id', models.IntegerField(primary_key=True, serialize=False)), - ('category', models.CharField(max_length=500)), - ('sub_category', models.CharField(max_length=500)), - ('amount', models.IntegerField()), - ('year', models.IntegerField()), - ('status', models.IntegerField(default=0)), - ('staff_limit', models.IntegerField(default=0)), - ('utilized_amount', models.IntegerField(default=0, null=True)), - ('project_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='research_procedures.projects')), - ], - options={ - 'ordering': ['-financial_outlay_id'], - }, - ), + # migrations.CreateModel( + # name='TechTransfer', + # fields=[ + # ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + # ('pf_no', models.IntegerField()), + # ('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)), + # ('end_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)), + # ], + # ), + # migrations.CreateModel( + # name='ResearchProject', + # fields=[ + # ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + # ('pf_no', models.IntegerField()), + # ('ptype', models.CharField(default='Research', max_length=100)), + # ('pi', models.CharField(default=' ', max_length=1000)), + # ('co_pi', models.CharField(default=' ', max_length=1500)), + # ('title', models.TextField(default=' ', max_length=5000)), + # ('funding_agency', models.CharField(default=' ', max_length=250, null=True)), + # ('financial_outlay', models.CharField(default=' ', max_length=150, null=True)), + # ('status', models.CharField(choices=[('Awarded', 'Awarded'), ('Submitted', 'Submitted'), ('Ongoing', 'Ongoing'), ('Completed', 'Completed')], max_length=10)), + # ('start_date', models.DateField(blank=True, null=True)), + # ('finish_date', models.DateField(blank=True, null=True)), + # ('date_submission', models.DateField(blank=True, null=True)), + # ('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)), + # ], + # ), + # migrations.CreateModel( + # name='ResearchGroup', + # fields=[ + # ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + # ('name', models.CharField(max_length=120)), + # ('description', models.TextField()), + # ('faculty_under_group', models.ManyToManyField(related_name='allfaculty', to=settings.AUTH_USER_MODEL)), + # ('students_under_group', models.ManyToManyField(related_name='allstudents', to=settings.AUTH_USER_MODEL)), + # ], + # ), + # migrations.CreateModel( + # name='Patent', + # fields=[ + # ('application_id', models.AutoField(primary_key=True, serialize=False)), + # ('title', models.CharField(max_length=120)), + # ('ipd_form', models.FileField(blank=True, null=True, upload_to='')), + # ('project_details', models.FileField(blank=True, null=True, upload_to='')), + # ('ipd_form_file', models.TextField(blank=True, null=True)), + # ('project_details_file', models.TextField(blank=True, null=True)), + # ('status', models.CharField(choices=[('Approved', 'Approved'), ('Disapproved', 'Disapproved'), ('Pending', 'Pending')], default='Pending', max_length=20)), + # ('faculty_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')), + # ], + # ), + # migrations.CreateModel( + # name='ConsultancyProject', + # fields=[ + # ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + # ('pf_no', models.IntegerField()), + # ('consultants', models.CharField(max_length=150)), + # ('title', models.CharField(max_length=1000)), + # ('client', models.CharField(max_length=1000)), + # ('financial_outlay', models.IntegerField()), + # ('start_date', models.DateField(blank=True, null=True)), + # ('end_date', models.DateField(blank=True, null=True)), + # ('duration', models.CharField(blank=True, max_length=500, null=True)), + # ('date_entry', models.DateField(blank=True, default=datetime.datetime.now, null=True)), + # ('status', models.CharField(blank=True, choices=[('Completed', 'Completed'), ('Submitted', 'Submitted'), ('Ongoing', 'Ongoing')], default='Ongoing', max_length=10, null=True)), + # ('remarks', models.CharField(blank=True, max_length=1000, 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/research_procedures/models.py b/FusionIIIT/applications/research_procedures/models.py index 9279939d2..a02aad5e3 100644 --- a/FusionIIIT/applications/research_procedures/models.py +++ b/FusionIIIT/applications/research_procedures/models.py @@ -88,6 +88,15 @@ def __str__(self): class Meta: ordering = ['-staff_allocation_id'] +class co_pis(models.Model): + co_pi= models.ForeignKey(User, on_delete=models.CASCADE) + project_id= models.ForeignKey(projects, on_delete=models.CASCADE) + + class Meta: + ordering = ['-project_id'] + + + class requests(models.Model): request_id=models.IntegerField(primary_key=True) project_id= models.ForeignKey(projects, on_delete=models.CASCADE) @@ -101,34 +110,15 @@ def __str__(self): class Meta: ordering = ['-request_id'] -# class requests(models.Model): -# request_id=models.IntegerField(primary_key=True) -# project_id= models.ForeignKey(projects, on_delete=models.CASCADE) -# request_type=models.CharField(max_length=500) -# project_investigator_id=models.ForeignKey(User, related_name='rj_pi' , on_delete= models.CASCADE) -# status= models.IntegerField(default=0) #value 0 means pending -# description=models.CharField(max_length=400,default=None, null= True) -# amount= models.IntegerField(default=0) #value 0 means pending - -# class Meta: -# ordering = ['-request_id'] - -# class rspc_inventory(models.Model): -# inventory_id=models.IntegerField(primary_key=True) -# project_id= models.ForeignKey(projects, on_delete=models.CASCADE) -# project_investigator_id=models.ForeignKey(User, related_name="rin_pi" , on_delete= models.CASCADE) -# status= models.IntegerField(default=0) #value 0 means pending -# description=models.CharField(max_length=400) -# amount= models.IntegerField(default=0) #value 0 means pending - -# class project_staff_info(models.Model): -# staff_id=models.CharField(primary_key=True,max_length=400) -# project_investigator_id= models.ForeignKey(User, on_delete=models.CASCADE) -# project_id=models.ForeignKey(projects, related_name='p_pji', on_delete=models.CASCADE) -# staff_name=models.CharField(max_length=400) -# status=models.IntegerField(default=0) -# description=models.CharField(max_length=400) +class co_project_investigator(models.Model): + co_pi_id= models.ForeignKey(User, on_delete=models.CASCADE) + project_id= models.ForeignKey(projects, on_delete=models.CASCADE) + def __str__(self): + return str(self.co_pi_id) + + class Meta: + ordering = ['-co_pi_id'] diff --git a/FusionIIIT/applications/research_procedures/views.py b/FusionIIIT/applications/research_procedures/views.py index 9c7132296..838cf0d62 100644 --- a/FusionIIIT/applications/research_procedures/views.py +++ b/FusionIIIT/applications/research_procedures/views.py @@ -153,11 +153,12 @@ def add_projects(request): if request.method== "POST": obj= request.POST + projectname= obj.get('project_name') projecttype= obj.get('project_type') fo= obj.get('financial_outlay') pid= obj.get('project_investigator_id') - copid=obj.get('co_project_investigator_id') + copid=obj.get('co_project_investigator_id-1') sa= obj.get('sponsored_agency') startd= obj.get('start_date') subd= obj.get('finish_date') @@ -166,6 +167,8 @@ def add_projects(request): # project_description= obj.get('description') project_info_file= request.FILES.get('project_info_file') + + check = User.objects.filter(username=pid) # print(check[0].username) @@ -191,8 +194,21 @@ def add_projects(request): return render(request,"rs/projects.html") - obj= projects.objects.all() + copi_list = [] + + for key, value in obj.items(): + if key.startswith('co_project_investigator_id-' ): + if value not in copi_list: + check= HoldsDesignation.objects.filter(user__username= value, designation__name= "Professor") #checking for copid to exist + if not check.exists(): + check= HoldsDesignation.objects.filter(user__username=value , designation__name= "Assistant Professor") + if not check.exists(): + messages.error(request,"Request not added, no such co project investigator exists ") + return render(request,"rs/projects.html") + copi_list.append(value) + + obj= projects.objects.all() if len(obj)==0 : projectid=1 @@ -206,6 +222,13 @@ def add_projects(request): return render(request,"rs/projects.html") + for copi in copi_list: + if copi == pid: + messages.error(request,"Request not added, project investigator and co project investigator cannot be same") + return render(request,"rs/projects.html") + + + @@ -227,7 +250,11 @@ def add_projects(request): project_info_file=project_info_file ) - project_investigator_designation = HoldsDesignation.objects.get(user=userpi_instance).designation + pi_designation= HoldsDesignation.objects.get(user=userpi_instance , designation__name="Professor") + if not pi_designation: + pi_designation= HoldsDesignation.objects.get(user=userpi_instance , designation__name="Assistant Professor") + project_investigator_designation= pi_designation.designation + file_x= create_file( uploader=request.user.username, @@ -241,6 +268,12 @@ def add_projects(request): attached_file= project_info_file, ) + + for copi in copi_list: + co_pis.objects.create( + co_pi= User.objects.get(username=copi), + project_id= projects.objects.get(project_id=projectid) + ) research_procedures_notif(request.user, userpi_instance, "Project Added") tracking_obj = Tracking.objects.get(file_id__id=file_x) @@ -529,9 +562,10 @@ def view_project_info(request,id): obj= projects.objects.get(project_id=id) - + copis= co_pis.objects.filter(project_id__project_id=id) data = { "project": obj, + "copis": copis } return render(request,"rs/view_project_info.html", context= data) @@ -1049,6 +1083,19 @@ def change_end_date(request,id): messages.success(request,"End date changed successfully") return redirect("/research_procedures/view_staff_details/"+str(staff_allocation_instance.project_id.project_id)) +def AjaxDropdown(request): + + if request.method == 'POST': + value = request.POST.get('value') + users = User.objects.filter(username__startswith=value) + users = serializers.serialize('json', list(users)) + + context = { + 'users': users + } + return HttpResponse(JsonResponse(context), content_type='application/json') + + def getDesignation(us): user_inst = User.objects.get(username= us) diff --git a/FusionIIIT/templates/rs/add_copis.html b/FusionIIIT/templates/rs/add_copis.html new file mode 100644 index 000000000..d1dabda1c --- /dev/null +++ b/FusionIIIT/templates/rs/add_copis.html @@ -0,0 +1,102 @@ +{% extends 'globals/base.html' %} +{% load static %} + + +{% block title %} +IPR +{% endblock %} + + +{% block body %} + {% block navBar %} + {% include 'dashboard/navbar.html' %} + {% endblock %} + + + + + +{% comment %}The grid starts here!{% endcomment %} +
+ + {% comment %}The left-margin segment!{% endcomment %} +
+ + {% comment %} + The left-rail segment starts here! + {% endcomment %} +
+ + {% comment %}The user image card starts here!{% endcomment %} + {% block usercard %} + {% include 'globals/usercard.html' %} + {% endblock %} + {% comment %}The user image card ends here!{% endcomment %} + +
+ + {% comment %}The Tab-Menu starts here!{% endcomment %} + + {% comment %}The Tab-Menu ends here!{% endcomment %} + +
+ + {% comment %} + The left-rail segment ends here! + {% endcomment %} + + {% comment %} + The central-rail segment starts here! + {% endcomment %} + +
+ + +
+ {% block add_copis %} + {% include 'rs/display_add_copis.html' %} + {% endblock %} +
+ + + + +
+ + {% comment %}The central-rail segment ends here!{% endcomment %} + + {% comment %}The right-rail segment starts here!{% endcomment %} +
+
+ {% comment %} + TODO: the right rail! + {% endcomment %} +
+
+ {% comment %}The right-rail segment ends here!{% endcomment %} + + {% comment %}The right-margin segment!{% endcomment %} +
+ +
+ +{% comment %}The grid ends here!{% endcomment %} + +{% endblock %} + +{% block javascript %} + + + + + + +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/rs/display_add_copis.html b/FusionIIIT/templates/rs/display_add_copis.html new file mode 100644 index 000000000..c44a4cb5d --- /dev/null +++ b/FusionIIIT/templates/rs/display_add_copis.html @@ -0,0 +1,96 @@ + +{% load static %} + +{% block title %} + +{% endblock %} + +{% block add_copis %} + +{% block body %} + + + + + + + + + +
+ + +
+ {% csrf_token %} + +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ +
+ + +
+ +
+ + {% comment %}
+ + +
{% endcomment %} + {% comment %} {% endcomment %} +
+
+
+ +
+{% endblock %} +{% endblock %} diff --git a/FusionIIIT/templates/rs/display_add_projects.html b/FusionIIIT/templates/rs/display_add_projects.html index 39e40db0e..2c8337674 100644 --- a/FusionIIIT/templates/rs/display_add_projects.html +++ b/FusionIIIT/templates/rs/display_add_projects.html @@ -9,8 +9,41 @@ {% block body %} + +