From 22dbfa066e6bec2254686a36957adcfd58392eaf Mon Sep 17 00:00:00 2001 From: Priyansh <88396544+itsspriyansh@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:20:58 +0530 Subject: [PATCH] Revert "Ac 5" --- FusionIIIT/applications/globals/api/urls.py | 1 - FusionIIIT/applications/globals/api/views.py | 4 - .../migrations/0002_auto_20231116_2323.py | 18 ---- FusionIIIT/applications/globals/views.py | 1 - FusionIIIT/applications/scholarships/urls.py | 2 +- FusionIIIT/applications/scholarships/views.py | 95 +++++++++++-------- .../scholarshipsModule/applyNew.html | 2 +- .../templates/scholarshipsModule/invite.html | 2 +- 8 files changed, 58 insertions(+), 67 deletions(-) delete mode 100644 FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py diff --git a/FusionIIIT/applications/globals/api/urls.py b/FusionIIIT/applications/globals/api/urls.py index e6683eac7..9f4e6c2b5 100644 --- a/FusionIIIT/applications/globals/api/urls.py +++ b/FusionIIIT/applications/globals/api/urls.py @@ -7,7 +7,6 @@ url(r'^auth/login/', views.login, name='login-api'), url(r'^auth/logout/', views.logout, name='logout-api'), # generic profile endpoint - #code of corresponding view is modifiedtemporary because of mismatched designations url(r'^profile/(?P.+)/', views.profile, name='profile-api'), # current user profile url(r'^profile/', views.profile, name='profile-api'), diff --git a/FusionIIIT/applications/globals/api/views.py b/FusionIIIT/applications/globals/api/views.py index c8fd9f5b1..c6723d0ab 100644 --- a/FusionIIIT/applications/globals/api/views.py +++ b/FusionIIIT/applications/globals/api/views.py @@ -117,9 +117,6 @@ def profile(request, username=None): user = get_object_or_404(User, username=username) if username else request.user user_detail = serializers.UserSerializer(user).data profile = serializers.ExtraInfoSerializer(user.extrainfo).data - - print(user) - if profile['user_type'] == 'student': student = user.extrainfo.student skills = serializers.HasSerializer(student.has_set.all(),many=True).data @@ -146,7 +143,6 @@ def profile(request, username=None): } return Response(data=resp, status=status.HTTP_200_OK) elif profile['user_type'] == 'faculty': - print(username) return redirect('/eis/api/profile/' + (username+'/' if username else '')) elif profile['user_type'] == 'staff': resp = { diff --git a/FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py b/FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py deleted file mode 100644 index 51f5a76b5..000000000 --- a/FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2023-11-16 23:23 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='extrainfo', - name='user_status', - field=models.CharField(choices=[('NEW', 'NEW'), ('PRESENT', 'PRESENT')], default='PRESENT', max_length=50), - ), - ] diff --git a/FusionIIIT/applications/globals/views.py b/FusionIIIT/applications/globals/views.py index 9b0303c36..74be358d3 100644 --- a/FusionIIIT/applications/globals/views.py +++ b/FusionIIIT/applications/globals/views.py @@ -789,7 +789,6 @@ 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) diff --git a/FusionIIIT/applications/scholarships/urls.py b/FusionIIIT/applications/scholarships/urls.py index 769dec040..77a292977 100755 --- a/FusionIIIT/applications/scholarships/urls.py +++ b/FusionIIIT/applications/scholarships/urls.py @@ -19,4 +19,4 @@ url(r'^updateEndDate/$', views.updateEndDate, name='updateEndDate'), url(r'^deleteRelease/$', views.deleteRelease, name='deleteRelease'), -] \ No newline at end of file +] diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 9bffc3fb8..0d95daa96 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -110,12 +110,22 @@ def convener_view(request): # It updates the student Notification table on the spacs head sending the mcm invitation if batch == 'All': active_batches = range(datetime.datetime.now().year - 4 , datetime.datetime.now().year + 1) - - query = reduce(or_, (Q(id__id__startswith=int(batch)-2000) for batch in active_batches)) + # 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) recipient = Student.objects.filter(programme=programme).filter(query) else: - recipient = Student.objects.filter(programme=programme, id__id__startswith=int(batch)-2000) - + if(int(batch)>2019): + curbatch=int(batch)%2000 + recipient = Student.objects.filter(programme=programme, id__id__startswith=curbatch) # Notification starts print(recipient) @@ -123,7 +133,6 @@ def convener_view(request): 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, @@ -131,7 +140,6 @@ def convener_view(request): 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, @@ -161,10 +169,8 @@ 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' - 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) + 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') @@ -188,10 +194,8 @@ 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') - 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) + Previous_winner.objects.create( + student=student_id, year=year, award_id=award) convenor = request.user recipient = student_id scholarship_portal_notif( @@ -218,13 +222,12 @@ 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') - 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) + 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') @@ -235,7 +238,8 @@ 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') @@ -246,10 +250,8 @@ 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') - 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) + 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') @@ -452,7 +454,6 @@ def getWinners(request): return JsonResponse(context) 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 @@ -469,9 +470,7 @@ 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 - - print("get convo_flags here") - x = Notification.objects.filter(student_id=request.user.extrainfo.id) + x = Notification.objects.select_related('student_id', 'release_id').filter(student_id=request.user.extrainfo.id) for i in x: i.invite_convocation_accept_flag = True i.save() @@ -1094,27 +1093,45 @@ def sendStudentRenderRequest(request, additionalParams={}): student_batch = getBatch(request.user.extrainfo.student) for dates in release: if checkDate(dates.startdate, dates.enddate): - 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: + 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: x_notif_mcm_flag = True if no_of_mcm_filled > 0: update_mcm_flag = True - elif dates.award == 'Convocation Medals' and dates.batch == "20"+str(request.user.extrainfo.student)[0:2]and dates.programme == request.user.extrainfo.student.programme: + elif dates.award == 'Convocation Medals' and dates.batch == student_batch 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 =="20"+ str(request.user.extrainfo.student)[0:2]: + if dates.award == "Merit-cum-Means Scholarship" and dates.batch == student_batch: 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 == "20"+str(request.user.extrainfo.student)[0:2]: + elif dates.award == 'Convocation Medals' and dates.batch == student_batch: try: x = Notification.objects.select_related('student_id','release_id').get( student_id=request.user.extrainfo.id, release_id=dates.id).delete() @@ -1122,11 +1139,9 @@ def sendStudentRenderRequest(request, additionalParams={}): 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 @@ -1172,4 +1187,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 \ No newline at end of file + return context diff --git a/FusionIIIT/templates/scholarshipsModule/applyNew.html b/FusionIIIT/templates/scholarshipsModule/applyNew.html index 503c8b365..7313aa0aa 100755 --- a/FusionIIIT/templates/scholarshipsModule/applyNew.html +++ b/FusionIIIT/templates/scholarshipsModule/applyNew.html @@ -1129,4 +1129,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/FusionIIIT/templates/scholarshipsModule/invite.html b/FusionIIIT/templates/scholarshipsModule/invite.html index 479a0bd04..a928c3f29 100755 --- a/FusionIIIT/templates/scholarshipsModule/invite.html +++ b/FusionIIIT/templates/scholarshipsModule/invite.html @@ -304,4 +304,4 @@ } -{% endblock %} \ No newline at end of file +{% endblock %}