Skip to content

Commit

Permalink
Merge pull request #1592 from SharanKumar06/rspc-2025-gad7
Browse files Browse the repository at this point in the history
Rspc 2025 gad7
  • Loading branch information
prajjwalkapoor authored May 4, 2024
2 parents 3f60f80 + 89f0220 commit dfe2c57
Show file tree
Hide file tree
Showing 8 changed files with 442 additions and 121 deletions.
154 changes: 73 additions & 81 deletions FusionIIIT/applications/research_procedures/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)),
# ],
# ),
]
44 changes: 17 additions & 27 deletions FusionIIIT/applications/research_procedures/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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']



Expand Down
55 changes: 51 additions & 4 deletions FusionIIIT/applications/research_procedures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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")






Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
Loading

0 comments on commit dfe2c57

Please sign in to comment.