Skip to content
Merged

Os 2 #1353

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5c61a54
GAD-5: Fix responsiveness (#1125)
Lawful2002 Feb 23, 2023
9a4fc4d
Merge branch 'main' into gad-5
akshatnema Mar 15, 2023
b295d7f
Merge branch 'main' into gad-5
akshatnema Mar 15, 2023
72e34e7
Merge branch 'main' into gad-5
akshatnema Mar 18, 2023
721ee82
Merge branch 'main' into gad-5
akshatnema Mar 19, 2023
91ef4e9
Merge branch 'main' into gad-5
akshatnema Mar 23, 2023
da49572
Merge branch 'main' into gad-5
akshatnema Mar 26, 2023
4a090eb
added announcements and pathologist schedule
prem-charan Feb 22, 2024
c1359b7
Added pylint (#1302)
hardiksharma11 Mar 11, 2024
ed210c1
Revert "Added pylint (#1302)" (#1324)
ChaudharyRaman Mar 11, 2024
47af12c
GAD -5 Dashboard Changes (#1325)
BlackHAWK2001 Mar 11, 2024
ed642ee
dashboard and usercard updated (#1329)
Arpittak Mar 12, 2024
6de59f0
changes in programme_cuuriculam,adding version to models (#1330)
anudeeps0306 Mar 12, 2024
d40e94d
Fixing ui bugs (#1335)
SukulSarve Mar 17, 2024
ea33899
Merge branch 'FusionIIIT:main' into main
prem-charan Mar 18, 2024
2544877
module completed
prem-charan Mar 18, 2024
6fd6c92
Merge branch 'gad-5' of https://github.com/FusionIIIT/Fusion
prem-charan Mar 18, 2024
8e48ec5
integrated dashboard
prem-charan Mar 18, 2024
06400a0
Merge branch 'main' of https://github.com/FusionIIIT/Fusion
prem-charan Mar 18, 2024
6f15803
Merge branch 'main' of https://github.com/prem-charan/Fusion
prem-charan Mar 18, 2024
aff778c
Revert "integrated dashboard"
prem-charan Mar 18, 2024
56085d3
Revert "module completed"
prem-charan Mar 18, 2024
be33bf1
Revert "module completed"
prem-charan Mar 18, 2024
a01412a
Revert "integrated dashboard"
prem-charan Mar 18, 2024
a6dc4ac
errors corrected
prem-charan Mar 18, 2024
ccab172
errors resolved
prem-charan Mar 18, 2024
5a08fa8
added dashboard and corrected errors
prem-charan Mar 18, 2024
c7e713d
Merge branch 'os1' into OS-2
prem-charan Mar 18, 2024
1136a5c
removed Migrations
prem-charan Mar 18, 2024
4cb570d
removed migrations
prem-charan Mar 19, 2024
adae4ed
removed migrations
prem-charan Mar 19, 2024
408ce7d
corrected errors
prem-charan Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ node_modules/

FusionIIIT/static/
package-lock.json

# migrations
**/migrations/*
5 changes: 5 additions & 0 deletions FusionIIIT/Fusion/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def global_vars(request):
return {
'global_var': request.session.get('currentDesignationSelected', 'default_value'),
'global_var2': request.session.get('allDesignations', 'default_value2'),
}
48 changes: 48 additions & 0 deletions FusionIIIT/Fusion/middleware/custom_middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# custom_middleware.py
from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
from applications.globals.models import (ExtraInfo, Feedback, HoldsDesignation,
Issue, IssueImage, DepartmentInfo)
from django.shortcuts import get_object_or_404, redirect, render

def user_logged_in_middleware(get_response):
@receiver(user_logged_in)
def user_logged_in_handler(sender, user, request, **kwargs):
if 'function_executed' not in request.session:
# Run the function only if the flag is not set
# Assuming user is a model with the desired data field, retrieve the data
# For example, if your User model has a field named 'custom_field', you can access it like:
if user.is_authenticated:
desig = list(HoldsDesignation.objects.select_related('user','working','designation').all().filter(working = request.user).values_list('designation'))
print(desig)
b = [i for sub in desig for i in sub]
design = HoldsDesignation.objects.select_related('user','designation').filter(working=request.user)

designation=[]

designation.append(str(user.extrainfo.user_type))
for i in design:
if str(i.designation) != str(user.extrainfo.user_type):
print('-------')
print(i.designation)
print(user.extrainfo.user_type)
print('')
designation.append(str(i.designation))

for i in designation:
print(i)

request.session['currentDesignationSelected'] = designation[0]
request.session['allDesignations'] = designation
print("logged iN")

# Set the flag in the session to indicate that the function has bee+n executed
request.session['function_executed'] = True

def middleware(request):
if request.user.is_authenticated:
user_logged_in_handler(request.user, request.user, request)
response = get_response(request)
return response

return middleware
2 changes: 2 additions & 0 deletions FusionIIIT/Fusion/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'Fusion.middleware.custom_middleware.user_logged_in_middleware',
]

ROOT_URLCONF = 'Fusion.urls'
Expand All @@ -178,6 +179,7 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'Fusion.context_processors.global_vars',
],
},
},
Expand Down
3 changes: 2 additions & 1 deletion FusionIIIT/applications/globals/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
# Endpoint to reset all passwords in DEV environment
url(r'^resetallpass/$', views.reset_all_pass, name='resetallpass'),
# API urls
url(r'^api/', include('applications.globals.api.urls'))
url(r'^api/', include('applications.globals.api.urls')),
url(r'^update_global_variable/$', views.update_global_variable, name='update_global_var'),
]
87 changes: 82 additions & 5 deletions FusionIIIT/applications/globals/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,21 +740,26 @@ def dashboard(request):

}
# a=HoldsDesignation.objects.select_related('user','working','designation').filter(designation = user)
print(context)
print(type(user.extrainfo.user_type))
if(request.user.get_username() == 'director'):
return render(request, "dashboard/director_dashboard2.html", {})
elif( "dean_rspc" in designation):
return render(request, "dashboard/dashboard.html", context)
elif user.extrainfo.user_type != 'student':
elif user.extrainfo.user_type != "student":
print ("inside")
designat = HoldsDesignation.objects.select_related().filter(user=user)
response = {'designat':designat}
context.update(response)
return render(request, "dashboard/dashboard.html", context)
else:
print ("inside2")

return render(request, "dashboard/dashboard.html", context)


@login_required(login_url=LOGIN_URL)
def profile(request, username=None):
def profile(request, username=None):
"""
Generic endpoint for views.
If it's a faculty, redirects to /eis/profile/*
Expand All @@ -768,16 +773,76 @@ def profile(request, username=None):
"""
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))
print("profile",profile)
if(str(user.extrainfo.user_type)=='faculty'):
print("profile")
return HttpResponseRedirect('/eis/profile/' + (username if username else ''))
if(str(user.extrainfo.department)=='department: Academics'):
print("profile2")
return HttpResponseRedirect('/aims')
current = HoldsDesignation.objects.select_related('user','working','designation').filter(Q(working=user, designation__name="student"))

array = [
"student",
"CC convenor",
"Mechatronic convenor",
"mess_committee",
"mess_convener",
"alumini",
"Electrical_AE",
"Electrical_JE",
"Civil_AE",
"Civil_JE",
"co-ordinator",
"co co-ordinator",
"Convenor",
"Convener",
"cc1convener",
"CC2 convener",
"mess_convener_mess2",
"mess_committee_mess2"
]

# queryset = HoldsDesignation.objects.select_related('user','working','designation').filter(Q(working=user))

# for obj in queryset:
# designation_name = obj.designation.name
# print("designation_name",designation_name)

# design = False
# if designation_name in array:
# design = True
# print("design",design)
# print("designation_name",designation_name)
# if design:
# current = HoldsDesignation.objects.select_relapted('user','working','designation').filter(Q(working=user, designation__name=designation_name))
# for obj in current:
# obj.designation.name = obj.designation.name.replace(designation_name, 'student')

designation_name = ""
design = False

current = HoldsDesignation.objects.select_related('user', 'working', 'designation').filter(Q(working=user))

for obj in current:
designation_name = obj.designation.name
if designation_name in array:
design = True
break

if design:
current = HoldsDesignation.objects.filter(working=user, designation__name=designation_name)
for obj in current:
obj.designation.name = obj.designation.name.replace(designation_name, 'student')

print(user.extrainfo.user_type)
print("current",current)
if current:
print("profile3")
student = get_object_or_404(Student, Q(id=profile.id))
print("student",student)
if editable and request.method == 'POST':
if 'studentapprovesubmit' in request.POST:
status = PlacementStatus.objects.select_related('notify_id','unique_id__id__user','unique_id__id__department').filter(pk=request.POST['studentapprovesubmit']).update(invitation='ACCEPTED', timestamp=timezone.now())
Expand Down Expand Up @@ -979,6 +1044,7 @@ 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)
return render(request, "globals/student_profile.html", context)
else:
return redirect("/")
Expand Down Expand Up @@ -1176,4 +1242,15 @@ def search(request):
if len(search_results) == 0:
search_results = []
context = {'sresults':search_results}
return render(request, "globals/search.html", context)
return render(request, "globals/search.html", context),

@login_required(login_url=LOGIN_URL)
def update_global_variable(request):
if request.method == 'POST':
selected_option = request.POST.get('dropdown')
request.session['currentDesignationSelected'] = selected_option
print(selected_option)
print(request.session['currentDesignationSelected'])
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
# Redirect to home if not a POST request or some issue occurs
return HttpResponseRedirect(reverse('home'))
7 changes: 4 additions & 3 deletions FusionIIIT/applications/health_center/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.contrib import admin

from .models import (Ambulance_request, Appointment, Complaint, Counter,
Doctor, Expiry, Hospital, Hospital_admit, Medicine,
Prescribed_medicine, Prescription, Schedule, Stock)
from .models import *

admin.site.register(Doctor)
admin.site.register(Appointment)
Expand All @@ -17,3 +15,6 @@
admin.site.register(Medicine)
admin.site.register(Prescribed_medicine)
admin.site.register(Schedule)
admin.site.register(Announcements)
admin.site.register(SpecialRequest)
admin.site.register(Pathologist)
6 changes: 6 additions & 0 deletions FusionIIIT/applications/health_center/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class ScheduleSerializer(serializers.ModelSerializer):
class Meta:
model=Schedule
fields=('__all__')

class AnnouncementSerializer(serializers.ModelSerializer):

class Meta:
model=Announcements
fields=('__all__')


class CounterSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 0 additions & 2 deletions FusionIIIT/applications/health_center/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from datetime import datetime, timedelta, time,date
from django.db import transaction
from notification.views import healthcare_center_notif

from rest_framework.permissions import IsAuthenticated
from rest_framework.authentication import TokenAuthentication
from rest_framework import status
Expand Down Expand Up @@ -353,4 +352,3 @@ def compounder_view_api(request):
resp = {'message': 'invalid request'}
return Response(data=resp,status=status.HTTP_404_NOT_FOUND) # compounder view ends


64 changes: 58 additions & 6 deletions FusionIIIT/applications/health_center/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from datetime import date

from applications.globals.models import ExtraInfo

Expand All @@ -21,16 +22,32 @@ class Constants:
(1, 'Dr.Vinay'),

)

NAME_OF_PATHOLOGIST = (
(0, 'Dr.Ajay'),
(1, 'Dr.Rahul'),

)

class Doctor(models.Model):
doctor_name = models.IntegerField(choices=Constants.NAME_OF_DOCTOR)
doctor_phone = models.CharField(max_length=10)
doctor_name = models.CharField(choices=Constants.NAME_OF_DOCTOR, max_length=50)
doctor_phone = models.IntegerField(max_length=10)
specialization = models.CharField(max_length=100)
active = models.BooleanField(default=True)

def __str__(self):
return self.doctor_name

class Pathologist(models.Model):
pathologist_name = models.CharField(choices=Constants.NAME_OF_PATHOLOGIST, max_length=50)
pathologist_phone = models.IntegerField(max_length=10)
specialization = models.CharField(max_length=100)
active = models.BooleanField(default=True)

def __str__(self):
return self.pathologist_name


class Complaint(models.Model):
user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE)
feedback = models.CharField(max_length=100, null=True, blank=False) #This is the feedback given by the compounder
Expand Down Expand Up @@ -65,7 +82,7 @@ class Hospital(models.Model):
def __str__(self):
return self.hospital_name


class Expiry(models.Model):
medicine_id=models.ForeignKey(Stock,on_delete=models.CASCADE)
quantity = models.IntegerField(default=0)
Expand All @@ -78,22 +95,28 @@ def __str__(self):
return self.medicine_id.medicine_name

class Schedule(models.Model):
doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE)
day = models.IntegerField(choices=Constants.DAYS_OF_WEEK)
doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE, default=0)
pathologist_id = models.ForeignKey(Pathologist,on_delete=models.CASCADE, default=0)
day = models.CharField(choices=Constants.DAYS_OF_WEEK, max_length=10)
from_time = models.TimeField(null=True,blank=True)
to_time = models.TimeField(null=True,blank=True)
room = models.IntegerField()
date = models.DateField(auto_now=True)



class Counter(models.Model):
count=models.IntegerField(default=0)
fine=models.IntegerField(default=0)
doc_count=models.IntegerField(default=0)
patho_count=models.IntegerField(default=0)

def doctor_count(self):
self.doc_count+=1
return ""
def pathologist_count(self):
self.doc_count+=1
return ""
def increment(self):
self.count+=1
return ""
Expand All @@ -105,8 +128,12 @@ def range_count(self):
dif=0
elif self.count<=4:
dif=self.doc_count-self.count
else:
elif self.count<=4:
dif=self.count-self.doc_count
elif self.count<=4:
dif=self.patho_count-self.count
else:
dif=self.count-self.patho_count
return range(dif)
def empty_fine(self):
self.count=0
Expand Down Expand Up @@ -165,3 +192,28 @@ class Hospital_admit(models.Model):
admission_date = models.DateField()
discharge_date = models.DateField(null=True, blank=True)
reason = models.CharField(max_length=50)

class Announcements(models.Model):
anno_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='announcements_made')
ann_date = models.DateTimeField(default="04-04-2021")
message = models.CharField(max_length=200)
batch = models.CharField(max_length=40,default="Year-1")
department = models.CharField(max_length=40,default="ALL")
programme = models.CharField(max_length=10)
upload_announcement = models.FileField(upload_to='health_center/upload_announcement', null=True, default=" ")
def __str__(self):
return str(self.anno_id.user.username)


class SpecialRequest(models.Model):
request_ann_maker = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='special_requests_made')
request_date = models.DateTimeField(default=date.today)
brief = models.CharField(max_length=20, default='--')
request_details = models.CharField(max_length=200)
upload_request = models.FileField(blank=True)
status = models.CharField(max_length=50,default='Pending')
remarks = models.CharField(max_length=300, default="--")
request_receiver = models.CharField(max_length=30, default="--")

def __str__(self):
return str(self.request_ann_maker.user.username)
Loading