diff --git a/FusionIIIT/applications/notifications_extension/api/views.py b/FusionIIIT/applications/notifications_extension/api/views.py index e4c125786..75054ddd5 100644 --- a/FusionIIIT/applications/notifications_extension/api/views.py +++ b/FusionIIIT/applications/notifications_extension/api/views.py @@ -147,7 +147,7 @@ def post(self, request, *args, **kwargs): recipient_id = request.data.get('recipient') type = request.data.get('type') User = get_user_model() - recipient = User.objects.get(pk=recipient_id) + recipient = User.objects.get(username=recipient_id) # Trigger the notification function scholarship_portal_notif(sender, recipient, type) diff --git a/FusionIIIT/applications/scholarships/api/views.py b/FusionIIIT/applications/scholarships/api/views.py index c1ee16c7e..ff8651008 100644 --- a/FusionIIIT/applications/scholarships/api/views.py +++ b/FusionIIIT/applications/scholarships/api/views.py @@ -25,6 +25,27 @@ def post(self, request): return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +class CheckApplicationWindowView(APIView): + def post(self, request): + award_name = request.data.get('award') + current_date = datetime.date.today() + + if not award_name: + return Response({'result': 'Failure', 'error': 'Award is a required field'}, status=status.HTTP_400_BAD_REQUEST) + + try: + #Get all the rows with the award name + releases = Release.objects.filter(award=award_name) + except Release.DoesNotExist: + return Response({'result': 'Failure', 'message': 'No release found for the specified award'}, status=status.HTTP_200_OK) + for release in releases: + # Check if the current date is within the start and end dates of the release + if release.startdate <= current_date <= release.enddate: + return Response({'result': 'Success', 'message': 'Application window is open.'}, status=status.HTTP_200_OK) + + # If the current date is outside the start and end dates + return Response({'result': 'Failure', 'message': 'Application window is closed.'}, status=status.HTTP_200_OK) + #This API is for editing the catalogue by convenor and assistant and saving in the database class AwardAndScholarshipCreateView(APIView): def post(self, request, pk=None): @@ -418,47 +439,6 @@ def get(self, request): serializer = DirectorSilverSerializer(director_silver_entries, many=True) return Response(serializer.data, status=status.HTTP_200_OK) -class GetReleaseByAwardView(APIView): - - def post(self, request, *args, **kwargs): - # Get the award name from the request - award_name = request.data.get('award') - - # Check if the award variable is provided - if not award_name: - return Response( - {'result': 'Failure', 'error': 'Award is a required field'}, - status=status.HTTP_400_BAD_REQUEST - ) - - # Fetch records from the Release table where the award matches - releases = Release.objects.filter(award=award_name) - - # Check if any records were found - if releases.exists(): - # Build the response data - data = [] - for release in releases: - data.append({ - 'id': release.id, - 'date_time': release.date_time, - 'programme': release.programme, - 'startdate': release.startdate, - 'enddate': release.enddate, - 'award': release.award, - 'remarks': release.remarks, - 'batch': release.batch, - 'notif_visible': release.notif_visible, - }) - - return Response({'result': 'Success', 'data': data}, status=status.HTTP_200_OK) - - # If no records found - return Response( - {'result': 'Failure', 'error': 'No releases found for the specified award'}, - status=status.HTTP_404_NOT_FOUND - ) - class McmDocumentsRetrieveView(APIView): permission_classes = [IsAuthenticated] diff --git a/FusionIIIT/applications/scholarships/urls.py b/FusionIIIT/applications/scholarships/urls.py index e7f5d77b4..c36ab14a4 100755 --- a/FusionIIIT/applications/scholarships/urls.py +++ b/FusionIIIT/applications/scholarships/urls.py @@ -1,10 +1,12 @@ from django.conf.urls import url from django.urls import path, include from rest_framework.routers import DefaultRouter +from django.urls import path, include +from rest_framework.routers import DefaultRouter from . import views from applications.scholarships.api.views import GetWinnersView -from applications.scholarships.api.views import create_award,McmUpdateView, McmRetrieveView, DirectorSilverRetrieveView,DirectorSilverUpdateView,DirectorGoldRetrieveView,DirectorGoldUpdateView,ProficiencyDmRetrieveView,ProficiencyDmUpdateView,AwardAndScholarshipCreateView,DirectorSilverMarksheetView,DirectorGoldMarksheetView +from applications.scholarships.api.views import create_award,McmUpdateView, McmRetrieveView, DirectorSilverRetrieveView,DirectorSilverUpdateView,DirectorGoldRetrieveView,DirectorGoldUpdateView,ProficiencyDmRetrieveView,ProficiencyDmUpdateView,AwardAndScholarshipCreateView,DirectorSilverMarksheetView,DirectorGoldMarksheetView, CheckApplicationWindowView from applications.scholarships.api.views import ScholarshipDetailView,StudentDetailView,DirectorSilverDetailView,DirectorGoldDetailView,DirectorGoldListView,DMProficiencyListView,ReleaseCreateView,McmStatusUpdateView,DirectorSilverDecisionView,DMProficiencyDecisionView,DirectorGoldAcceptRejectView,DirectorSilverListView,GetReleaseByAwardView,McmDocumentsRetrieveView # ,DirectorSilverAcceptRejectView @@ -83,5 +85,6 @@ path('medals/marksheet/', DirectorSilverMarksheetView.as_view(), name='director_silver_marksheet'), path('medals/marksheet/gold/', DirectorGoldMarksheetView.as_view(), name='director_gold_marksheet'), path('dm-proficiency-list/', DMProficiencyListView.as_view(), name='proficiency-dm'), + path('check-application-window/', CheckApplicationWindowView.as_view(), name='check-application-window'), ] \ No newline at end of file diff --git a/FusionIIIT/notification/views.py b/FusionIIIT/notification/views.py index 314e04e1f..aa4aa194e 100644 --- a/FusionIIIT/notification/views.py +++ b/FusionIIIT/notification/views.py @@ -300,6 +300,8 @@ def scholarship_portal_notif(sender, recipient, type): verb = "Your Mcm form has been accepted " elif type == 'Reject_MCM': verb = "Your Mcm form has been rejected as you have not fulfilled the required criteria " + elif type == 'MCM_UNDER_REVIEW': + verb = "Your Mcm form is under review" elif type == 'Accept_Gold': verb = "Your Convocation form for Director's Gold Medal has been accepted " elif type == 'Reject_Gold': @@ -310,7 +312,7 @@ def scholarship_portal_notif(sender, recipient, type): verb = "Your Convocation form for Director's Silver Medal has been rejected " elif type == 'Accept_DM': verb = "Your Convocation form for D&M Proficiency Gold Medal has been accepted " - elif type == 'Reject_Silver': + elif type == 'Reject_DM': verb = "Your Convocation form for D&M Proficiency Gold Medal has been rejected " notify.send(sender=sender, recipient=recipient, url=url, module=module, verb=verb)