From 07750f7f5d81f45547a4502aca07fb1ef5be6ac5 Mon Sep 17 00:00:00 2001 From: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Date: Fri, 10 Feb 2023 23:50:21 +0530 Subject: [PATCH 01/17] =?UTF-8?q?Fix=20problem=20regarding=20fetching=20ba?= =?UTF-8?q?tch=20for=20students=20enrolled=20in=20batch=202=E2=80=A6=20(#1?= =?UTF-8?q?030)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FusionIIIT/applications/scholarships/helpers.py | 14 ++++++++++++++ FusionIIIT/applications/scholarships/views.py | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 FusionIIIT/applications/scholarships/helpers.py diff --git a/FusionIIIT/applications/scholarships/helpers.py b/FusionIIIT/applications/scholarships/helpers.py new file mode 100644 index 000000000..489f340a4 --- /dev/null +++ b/FusionIIIT/applications/scholarships/helpers.py @@ -0,0 +1,14 @@ +import subprocess +from datetime import datetime + +from django.conf import settings + + +def getBatch(roll): + batch = "20" + if(str(roll)[2].isdigit()): + return str(roll)[0:4] + + else: + batch+=str(roll)[0:2] + return batch \ No newline at end of file diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 5f547149f..ba5d4bec5 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -23,6 +23,7 @@ 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. @@ -1039,24 +1040,25 @@ 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): - if dates.award == 'Merit-cum-Means Scholarship' and dates.batch == str(request.user.extrainfo.student)[0:4] and dates.programme == request.user.extrainfo.student.programme: + if dates.award == 'Merit-cum-Means Scholarship' and dates.batch == student_batch 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 == str(request.user.extrainfo.student)[0:4] 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 == str(request.user.extrainfo.student)[0:4]: + 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 == str(request.user.extrainfo.student)[0:4]: + 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() From 91e248c3dba56d2a8db04cdaf5f774d202803e73 Mon Sep 17 00:00:00 2001 From: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Date: Mon, 13 Feb 2023 15:52:01 +0530 Subject: [PATCH 02/17] Fix form render for students of 2020 batch and later (#1103) --- FusionIIIT/applications/scholarships/views.py | 9 +++------ FusionIIIT/templates/dashboard/modules.html | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index ba5d4bec5..ef9c33c87 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -99,13 +99,11 @@ def convener_view(request): ) # It updates the student Notification table on the spacs head sending the mcm invitation - if batch == 'all': + if batch.lower() == 'all': active_batches = range(datetime.datetime.now().year - 4 , datetime.datetime.now().year + 1) - query = reduce(or_, (Q(id__id__startswith=batch) for batch in active_batches)) - recipient = Student.objects.filter(programme=programme).filter(query) + recipient = Student.objects.filter(programme=programme).filter(batch__in=active_batches) else: - recipient = Student.objects.filter(programme=programme, id__id__startswith=batch) - + recipient = Student.objects.filter(programme=programme, batch=batch) # Notification starts convenor = request.user for student in recipient: @@ -1013,7 +1011,6 @@ 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) diff --git a/FusionIIIT/templates/dashboard/modules.html b/FusionIIIT/templates/dashboard/modules.html index 73fc33d85..3a33bda1b 100755 --- a/FusionIIIT/templates/dashboard/modules.html +++ b/FusionIIIT/templates/dashboard/modules.html @@ -116,7 +116,7 @@ {% comment %}A single modules row starts here!{% endcomment %}
- +
From bcd84d36b0b36c9d70c77039bab85ee9867ce930 Mon Sep 17 00:00:00 2001 From: sudheer dagar Date: Tue, 20 Feb 2024 13:20:34 +0530 Subject: [PATCH 03/17] debugging and refactoring --- .../migrations/0002_auto_20231116_2323.py | 18 +++++ FusionIIIT/applications/scholarships/urls.py | 1 + FusionIIIT/applications/scholarships/views.py | 65 +++++++++++++++++-- FusionIIIT/notification/views.py | 2 + FusionIIIT/templates/dashboard/modules.html | 2 +- .../scholarshipsModule/applyNew.html | 6 +- .../templates/scholarshipsModule/invite.html | 35 +++++++++- 7 files changed, 119 insertions(+), 10 deletions(-) create mode 100644 FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py diff --git a/FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py b/FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py new file mode 100644 index 000000000..51f5a76b5 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py @@ -0,0 +1,18 @@ +# 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/scholarships/urls.py b/FusionIIIT/applications/scholarships/urls.py index fd5a3516f..77a292977 100755 --- a/FusionIIIT/applications/scholarships/urls.py +++ b/FusionIIIT/applications/scholarships/urls.py @@ -17,5 +17,6 @@ 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'), ] diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 5f547149f..4369e68f2 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -3,6 +3,7 @@ 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 @@ -70,6 +71,8 @@ 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( @@ -77,8 +80,11 @@ def convener_view(request): 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') @@ -98,14 +104,26 @@ 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) - query = reduce(or_, (Q(id__id__startswith=batch) for batch in active_batches)) + # active_batches=str(active_batches) + # active_batches.split(',') + querybatch = [] + for batch in active_batches: + if batch > 2019: + batch=batch%2000 + querybatch.append(batch) + 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: + if(batch>2019): + batch=batch%2000 recipient = Student.objects.filter(programme=programme, id__id__startswith=batch) # Notification starts + print(recipient) convenor = request.user for student in recipient: scholarship_portal_notif(convenor, student.id.user, 'award_' + award) # Notification @@ -126,7 +144,7 @@ def convener_view(request): # Notification ends messages.success(request, - award + ' applications are invited successfully for ' + batch + ' batch(es)') + award + ' applications are invited successfully for ' + str(batch) + ' batch(es)') return HttpResponseRedirect('/spacs/convener_view') elif 'Email' in request.POST: @@ -257,6 +275,7 @@ 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) @@ -481,6 +500,18 @@ 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 @@ -1020,6 +1051,7 @@ def sendConvenerRenderRequest(request, additionalParams={}): def sendStudentRenderRequest(request, additionalParams={}): context = getCommonParams(request) + ch = Constants.BATCH time = Constants.TIME mother_occ = Constants.MOTHER_OCC_CHOICES @@ -1041,7 +1073,30 @@ def sendStudentRenderRequest(request, additionalParams={}): x_notif_con_flag = False for dates in release: if checkDate(dates.startdate, dates.enddate): - if dates.award == 'Merit-cum-Means Scholarship' and dates.batch == str(request.user.extrainfo.student)[0:4] and dates.programme == request.user.extrainfo.student.programme: + curBatch = dates.batch + checkBatch = str(request.user.extrainfo.student)[0:4] + batchCondition = False + if checkBatch[2:4] == "BC": + 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 @@ -1081,7 +1136,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) diff --git a/FusionIIIT/notification/views.py b/FusionIIIT/notification/views.py index 0480575b8..4d55c2b9b 100644 --- a/FusionIIIT/notification/views.py +++ b/FusionIIIT/notification/views.py @@ -148,6 +148,8 @@ def scholarship_portal_notif(sender, recipient, type): if type.startswith('award'): s = type.split('_') + # print("psss") + # print(type, s) verb = "Invitation to apply for " + s[1] elif type == 'Accept_MCM': verb = "Your Mcm form has been accepted " diff --git a/FusionIIIT/templates/dashboard/modules.html b/FusionIIIT/templates/dashboard/modules.html index 73fc33d85..ca37247d7 100755 --- a/FusionIIIT/templates/dashboard/modules.html +++ b/FusionIIIT/templates/dashboard/modules.html @@ -116,7 +116,7 @@ {% comment %}A single modules row starts here!{% endcomment %}
-{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/scholarshipsModule/invite.html b/FusionIIIT/templates/scholarshipsModule/invite.html index a928c3f29..bfcf6795e 100755 --- a/FusionIIIT/templates/scholarshipsModule/invite.html +++ b/FusionIIIT/templates/scholarshipsModule/invite.html @@ -210,7 +210,6 @@ {{ i.date_time }} {{ i.programme}} - {{ i.batch }} - {% endfor %} @@ -228,17 +227,6 @@
Cancel
-
-
Delete Of Application
-
-
-
-
Update
-
Cancel
-
-
-{% endblock %} +{% endblock %} \ No newline at end of file From eabf67e6af366097fe1131852a21e8b5c2ac7d59 Mon Sep 17 00:00:00 2001 From: sudheerdagar Date: Sat, 20 Apr 2024 12:19:02 +0530 Subject: [PATCH 13/17] fixed previous winners data duplications --- FusionIIIT/applications/scholarships/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 142687e6e..99ed99131 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -148,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') From 839f35b3d67cb86df521a7e8cf0344b5f10fbd0a Mon Sep 17 00:00:00 2001 From: sudheerdagar Date: Sat, 20 Apr 2024 14:31:06 +0530 Subject: [PATCH 14/17] fixed update issues with convocation medals --- FusionIIIT/applications/scholarships/views.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 99ed99131..bbcbffb16 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -175,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( @@ -203,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') @@ -219,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') @@ -231,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') From f93a37f8efb2bf95c6fd1ca0086e788c0bbcdca4 Mon Sep 17 00:00:00 2001 From: sudheerdagar Date: Sat, 20 Apr 2024 14:35:34 +0530 Subject: [PATCH 15/17] refactoring --- .../migrations/0002_auto_20231116_2323.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 FusionIIIT/applications/globals/migrations/0002_auto_20231116_2323.py 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), - ), - ] From cbfbfbcdbcbe95b20a19afc440155f82434496af Mon Sep 17 00:00:00 2001 From: sudheerdagar Date: Sat, 20 Apr 2024 21:31:35 +0530 Subject: [PATCH 16/17] final changes and refactoring --- FusionIIIT/applications/scholarships/urls.py | 1 - FusionIIIT/applications/scholarships/views.py | 3 +- .../scholarshipsModule/applyNew.html | 16 +++------ .../templates/scholarshipsModule/invite.html | 35 +------------------ 4 files changed, 7 insertions(+), 48 deletions(-) diff --git a/FusionIIIT/applications/scholarships/urls.py b/FusionIIIT/applications/scholarships/urls.py index 769dec040..121cdd116 100755 --- a/FusionIIIT/applications/scholarships/urls.py +++ b/FusionIIIT/applications/scholarships/urls.py @@ -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'), ] \ No newline at end of file diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 9fc2f60db..2818832d6 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -648,7 +648,7 @@ def submitMCM(request): status="INCOMPLETE", ) messages.success( - request, award + ' Application is successfully submitted' + request, award + ' Application is successfully Updated' ) break else: @@ -1120,7 +1120,6 @@ 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: diff --git a/FusionIIIT/templates/scholarshipsModule/applyNew.html b/FusionIIIT/templates/scholarshipsModule/applyNew.html index 503c8b365..b240a9157 100755 --- a/FusionIIIT/templates/scholarshipsModule/applyNew.html +++ b/FusionIIIT/templates/scholarshipsModule/applyNew.html @@ -33,7 +33,7 @@ @@ -318,7 +318,7 @@
{% endif %} {% else %} -
+
Applications not invited or has already been submitted
{% endif %} @@ -368,7 +368,7 @@
{% endif %} {% else %} -
+
Apply
{% endif %} @@ -957,7 +957,7 @@
- @@ -1077,7 +1077,7 @@ success: function (response) { if(response.result==='Success'){ location.reload(); - console.log("reuk", response.result) + console.log(response.result) } else{ console.log(response.result); @@ -1104,12 +1104,6 @@ } }); }); - - $(document).on('click', '#submit_silver', function (event){ - event.preventDefault(); - $.ajax() - }) -