Skip to content
Merged

Ac 5 #10

Show file tree
Hide file tree
Changes from all commits
Commits
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
100 changes: 93 additions & 7 deletions FusionIIIT/applications/scholarships/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
from rest_framework.decorators import api_view
from rest_framework import status
from applications.scholarships.models import Previous_winner, Award_and_scholarship,Mcm,Director_gold,Notional_prize,Director_silver,Proficiency_dm,Release
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from applications.academic_information.models import Spi, Student
from applications.globals.models import (Designation, ExtraInfo,
HoldsDesignation)
from rest_framework import viewsets
from applications.scholarships.api.serializers import PreviousWinnerSerializer,AwardAndScholarshipSerializer,McmSerializer,NotionalPrizeSerializer,DirectorGoldSerializer,DirectorSilverSerializer,ProficiencyDmSerializer,ReleaseSerializer,McmStatusUpdateSerializer,DirectorSilverDecisionSerializer
from applications.scholarships.api.serializers import PreviousWinnerSerializer,AwardAndScholarshipSerializer,McmSerializer,NotionalPrizeSerializer,DirectorGoldSerializer,DirectorSilverSerializer,ProficiencyDmSerializer,ReleaseSerializer
from django.shortcuts import get_object_or_404


#This api is for invite application
class ReleaseCreateView(APIView):
def post(self, request):
Expand All @@ -37,10 +39,9 @@ def post(self, request, pk=None):

if serializer.is_valid():
serializer.save()
status_code = status.HTTP_200_OK if pk is not None else status.HTTP_201_CREATED
return Response(serializer.data, status=status_code)

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
return Response(serializer.data, status=status.HTTP_201_CREATED) # 201 Created response
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) # 400 Bad Request if data is invalid




Expand Down Expand Up @@ -270,6 +271,49 @@ def post(self, request):
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
)


#This api for MCM status that is accept, reject and under review

class McmStatusUpdateView(APIView):
Expand Down Expand Up @@ -386,4 +430,46 @@ def get(self, request):

# # Return the updated entry as a response
# serializer = DirectorSilverSerializer(director_silver)
# return Response(serializer.data, status=status.HTTP_200_OK)
# 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
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.1.5 on 2024-11-18 19:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('scholarships', '0003_auto_20241116_0306'),
]

operations = [
migrations.AddField(
model_name='director_gold',
name='nearest_railwaystations',
field=models.CharField(max_length=25, null=True),
),
migrations.AlterField(
model_name='director_gold',
name='nearest_railwaystation',
field=models.TextField(default='station', max_length=30),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.1.5 on 2024-11-18 19:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('scholarships', '0004_auto_20241118_1917'),
]

operations = [
migrations.RemoveField(
model_name='director_gold',
name='nearest_railwaystations',
),
migrations.AlterField(
model_name='director_gold',
name='nearest_railwaystation',
field=models.CharField(max_length=25, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2024-11-18 19:21

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('scholarships', '0005_auto_20241118_1918'),
]

operations = [
migrations.RenameField(
model_name='mcm',
old_name='Marksheet',
new_name='Marksheets',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2024-11-18 19:21

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('scholarships', '0006_auto_20241118_1921'),
]

operations = [
migrations.RenameField(
model_name='mcm',
old_name='Marksheets',
new_name='Marksheet',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2024-11-18 19:45

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('scholarships', '0007_auto_20241118_1921'),
]

operations = [
migrations.RenameField(
model_name='mcm',
old_name='Marksheet',
new_name='marksheet',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2024-11-18 19:48

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('scholarships', '0008_auto_20241118_1945'),
]

operations = [
migrations.RenameField(
model_name='mcm',
old_name='marksheet',
new_name='Marksheet',
),
]
45 changes: 38 additions & 7 deletions FusionIIIT/applications/scholarships/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
from applications.scholarships.api.views import ScholarshipDetailView,StudentDetailView,DirectorSilverDetailView,DirectorGoldDetailView,DirectorGoldListView,ReleaseCreateView,McmStatusUpdateView,DirectorSilverDecisionView,DirectorGoldAcceptRejectView,DirectorSilverListView
from applications.scholarships.api.views import ScholarshipDetailView,StudentDetailView,DirectorSilverDetailView,DirectorGoldDetailView,DirectorGoldListView,ReleaseCreateView,McmStatusUpdateView,DirectorSilverDecisionView,DirectorGoldAcceptRejectView,DirectorSilverListView,GetReleaseByAwardView
# ,DirectorSilverAcceptRejectView


Expand All @@ -25,7 +25,7 @@
url(r'^getConvocationFlag/$', views.getConvocationFlag, name='getConvocationFlag'),
url(r'^getContent/$', views.getContent, name='getContent'),
url(r'^updateEndDate/$', views.updateEndDate, name='updateEndDate'),
#app -->
#app --> api created by 2022 batch
url(r'get-winners/', GetWinnersView.as_view(), name='get-winners'),
url(r'create-award/', create_award.as_view(), name='create-award'),
url(r'mcm_update/', McmUpdateView.as_view(), name='mcm-update'),
Expand All @@ -36,20 +36,51 @@
url(r'directorgold_update/', DirectorGoldUpdateView.as_view(), name='director-gold-update'),
url(r'proficiencydm_update/', ProficiencyDmUpdateView.as_view(), name='proficiency-dm-update'),
url(r'proficiencydm_show/', ProficiencyDmRetrieveView.as_view(), name='proficiency-dm-update'),
path('award/', AwardAndScholarshipCreateView.as_view(), name='award-create'), # URL for convenor catalog
# path('award/', AwardAndScholarshipCreateView.as_view(), name='award-create'), # URL for convenor catalog

# path('scholarship-details/', ScholarshipDetailView.as_view(), name='scholarship-list'),
# path('director_gold_list/', DirectorGoldListView.as_view(), name='director_gold_list'),
# #path('scholarship-details/<int:student_id>/', ScholarshipDetailView.as_view(), name='scholarship-detail'),
# url(r'student_file_show/', StudentDetailView.as_view(), name='student-file-show'),
# path('director_silver_show/', DirectorSilverDetailView.as_view(), name='director_silver_detail'),
# path('director_gold_view/', DirectorGoldDetailView.as_view(), name='director_gold_detail'),
# path(r'release', ReleaseCreateView.as_view(), name='release_create'),

# below this line all api's are for convenor and assistant

# edit and save the catalog by convenor or assistant
path('award/', AwardAndScholarshipCreateView.as_view(), name='award-create'),

# to show all the applications of mcm to the convenor and assistant
path('scholarship-details/', ScholarshipDetailView.as_view(), name='scholarship-list'),
path('director_gold_list/', DirectorGoldListView.as_view(), name='director_gold_list'),
#path('scholarship-details/<int:student_id>/', ScholarshipDetailView.as_view(), name='scholarship-detail'),

# to show all the application of director's gold to
path('director_gold_list/', DirectorGoldListView.as_view(), name='director_gold_list'),

# to show the all submit details of a particular student to convenor and assistant
url(r'student_file_show/', StudentDetailView.as_view(), name='student-file-show'),
path('director_silver_show/', DirectorSilverDetailView.as_view(), name='director_silver_detail'),

# to show the all submit details of a particular student about director's silver to convenor and assistant
path('director_silver_show/', DirectorSilverDetailView.as_view(), name='director_silver_detail'),

# to show the all submit details of a particular student about director's gold to convenor and assistant
path('director_gold_view/', DirectorGoldDetailView.as_view(), name='director_gold_detail'),
path(r'release', ReleaseCreateView.as_view(), name='release_create'),


# Api for invite appication usecase
path('release', ReleaseCreateView.as_view(), name='release_create'),

# to get the data from relaese table according to the name of award and scholarship
path('releases/get-by-award/', GetReleaseByAwardView.as_view(), name='get-release-by-award'),


# url(r'student_file_show/', StudentDetailView.as_view(), name='student-file-show'),
path('mcm/status-update/', McmStatusUpdateView.as_view(), name='mcm-status-update'),
path('api/director_silver/decision/', DirectorSilverDecisionView.as_view(), name='director_silver_decision'),
path('director-gold/accept-reject/', DirectorGoldAcceptRejectView.as_view(), name='director-gold-accept-reject'),
path('director-silver/', DirectorSilverListView.as_view(), name='director-silver-list'),
# path('director-silver/accept-reject/', DirectorSilverAcceptRejectView.as_view(), name='director-silver-accept-reject'),



]