diff --git a/FusionIIIT/applications/research_procedures/api/urls.py b/FusionIIIT/applications/research_procedures/api/urls.py index 232dda90c..55c56e10b 100644 --- a/FusionIIIT/applications/research_procedures/api/urls.py +++ b/FusionIIIT/applications/research_procedures/api/urls.py @@ -23,17 +23,17 @@ # url(r'^api/',include('applications.research_procedures.api.urls')), # path('view_requests//',views.view_requests), path('projects',views.view_projects), - # path('view_project_info//',views.view_project_info), + path('view_project_info//',views.view_project_info), # path('submit_closure_report//',views.submit_closure_report, name="submit_closure_report"), # path('add_fund_requests//',views.add_fund_requests, name="add_fund_requests"), # path('add_staff_requests//',views.add_staff_requests, name="add_staff_requests"), - # path('view_project_inventory//',views.view_project_inventory, name="view_project_inventory"), - # path('view_project_staff//',views.view_project_staff, name="view_project_staff"), + path('view_project_inventory//',views.view_project_inventory, name="view_project_inventory"), + path('view_project_staff//',views.view_project_staff, name="view_project_staff"), # path('add_financial_outlay//',views.add_financial_outlay, name="add_financial_outlay"), # path('financial_outlay//',views.financial_outlay_form, name="financial_outlay_form"), - # path('view_financial_outlay//',views.view_financial_outlay, name="view_financial_outlay"), + path('view_financial_outlay//',views.view_financial_outlay, name="view_financial_outlay"), # path('add_staff_details//',views.add_staff_details, name="add_staff_details"), - # path('view_staff_details//',views.view_staff_details, name="view_staff_details"), + path('view_staff_details//',views.view_staff_details, name="view_staff_details"), # path('add_staff_request//',views.add_staff_request, name="add_staff_request"), # path('inbox',views.inbox, name="inbox"), # path('view_request_inbox',views.view_request_inbox, name="view_request_inbox"), diff --git a/FusionIIIT/applications/research_procedures/api/views.py b/FusionIIIT/applications/research_procedures/api/views.py index 3addf40d4..20483cb8e 100644 --- a/FusionIIIT/applications/research_procedures/api/views.py +++ b/FusionIIIT/applications/research_procedures/api/views.py @@ -1,9 +1,11 @@ from rest_framework.viewsets import ModelViewSet from applications.research_procedures.models import * from .serializers import * +from rest_framework.decorators import api_view from rest_framework.permissions import IsAuthenticatedOrReadOnly from django.shortcuts import redirect, render, get_object_or_404 from rest_framework.response import Response +from django.http import JsonResponse from django.contrib import messages from applications.research_procedures.models import * from applications.globals.models import ExtraInfo, HoldsDesignation, Designation @@ -137,219 +139,256 @@ # messages.success(request,"Successfully created consultancy project") # return redirect(reverse("research_procedures:patent_registration")) -# 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') -# sa= obj.get('sponsored_agency') -# startd= obj.get('start_date') -# subd= obj.get('finish_date') -# finishd= obj.get('finish_date') -# years= obj.get('number_of_years') -# # project_description= obj.get('description') -# project_info_file= request.FILES.get('project_info_file') - -# check = User.objects.filter(username=pid) -# # print(check[0].username) +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') + sa= obj.get('sponsored_agency') + startd= obj.get('start_date') + subd= obj.get('finish_date') + finishd= obj.get('finish_date') + years= obj.get('number_of_years') + # project_description= obj.get('description') + project_info_file= request.FILES.get('project_info_file') + + check = User.objects.filter(username=pid) + # print(check[0].username) -# check= HoldsDesignation.objects.filter(user__username=pid , designation__name= "Professor") -# if not check.exists(): -# check= HoldsDesignation.objects.filter(user__username=pid , designation__name= "Assistant Professor") + check= HoldsDesignation.objects.filter(user__username=pid , designation__name= "Professor") + if not check.exists(): + check= HoldsDesignation.objects.filter(user__username=pid , designation__name= "Assistant Professor") -# if not check.exists(): -# messages.error(request,"Request not added, no such project investigator exists 2") -# return render(request,"rs/projects.html") + if not check.exists(): + messages.error(request,"Request not added, no such project investigator exists 2") + return render(request,"rs/projects.html") -# check= HoldsDesignation.objects.filter(user__username=copid , designation__name= "Professor") -# if not check.exists(): -# check= HoldsDesignation.objects.filter(user__username=copid , designation__name= "Assistant Professor") + check= HoldsDesignation.objects.filter(user__username=copid , designation__name= "Professor") + if not check.exists(): + check= HoldsDesignation.objects.filter(user__username=copid , designation__name= "Assistant Professor") -# if not check.exists(): -# messages.error(request,"Request not added, no such project investigator exists 2") -# return render(request,"rs/projects.html") + if not check.exists(): + messages.error(request,"Request not added, no such project investigator exists 2") + return render(request,"rs/projects.html") -# obj= projects.objects.all() -# if len(obj)==0 : -# projectid=1 + obj= projects.objects.all() + if len(obj)==0 : + projectid=1 -# else : -# projectid= obj[0].project_id+1 - -# userpi_instance = User.objects.get(username=pid) -# usercpi_instance = User.objects.get(username=copid) - -# projects.objects.create( -# project_id=projectid, -# project_name=projectname, -# project_type=projecttype, -# status=0, -# project_investigator_id=userpi_instance, -# co_project_investigator_id=usercpi_instance, -# sponsored_agency=sa, -# start_date=startd, -# submission_date=finishd, -# finish_date=finishd, -# years=years, -# project_info_file=project_info_file + else : + projectid= obj[0].project_id+1 + + userpi_instance = User.objects.get(username=pid) + usercpi_instance = User.objects.get(username=copid) + + projects.objects.create( + project_id=projectid, + project_name=projectname, + project_type=projecttype, + status=0, + project_investigator_id=userpi_instance, + co_project_investigator_id=usercpi_instance, + sponsored_agency=sa, + start_date=startd, + submission_date=finishd, + finish_date=finishd, + years=years, + project_info_file=project_info_file -# ) -# project_investigator_designation = HoldsDesignation.objects.get(user=userpi_instance).designation + ) + project_investigator_designation = HoldsDesignation.objects.get(user=userpi_instance).designation + + file_x= create_file( + uploader=request.user.username, + uploader_designation="rspc_admin", + receiver= pid, + receiver_designation=project_investigator_designation, + src_module="research_procedures", + src_object_id= projectid, + file_extra_JSON= { "message": "Project added successfully"}, + attached_file= project_info_file, + ) + + messages.success(request,"Project added successfully") + categories = category.objects.all() + + data = { + "pid": pid, + "years": list(range(1, int(years) + 1)), + "categories": categories, + } + + return redirect("/research_procedures/financial_outlay/"+str(projectid)) + return render(request,"rs/projects.html") -# file_x= create_file( -# uploader=request.user.username, -# uploader_designation="rspc_admin", -# receiver= pid, -# receiver_designation=project_investigator_designation, -# src_module="research_procedures", -# src_object_id= projectid, -# file_extra_JSON= { "message": "Project added successfully"}, -# attached_file= project_info_file, -# ) +def add_fund_requests(request,pj_id): + data= { + "pj_id": pj_id + } + return render(request,"rs/add_fund_requests.html",context=data) -# messages.success(request,"Project added successfully") -# categories = category.objects.all() +def add_staff_requests(request,pj_id): + data= { + "pj_id": pj_id + } + return render(request,"rs/add_staff_requests.html",context=data) -# data = { -# "pid": pid, -# "years": list(range(1, int(years) + 1)), -# "categories": categories, -# } - -# return redirect("/research_procedures/financial_outlay/"+str(projectid)) -# return render(request,"rs/projects.html") +def add_projects(request): -# def add_fund_requests(request,pj_id): -# data= { -# "pj_id": pj_id -# } -# return render(request,"rs/add_fund_requests.html",context=data) + # designation = getDesignation(request.user.username) + # print("designation is " + designation) + # if designation != 'rspc_admin': + # messages.error(request, 'Only RSPC Admin can add projects') + # return redirect("/research_procedures") -# def add_staff_requests(request,pj_id): -# data= { -# "pj_id": pj_id -# } -# return render(request,"rs/add_staff_requests.html",context=data) + 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') + sa= obj.get('sponsored_agency') + startd= obj.get('start_date') + subd= obj.get('finish_date') + finishd= obj.get('finish_date') + years= obj.get('number_of_years') + # project_description= obj.get('description') + project_info_file= request.FILES.get('project_info_file') -# def add_requests(request,id,pj_id): -# if request.method == 'POST': -# obj=request.POST + check = User.objects.filter(username=pid) + # print(check[0].username) -# if(id=='0') : -# projectid = pj_id -# reqtype = obj.get('request_type') -# stats =0 -# desc= obj.get('description') -# amt= obj.get('amount') -# check= projects.objects.filter(project_id=projectid) -# if not check.exists(): -# messages.error(request,"Request not added, no such project exists") -# return render(request,"rs/add_fund_requests.html") + + + check= get_obj_by_username_and_designation(pid, "Professor") #checking for pid to exist -# check= projects.objects.filter(project_id= projectid, project_investigator_id__username=pi_id) -# if not check.exists(): -# messages.error(request,"Request not added, no such project investigator exists") -# return render(request,"rs/add_fund_requests.html") + if not check.exists(): + check= HoldsDesignation.objects.filter(user__username=pid , designation__name= "Assistant Professor") + if not check.exists(): + messages.error(request,"Request not added, no such project investigator exists ") + return render(request,"rs/projects.html") -# pi_id_instance=User.objects.get(username= request.user.username ) -# project_instance=projects.objects.get(project_id=projectid) + + + check= get_obj_by_username_and_designation(copid, "Professor") #checking for copid to exist -# obj= requests.objects.all() -# if len(obj)==0 : -# requestid=1 - -# else : -# requestid= obj[0].request_id+1 - -# requests.objects.create( -# request_id=requestid, -# project_id=project_instance, -# request_type="funds", -# project_investigator_id=pi_id_instance, -# status=stats, description=desc, amount= amt -# ) -# rspc_inventory.objects.create( -# inventory_id=requestid, -# project_id=project_instance, -# project_investigator_id=pi_id_instance, -# status=stats, -# description=desc, amount= amt -# ) -# messages.success(request,"Request added successfully") -# return render(request,"rs/add_fund_requests.html") - -# if(id=='1'): -# projectid = obj.get('project_id') -# pi_id = obj.get('project_investigator_id') -# stats = obj.get('status') -# desc= obj.get('description') - -# obj= requests.objects.all() -# if len(obj)==0 : -# requestid=1 - -# else : -# requestid= obj[0].request_id+1 + if not check.exists(): + check= HoldsDesignation.objects.filter(user__username=copid , 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") -# check= projects.objects.filter(project_id=projectid) -# if not check.exists(): -# messages.error(request,"Request not added, no such project exists") -# return render(request,"rs/add_fund_requests.html") + + obj= projects.objects.all() -# check= projects.objects.filter(project_id= projectid, project_investigator_id__username=pi_id) -# if not check.exists(): -# messages.error(request,"Request not added, no such project investigator exists") -# return render(request,"rs/add_fund_requests.html") -# pi_id_instance=User.objects.get(username=pi_id) -# project_instance=projects.objects.get(project_id=projectid) + if len(obj)==0 : + projectid=1 + + else : + projectid= obj[0].project_id+1 -# requests.objects.create( -# request_id=requestid, -# project_id=project_instance, -# request_type="staff", -# project_investigator_id=pi_id_instance, -# description=desc -# ) -# messages.success(request,"Request added successfully") -# return redirect("/research_procedures") -# return render(request, "rs/add_requests.html") + for project in obj: + if project.project_name==projectname: + messages.error(request,"Request not added, project name already exists") + return render(request,"rs/projects.html") + + + userpi_instance = User.objects.get(username=pid) + usercpi_instance = User.objects.get(username=copid) + + projects.objects.create( + project_id=projectid, + project_name=projectname, + project_type=projecttype, + status=0, + project_investigator_id=userpi_instance, + co_project_investigator_id=usercpi_instance, + sponsored_agency=sa, + start_date=startd, + submission_date=finishd, + finish_date=finishd, + years=years, + project_info_file=project_info_file + + ) + project_investigator_designation = HoldsDesignation.objects.get(user=userpi_instance).designation + + file_x= create_file( + uploader=request.user.username, + uploader_designation="rspc_admin", + receiver= pid, + receiver_designation=project_investigator_designation, + src_module="research_procedures", + src_object_id= projectid, + file_extra_JSON= { "message": "Project added successfully"}, + attached_file= project_info_file, + ) + + messages.success(request,"Project added successfully") + categories = category.objects.all() + + data = { + "pid": pid, + "years": list(range(1, int(years) + 1)), + "categories": categories, + } + + return redirect("/research_procedures/financial_outlay/"+str(projectid)) + return render(request,"rs/projects.html") +@api_view(['GET']) def view_projects(request): queryset= projects.objects.all() - + print('---------------------------------------------------------------') rspc_admin = HoldsDesignation.objects.get(designation__name="rspc_admin") rspc_admin =rspc_admin.user.username + data = Project_serializer(queryset, many=True).data if request.user.username == rspc_admin: data= { - "projects": queryset, + "projects": data, "username": request.user.username, } - return render(request,"rs/view_projects_rspc.html", context= data) + return JsonResponse(data,safe=False) queryset= projects.objects.filter(project_investigator_id__username= request.user.username) - + data2 = Project_serializer(queryset, many=True).data data= { - "projects": queryset, + "projects": data2, "username": request.user.username, } # print(data) # print(request.user.username) - return Response(data, status=status.HTTP_200_OK) + return JsonResponse(data,safe=False) +def view_project_info(request,id): + id= int(id) + obj= projects.objects.filter(project_id=id) + data = Project_serializer(obj, many=True).data + + + # data = { + # "project": obj, + # } + data = { + "project": data, + } + + return JsonResponse(data , safe=False) # def view_requests(request,id): @@ -382,28 +421,29 @@ def view_projects(request): # return render(request,"rs/view_requests.html", context= data) -# def view_financial_outlay(request,pid): +def view_financial_outlay(request,pid): -# table_data=financial_outlay.objects.filter(project_id=pid).order_by('category', 'sub_category') -# project= projects.objects.get(project_id=pid); - -# years = set(table_data.values_list('year', flat=True)) - -# category_data = {} -# for category in table_data.values_list('category', flat=True).distinct(): -# category_data[category] = table_data.filter(category=category) + table_data=financial_outlay.objects.filter(project_id=pid).order_by('category', 'sub_category') + project= projects.objects.get(project_id=pid) + years = set(table_data.values_list('year', flat=True)) + + category_data = {} + for category in table_data.values_list('category', flat=True).distinct(): + category_data[category] = financial_outlay_serializer(table_data.filter(category=category) , many=True).data + # category_data = category_serializer(category_data , many=True).data + -# data = { -# 'table_title': 'Total Budget Outlay', -# 'table_caption': '...', # Add caption if needed -# 'project_name':project.project_name, -# 'years': list(years), -# 'category_data': category_data, -# } + data = { + 'table_title': 'Total Budget Outlay', + 'table_caption': '...', # Add caption if needed + 'project_name':project.project_name, + 'years': list(years), + 'category_data': category_data, + } -# # print(data) -# return render(request,"rs/view_financial_outlay.html", context= data) + # print(data) + return JsonResponse(data , safe=False) # def submit_closure_report(request,id): # id= int(id) @@ -421,32 +461,33 @@ def view_projects(request): # } # messages.success(request,"Closure report submitted successfully") # return render(request,"rs/view_projects_rspc.html",context=data) - -# def view_project_inventory(request,pj_id): -# pj_id=int(pj_id) -# queryset= requests.objects.filter(project_id=pj_id,request_type="funds") - - -# # print(queryset) +@api_view(['GET']) +def view_project_inventory(request,pj_id): + pj_id=int(pj_id) + queryset= (requests.objects.filter(project_id=pj_id,request_type="funds")) + queryset = requests_serializer(queryset , many=True).data -# data= { -# "requests": queryset, -# "username": request.user.username -# } -# return render(request,"rs/view_project_inventory.html",context=data) + # print(queryset) + + data= { + "requests": queryset, + "username": request.user.username + } + return JsonResponse(data , safe=True) -# def view_project_staff(request,pj_id): -# pj_id=int(pj_id) -# queryset= requests.objects.filter(project_id=pj_id,request_type="staff") +def view_project_staff(request,pj_id): + pj_id=int(pj_id) + queryset= requests.objects.filter(project_id=pj_id,request_type="staff") + queryset = requests_serializer(queryset , many = True).data -# # print(queryset) + # print(queryset) -# data= { -# "requests": queryset, -# "username": request.user.username -# } -# return render(request,"rs/view_project_staff.html",context=data) + data= { + "requests": queryset, + "username": request.user.username + } + return JsonResponse(data , safe = True) # def projectss(request): # return render(request,"rs/projects.html") @@ -548,36 +589,33 @@ def view_projects(request): # return render(request, "rs/add_staff_details.html", context=data) +@api_view(['GET']) +def view_staff_details(request, pid): + staff_records = staff_allocations.objects.filter(project_id=pid) + data_by_year = {} + project = projects.objects.get(project_id=pid) + # project = Project_serializer(project , many=True).data + + for record in staff_records: + year = record.year + if year not in data_by_year: + data_by_year[year] = [] + data_by_year[year].append({ + 'staff_id': int(record.staff_id.id), + 'staff_name': record.staff_name, + 'qualification': record.qualification, + 'stipend': record.stipend + }) + + context = { + 'data_by_year': data_by_year, + 'project_name': project.project_name + # Add other necessary fields from project here + } -# def view_staff_details(request,pid): - -# staff_records = staff_allocations.objects.filter(project_id=pid) - -# # Initialize a dictionary to hold data year-wise -# data_by_year = {} -# project = projects.objects.get(project_id=pid) - -# # Iterate through each staff record -# for record in staff_records: -# year = record.year -# if year not in data_by_year: -# data_by_year[year] = [] -# data_by_year[year].append({ -# 'staff_id' : record.staff_id, -# 'staff_name': record.staff_name, -# 'qualification': record.qualification, -# 'stipend': record.stipend -# }) -# # Pass the organized data to the template -# context = { -# 'data_by_year': data_by_year, -# 'project_name':project.project_name -# } -# rspc_admin = HoldsDesignation.objects.get(designation__name="rspc_admin") - - -# return render(request, "rs/view_staff_details.html", context) + rspc_admin = HoldsDesignation.objects.get(designation__name="rspc_admin") + return JsonResponse(context, safe=True) # def add_financial_outlay(request,pid): 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 %} + +