Skip to content

Commit

Permalink
Ac 1 Request to merge in staging again. (#1373)
Browse files Browse the repository at this point in the history
* Checked the sidebar after acad-admin login and fixed the (#1113)

fix: icons that were disabled or not working.

* Enabled all modules for access (#1120)

* AC-1 : Add functionality to add and update courses (#1300)

* Add functionality to add and update courses

* Course version added

* Delete FusionIIIT/Fusion/settings/development.py

* Delete FusionIIIT/applications/academic_procedures/migrations/0002_auto_20240218_1206.py

* Delete FusionIIIT/applications/eis/migrations/0002_auto_20240218_1206.py

* Delete FusionIIIT/applications/globals/migrations/0002_auto_20240218_1206.py

* Delete FusionIIIT/applications/globals/migrations/0003_auto_20240218_1235.py

* Delete FusionIIIT/applications/globals/migrations/0004_auto_20240218_1242.py

* Delete FusionIIIT/applications/globals/migrations/0005_auto_20240218_1325.py

* Delete FusionIIIT/applications/globals/migrations/0006_auto_20240218_1336.py

* Delete FusionIIIT/applications/globals/migrations/0007_auto_20240218_1601.py

* Delete FusionIIIT/applications/globals/migrations/0008_auto_20240218_1942.py

* Delete FusionIIIT/applications/globals/migrations/0009_auto_20240219_2217.py

* Delete FusionIIIT/applications/globals/migrations/0010_auto_20240219_2232.py

* Delete FusionIIIT/applications/scholarships/migrations/0002_auto_20240218_1206.py

* Delete requirements.txt

* Delete FusionIIIT/applications/programme_curriculum/migrations/0002_auto_20240312_1929.py

* Delete FusionIIIT/applications/programme_curriculum/migrations/0003_auto_20240312_1944.py

* Delete FusionIIIT/applications/programme_curriculum/migrations/0004_course_latest_version.py

* Delete FusionIIIT/applications/programme_curriculum/migrations/0005_auto_20240313_0128.py

* AC-1 Updated according to dashboard (#1355)

* GAD-5: Fix responsiveness (#1125)

Co-authored-by: A Anunaya <[email protected]>
Co-authored-by: Aksh Bansal <[email protected]>

* GAD -5 Dashboard Changes (#1325)

* dashboard and usercard updated (#1329)

* Fixing ui bugs (#1335)

* Ac1 Updated Dashboard

---------

Co-authored-by: Harshvardhan Singh <[email protected]>
Co-authored-by: A Anunaya <[email protected]>
Co-authored-by: Aksh Bansal <[email protected]>
Co-authored-by: akshatnema <[email protected]>
Co-authored-by: BlackHAWK2001 <[email protected]>
Co-authored-by: Arpit Tak <[email protected]>
Co-authored-by: SukulSarve <[email protected]>

* Added pylint  (#1302)

* Create bandit_security_test.yml

Added Bandit security test for python

* Update bandit_security_test.yml

* Update bandit_security_test.yml

* Create pylint.yml

* Update pylint.yml

* Update pylint.yml

* Revert "Added pylint  (#1302)" (#1324)

This reverts commit c1359b7.

* changes in programme_cuuriculam,adding version to models (#1330)

* Ac-1 updated model.py (#1372)

* GAD-5: Fix responsiveness (#1125)

Co-authored-by: A Anunaya <[email protected]>
Co-authored-by: Aksh Bansal <[email protected]>

* GAD -5 Dashboard Changes (#1325)

* dashboard and usercard updated (#1329)

* Fixing ui bugs (#1335)

* Ac1 Updated Dashboard

* changes

* Changes in model.py

* Changes in model.py

---------

Co-authored-by: Harshvardhan Singh <[email protected]>
Co-authored-by: A Anunaya <[email protected]>
Co-authored-by: Aksh Bansal <[email protected]>
Co-authored-by: akshatnema <[email protected]>
Co-authored-by: BlackHAWK2001 <[email protected]>
Co-authored-by: Arpit Tak <[email protected]>
Co-authored-by: SukulSarve <[email protected]>

---------

Co-authored-by: EyeOfHorus158 <[email protected]>
Co-authored-by: Yathartha Goenka <[email protected]>
Co-authored-by: akshatnema <[email protected]>
Co-authored-by: Ravichendraa <[email protected]>
Co-authored-by: Harshvardhan Singh <[email protected]>
Co-authored-by: A Anunaya <[email protected]>
Co-authored-by: Aksh Bansal <[email protected]>
Co-authored-by: BlackHAWK2001 <[email protected]>
Co-authored-by: Arpit Tak <[email protected]>
Co-authored-by: SukulSarve <[email protected]>
Co-authored-by: Hardik Sharma <[email protected]>
Co-authored-by: Raman Chaudhary <[email protected]>
Co-authored-by: Anudeep Sanapala <[email protected]>
  • Loading branch information
14 people authored Mar 20, 2024
1 parent 6de59f0 commit 16523a7
Show file tree
Hide file tree
Showing 47 changed files with 5,156 additions and 410 deletions.
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'))
11 changes: 8 additions & 3 deletions FusionIIIT/applications/programme_curriculum/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin
from django.contrib.admin.options import ModelAdmin
from .models import Programme, Discipline, Curriculum, Semester, Course, Batch, CourseSlot,CourseInstructor
from .models import Programme, Discipline, Curriculum, Semester, Course, Batch, CourseSlot,CourseInstructor, CourseProposal,UpdateCourseProposal


class ProgrammeAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -29,7 +29,10 @@ class BatchAdmin(admin.ModelAdmin):
class CourseSlotAdmin(admin.ModelAdmin):
list_display = ('name', 'type', 'course_slot_info','semester')
list_filter = ('type', 'courses',)

class CourseProposalAdmin(admin.ModelAdmin):
list_display = ('faculty_name','faculty_code', 'name', 'code',)
class UpdateCourseProposalAdmin(admin.ModelAdmin):
list_display = ('faculty_name','faculty_code', 'name', 'code',)

# Register your models here.
admin.site.register(Discipline, DisciplineAdmin)
Expand All @@ -39,4 +42,6 @@ class CourseSlotAdmin(admin.ModelAdmin):
admin.site.register(Course, CourseAdmin)
admin.site.register(Batch, BatchAdmin)
admin.site.register(CourseSlot, CourseSlotAdmin)
admin.site.register(CourseInstructor)
admin.site.register(CourseInstructor)
admin.site.register(CourseProposal,CourseProposalAdmin)
admin.site.register(UpdateCourseProposal,UpdateCourseProposalAdmin)
10 changes: 9 additions & 1 deletion FusionIIIT/applications/programme_curriculum/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class Meta:
model = Course
fields = {'code': ['icontains'],
'name': ['icontains'],
'version': ['exact'],
'working_course': ['exact'],
'disciplines': ['exact'],
}
widgets = {
'code' : django_filters.CharFilter(forms.TextInput(attrs={'placeholder': 'Course Code','max_length': 10,})),
'name' : forms.TextInput(attrs={'placeholder': 'Course/Project Name','max_length': 100,}),
'name' : django_filters.CharFilter(forms.TextInput(attrs={'placeholder': 'Course/Project Name','max_length': 100,})),
'code' : django_filters.CharFilter(forms.TextInput(attrs={'placeholder': 'Version','max_length': 10,})),
'working_course' : django_filters.CharFilter(forms.CheckboxInput(attrs={'class': 'ui checkbox'})),
'disciplines' : django_filters.CharFilter(forms.SelectMultiple(attrs={'class':'ui fluid search selection dropdown',})),
}
Expand All @@ -32,4 +34,10 @@ class CurriculumFilter(django_filters.FilterSet):
class Meta:
model = Curriculum
fields = {'name': ['icontains'],
}
'version': ['exact'],
}
widgets = {
'name' : forms.TextInput(attrs={'placeholder': 'Course/Project Name','max_length': 100,}),
'name' : django_filters.CharFilter(forms.TextInput(attrs={'placeholder': 'Course/Project Name','max_length': 100,})),
'code' : django_filters.CharFilter(forms.TextInput(attrs={'placeholder': 'Version','max_length': 10,})),
}
Loading

0 comments on commit 16523a7

Please sign in to comment.