Skip to content
Merged
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
bcd84d3
debugging and refactoring
sudheerdagar Feb 20, 2024
037f6bc
resolved invitation notifications error
nityatiwari002 Feb 20, 2024
b19aa2d
Merge pull request #1 from nityatiwari002/main
sudheerdagar Feb 20, 2024
6f24ede
added apply convocation functionality
nityatiwari002 Feb 20, 2024
99c0709
Merge branch 'sudheerdagar:main' into main
nityatiwari002 Feb 20, 2024
3a13ee2
fixed profile redirection issue
sudheerdagar Feb 20, 2024
25000d4
Merge pull request #2 from nityatiwari002/main
sudheerdagar Feb 20, 2024
e6e9d2f
fixed profile redirection issues
sudheerdagar Feb 21, 2024
654496a
Merge branch 'main' of https://github.com/sudheerdagar/Fusion
sudheerdagar Feb 21, 2024
dfdc6b3
refactoring and other changes
sudheerdagar Feb 22, 2024
47af12c
GAD -5 Dashboard Changes (#1325)
BlackHAWK2001 Mar 11, 2024
ed642ee
dashboard and usercard updated (#1329)
Arpittak Mar 12, 2024
01ef828
resolved routing error
nityatiwari002 Feb 22, 2024
7eec96a
Merge remote-tracking branch 'upstream/gad-5
sudheerdagar Mar 15, 2024
e1c716a
removed delete button
nityatiwari002 Mar 15, 2024
83d1d94
Merge branch 'main' into main
sudheerdagar Mar 18, 2024
2ad8b76
Merge pull request #3 from nityatiwari002/main
sudheerdagar Mar 18, 2024
4549a6a
Merge branch 'main' of https://github.com/sudheerdagar/Fusion into ac-5
sudheerdagar Mar 18, 2024
e78b2f6
fixed convocation flag errors updated recent invite Ui
sudheerdagar Apr 19, 2024
eabf67e
fixed previous winners data duplications
sudheerdagar Apr 20, 2024
839f35b
fixed update issues with convocation medals
sudheerdagar Apr 20, 2024
f93a37f
refactoring
sudheerdagar Apr 20, 2024
0ea8a42
Merge branch 'ac-5' into ac-5
sudheerdagar Apr 20, 2024
cbfbfbc
final changes and refactoring
sudheerdagar Apr 20, 2024
85f5d36
modified get_mcm_flags functionalities
sudheerdagar Apr 20, 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: 1 addition & 2 deletions FusionIIIT/applications/scholarships/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
url(r'^getConvocationFlag/$', views.getConvocationFlag, name='getConvocationFlag'),
url(r'^getContent/$', views.getContent, name='getContent'),
url(r'^updateEndDate/$', views.updateEndDate, name='updateEndDate'),
url(r'^deleteRelease/$', views.deleteRelease, name='deleteRelease'),

]
]
176 changes: 59 additions & 117 deletions FusionIIIT/applications/scholarships/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from operator import or_
from functools import reduce

from django.http import JsonResponse
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect
Expand All @@ -24,13 +23,9 @@
from .validations import MCM_list, MCM_schema, gold_list, gold_schema, silver_list, silver_schema, proficiency_list,proficiency_schema
from jsonschema import validate
from jsonschema.exceptions import ValidationError
from .helpers import getBatch
# Create your views here.





@login_required(login_url='/accounts/login')
def spacs(request):
convener = Designation.objects.get(name='spacsconvenor')
Expand Down Expand Up @@ -75,20 +70,15 @@ def spacs(request):

@login_required(login_url='/accounts/login')
def convener_view(request):
print(request)

try:
convener = Designation.objects.get(name='spacsconvenor')
hd = HoldsDesignation.objects.get(
user=request.user, designation=convener)
except:
return HttpResponseRedirect('/logout')
if request.method == 'POST':
print("this is a check for post request")
if 'Submit' in request.POST:
print("this is a check for post xfhjgisdfkhlsjk request")
award = request.POST.get('type')
print("award " + award)
programme = request.POST.get('programme')
batch = request.POST.get('batch')
from_date = request.POST.get('From')
Expand All @@ -108,48 +98,37 @@ def convener_view(request):
)

# It updates the student Notification table on the spacs head sending the mcm invitation
if batch == 'All':
if batch == 'all':
active_batches = range(datetime.datetime.now().year - 4 , datetime.datetime.now().year + 1)
# active_batches=str(active_batches)
# active_batches.split(',')
print(active_batches)
querybatch = []
for curbatch in active_batches:
if curbatch > 2019:
curbatch=curbatch%2000
querybatch.append(curbatch)
print( active_batches)
query = reduce(or_, (Q(id__id__startswith=batch) for batch in querybatch))
print(query)
query = reduce(or_, (Q(id__id__startswith=int(batch)-2000) for batch in active_batches))
recipient = Student.objects.filter(programme=programme).filter(query)
else:
if(int(batch)>2019):
curbatch=int(batch)%2000
recipient = Student.objects.filter(programme=programme, id__id__startswith=curbatch)
recipient = Student.objects.filter(programme=programme, id__id__startswith=int(batch)-2000)

# Notification starts
print(recipient)
convenor = request.user
for student in recipient:
scholarship_portal_notif(convenor, student.id.user, 'award_' + award) # Notification
if award == 'Merit-cum-Means Scholarship':
print("MCM")
rel = Release.objects.get(date_time=d_time)
Notification.objects.select_related('student_id','release_id').bulk_create([Notification(
release_id=rel,
student_id=student,
notification_mcm_flag=True,
invite_mcm_accept_flag=False) for student in recipient])
else:
print("convo")
rel = Release.objects.get(date_time=d_time)
Notification.objects.select_related('student_id','release_id').bulk_create([Notification(
release_id=rel,
student_id=student,
notification_convocation_flag=True,
invite_convocation_accept_flag=False) for student in recipient])
# Notification ends
print(batch)

messages.success(request,
award + ' applications are invited successfully for ' + str(batch) + ' batch(es)')
award + ' applications are invited successfully for ' + batch + ' batch(es)')
return HttpResponseRedirect('/spacs/convener_view')

elif 'Email' in request.POST:
Expand All @@ -169,8 +148,10 @@ def convener_view(request):
year = datetime.datetime.now().year
Mcm.objects.select_related('award_id','student').filter(id=pk).update(status='Accept')
request.session['last_clicked'] = 'Accept_MCM'
Previous_winner.objects.create(
student=student_id, year=year, award_id=award)
zest=Previous_winner.objects.filter(student = student_id, year=year, award_id=award)
print(zest)
if(len(zest)==0):
Previous_winner.objects.create(student=student_id, year=year, award_id=award)
convenor = request.user
recipient = student_id
scholarship_portal_notif(convenor, recipient.id.user, 'Accept_MCM')
Expand All @@ -194,8 +175,10 @@ def convener_view(request):
student_id = Director_gold.objects.select_related('student','award_id').get(id=pk).student
year = datetime.datetime.now().year
Director_gold.objects.select_related('student','award_id').filter(id=pk).update(status='Accept')
Previous_winner.objects.create(
student=student_id, year=year, award_id=award)
zest=Previous_winner.objects.filter(student = student_id, year=year, award_id=award)
print(zest)
if(len(zest)==0):
Previous_winner.objects.create(student=student_id, year=year, award_id=award)
convenor = request.user
recipient = student_id
scholarship_portal_notif(
Expand All @@ -222,12 +205,13 @@ def convener_view(request):
student_id = Director_silver.objects.select_related('student','award_id').get(id=pk).student
year = datetime.datetime.now().year
Director_silver.objects.select_related('student','award_id').filter(id=pk).update(status='Accept')
Previous_winner.objects.create(
student=student_id, year=year, award_id=award)
zest=Previous_winner.objects.filter(student = student_id, year=year, award_id=award)
print(zest)
if(len(zest)==0):
Previous_winner.objects.create(student=student_id, year=year, award_id=award)
convenor = request.user
recipient = student_id
scholarship_portal_notif(
convenor, recipient.id.user, 'Accept_Silver')
scholarship_portal_notif(convenor, recipient.id.user, 'Accept_Silver')
request.session['last_clicked'] = 'Accept_Silver'
messages.success(request, 'Application is accepted')
return HttpResponseRedirect('/spacs/convener_view')
Expand All @@ -238,8 +222,7 @@ def convener_view(request):
Director_silver.objects.select_related('student','award_id').filter(id=pk).update(status='Reject')
convenor = request.user
recipient = student_id
scholarship_portal_notif(
convenor, recipient.id.user, 'Reject_Silver')
scholarship_portal_notif(convenor, recipient.id.user, 'Reject_Silver')
request.session['last_clicked'] = 'Reject_Silver'
messages.success(request, 'Application is rejected')
return HttpResponseRedirect('/spacs/convener_view')
Expand All @@ -250,8 +233,10 @@ def convener_view(request):
student_id = Proficiency_dm.objects.select_related('student','award_id').get(id=pk).student
year = datetime.datetime.now().year
Proficiency_dm.objects.select_related('student','award_id').filter(id=pk).update(status='Accept')
Previous_winner.objects.create(
student=student_id, year=year, award_id=award)
zest=Previous_winner.objects.filter(student = student_id, year=year, award_id=award)
print(zest)
if(len(zest)==0):
Previous_winner.objects.create(student=student_id, year=year, award_id=award)
convenor = request.user
recipient = student_id
scholarship_portal_notif(convenor, recipient.id.user, 'Accept_DM')
Expand Down Expand Up @@ -280,7 +265,6 @@ def convener_view(request):

@login_required(login_url='/accounts/login')
def student_view(request):

if request.method == 'POST':
if 'Submit_MCM' in request.POST:
return submitMCM(request)
Expand Down Expand Up @@ -406,54 +390,40 @@ def convenerCatalogue(request):
context['result'] = 'Failure'
return HttpResponse(json.dumps(context), content_type='convenerCatalogue/json')



#below function is refactored and changed as it is not used by the user interface
#it will be changed later for other testing and download of winners
def getWinners(request):
# Extract parameters from the request
award_name = request.GET.get('award_name')
batch_year = int(request.GET.get('batch'))
programme_name = request.GET.get('programme')

# Get the Award_and_scholarship object based on the provided award name
try:
award = Award_and_scholarship.objects.get(award_name=award_name)
except Award_and_scholarship.DoesNotExist:
return JsonResponse({'result': 'Failure', 'message': 'Award not found'})

# Query for previous winners based on the provided criteria
winners = Previous_winner.objects.select_related('student__extra_info').filter(
award = Award_and_scholarship.objects.get(award_name=award_name)
winners = Previous_winner.objects.select_related('student','award_id').filter(
year=batch_year, award_id=award, programme=programme_name)
context = {}
context['student_name'] = []
context['student_program'] = []
context['roll'] = []

context = {
'result': 'Success',
'winners': [],
}

# Process the winners if any found
# If-Else Condition for previous winner if there is or no data in the winner table
if winners:
for winner in winners:
# Fetch extra information for the student
extra_info = winner.student.extra_info

extra_info = ExtraInfo.objects.get(id=winner.student_id)
student_id = Student.objects.get(id=extra_info)
student_name = extra_info.user.first_name
student_roll = winner.student_id
student_program = winner.student.programme

# Append student details to the context
context['winners'].append({
'student_name': student_name,
'roll': student_roll,
'student_program': student_program,
})
student_program = student_id.programme
context['student_name'].append(student_name)
context['roll'].append(student_roll)
context['student_program'].append(student_program)

context['result'] = 'Success'

else:
context['result'] = 'Failure'
context['message'] = 'No winners found for the provided criteria'

return JsonResponse(context)
return HttpResponse(json.dumps(context), content_type='getWinners/json')

def get_MCM_Flag(request): # Here we are extracting mcm_flag
print("get mcm_flags here")
x = Notification.objects.select_related('student_id','release_id').filter(student_id=request.user.extrainfo.id)
for i in x:
i.invite_mcm_accept_flag = True
Expand All @@ -470,7 +440,8 @@ def get_MCM_Flag(request): # Here we are extracting mcm_flag
# return HttpResponseRedirect('/spacs/student_view')

def getConvocationFlag(request): # Here we are extracting convocation_flag
x = Notification.objects.select_related('student_id', 'release_id').filter(student_id=request.user.extrainfo.id)
print("get convo_flags here")
x = Notification.objects.filter(student_id=request.user.extrainfo.id)
for i in x:
i.invite_convocation_accept_flag = True
i.save()
Expand Down Expand Up @@ -520,18 +491,6 @@ def updateEndDate(request):
context['result'] = 'Failure'
return HttpResponse(json.dumps(context), content_type='updateEndDate/json')

def deleteRelease(request):
print("deleteRelease")
id = request.GET.get('id')
is_deleted = Release.objects.filter(pk=id).delete()
request.session['last_clicked'] = "Release_deleted"
context = {}
if is_deleted:
context['result'] = 'Success'
else:
context['result'] = 'Failure'
return HttpResponse(json.dumps(context), content_type='deleteRelease/json')

def getAwardId(request):
award = request.POST.get('award')
a = Award_and_scholarship.objects.get(award_name=award).id
Expand Down Expand Up @@ -1063,14 +1022,14 @@ def sendConvenerRenderRequest(request, additionalParams={}):
source = Constants.FATHER_OCC_CHOICE
time = Constants.TIME
release = Release.objects.all()
notification = Notification.objects.select_related('student_id','release_id').all()
spi = Spi.objects.all()
context.update({ 'source': source, 'time': time, 'ch': ch, 'spi': spi, 'release': release})
context.update(additionalParams)
return render(request, 'scholarshipsModule/scholarships_convener.html', context)

def sendStudentRenderRequest(request, additionalParams={}):
context = getCommonParams(request)

ch = Constants.BATCH
time = Constants.TIME
mother_occ = Constants.MOTHER_OCC_CHOICES
Expand All @@ -1090,58 +1049,41 @@ def sendStudentRenderRequest(request, additionalParams={}):
update_con_flag = False
x_notif_mcm_flag = False
x_notif_con_flag = False
student_batch = getBatch(request.user.extrainfo.student)
for dates in release:
if checkDate(dates.startdate, dates.enddate):
curBatch = dates.batch
checkBatch = str(request.user.extrainfo.student)[0:4]
batchCondition = False
if checkBatch[2] >= "A" and checkBatch[2] <= "Z":
if(curBatch == 'All'):
batchRange = range(datetime.datetime.now().year - 4, datetime.datetime.now().year + 1)
for batches in batchRange :
if int(checkBatch[0:2]) == batches % 2000:
batchCondition = True
elif curBatch == checkBatch:
batchCondition = True
else:
if(curBatch == 'All'):
batchRange = range(datetime.datetime.now().year - 4, datetime.datetime.now().year + 1)
for batch in batchRange:
if str(checkBatch) == batch:
batchCondition = True
elif curBatch == checkBatch:
True
print("bye")


print(curBatch, checkBatch)
if dates.award == 'Merit-cum-Means Scholarship' and batchCondition and dates.programme == request.user.extrainfo.student.programme:
print("sudheer's test --->")
print(request.user.extrainfo.student)
print(str(request.user.extrainfo.student)[0:2])
if dates.award == 'Merit-cum-Means Scholarship' and dates.batch == "20"+str(request.user.extrainfo.student)[0:2]and dates.programme == request.user.extrainfo.student.programme:
x_notif_mcm_flag = True
if no_of_mcm_filled > 0:
update_mcm_flag = True
elif dates.award == 'Convocation Medals' and dates.batch == student_batch and dates.programme == request.user.extrainfo.student.programme:
elif dates.award == 'Convocation Medals' and dates.batch == "20"+str(request.user.extrainfo.student)[0:2]and dates.programme == request.user.extrainfo.student.programme:

x_notif_con_flag = True
if no_of_con_filled > 0:
update_con_flag = True
else:
if dates.award == "Merit-cum-Means Scholarship" and dates.batch == student_batch:

if dates.award == "Merit-cum-Means Scholarship" and dates.batch =="20"+ str(request.user.extrainfo.student)[0:2]:
try:
x = Notification.objects.select_related('student_id','release_id').get(
student_id=request.user.extrainfo.id, release_id=dates.id).delete()
except:
pass
elif dates.award == 'Convocation Medals' and dates.batch == student_batch:
elif dates.award == 'Convocation Medals' and dates.batch == "20"+str(request.user.extrainfo.student)[0:2]:
try:
x = Notification.objects.select_related('student_id','release_id').get(
student_id=request.user.extrainfo.id, release_id=dates.id).delete()
except:
pass

x = Notification.objects.select_related('student_id','release_id').filter(student_id=request.user.extrainfo.id).order_by('-release_id__date_time')
print(x)
show_mcm_flag = False
show_convocation_flag = False
for i in x:
print(i.invite_convocation_accept_flag)
if i.invite_mcm_accept_flag == True:
show_mcm_flag = True
break
Expand All @@ -1156,7 +1098,7 @@ def sendStudentRenderRequest(request, additionalParams={}):
context.update(additionalParams)
return render(request, 'scholarshipsModule/scholarships_student.html',context)

def sendStaffRenderRequest(request, additionalParams={}):
def sendStaffRenderRequest(request, additionalParams={}):
context = getCommonParams(request)
context.update(additionalParams)
return render(request, 'scholarshipsModule/scholarships_staff.html', context)
Expand Down Expand Up @@ -1187,4 +1129,4 @@ def getCommonParams(request):
context = {'mcm': mcm, 'awards': awards, 'student': student, 'gold': gold, 'silver': silver,
'dandm': dandm, 'con': con, 'assis': assis, 'hd': hd, 'hd1': hd1,
'last_clicked': last_clicked, 'year_range': year_range, 'active_batches': active_batches}
return context
return context
Loading