Skip to content

Commit fb2765a

Browse files
authored
Merge pull request #8 from PriyanshuXcoder/ac-5
Ac 5
2 parents dc372ee + 0d4edbd commit fb2765a

File tree

8 files changed

+215
-7
lines changed

8 files changed

+215
-7
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 3.1.5 on 2024-11-16 02:33
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('central_mess', '0003_merge_20241110_1253'),
10+
('central_mess', '0004_merge_20241115_1610'),
11+
]
12+
13+
operations = [
14+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 3.1.5 on 2024-11-16 02:33
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('globals', '0004_merge_20241115_1610'),
10+
('globals', '0005_auto_20241115_1710'),
11+
]
12+
13+
operations = [
14+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 3.1.5 on 2024-11-16 02:33
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('online_cms', '0003_merge_20241110_1253'),
10+
('online_cms', '0004_merge_20241115_1509'),
11+
]
12+
13+
operations = [
14+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 3.1.5 on 2024-11-16 02:32
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('research_procedures', '0003_merge_20241115_1509'),
10+
('research_procedures', '0003_merge_20241110_1253'),
11+
]
12+
13+
operations = [
14+
]

FusionIIIT/applications/scholarships/api/serializers.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@
44
from applications.scholarships.models import Award_and_scholarship,Previous_winner,Mcm,Director_silver,Director_gold,Notional_prize,Proficiency_dm,Release
55

66

7+
class McmStatusUpdateSerializer(serializers.ModelSerializer):
8+
class Meta:
9+
model = Mcm
10+
fields = ['status']
11+
12+
13+
14+
15+
class DirectorSilverDecisionSerializer(serializers.ModelSerializer):
16+
class Meta:
17+
model = Director_silver
18+
fields = ['id', 'status']
19+
20+
def validate_status(self, value):
21+
if value not in ['ACCEPTED', 'REJECTED']:
22+
raise serializers.ValidationError("Status must be either 'ACCEPTED' or 'REJECTED'.")
23+
return value
24+
25+
26+
727

828
class ReleaseSerializer(serializers.ModelSerializer):
929
class Meta:

FusionIIIT/applications/scholarships/api/views.py

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from applications.globals.models import (Designation, ExtraInfo,
88
HoldsDesignation)
99
from rest_framework import viewsets
10-
from applications.scholarships.api.serializers import PreviousWinnerSerializer,AwardAndScholarshipSerializer,McmSerializer,NotionalPrizeSerializer,DirectorGoldSerializer,DirectorSilverSerializer,ProficiencyDmSerializer,ReleaseSerializer
10+
from applications.scholarships.api.serializers import PreviousWinnerSerializer,AwardAndScholarshipSerializer,McmSerializer,NotionalPrizeSerializer,DirectorGoldSerializer,DirectorSilverSerializer,ProficiencyDmSerializer,ReleaseSerializer,McmStatusUpdateSerializer,DirectorSilverDecisionSerializer
11+
from django.shortcuts import get_object_or_404
1112

1213

1314
class ReleaseCreateView(APIView):
@@ -255,3 +256,123 @@ def post(self, request):
255256

256257
serializer = DirectorGoldSerializer(director_gold_entry)
257258
return Response(serializer.data, status=status.HTTP_200_OK)
259+
260+
261+
#This api for MCM status that is accept, reject and under review
262+
263+
class McmStatusUpdateView(APIView):
264+
def post(self, request):
265+
# Fetch the Mcm instance based on the provided primary key (pk)
266+
mcm_instance = get_object_or_404(Mcm)
267+
268+
# Deserialize the input data with the existing object
269+
serializer = McmStatusUpdateSerializer(mcm_instance, data=request.data, partial=True)
270+
271+
# Validate the data
272+
if serializer.is_valid():
273+
# Save the updated status
274+
serializer.save()
275+
return Response({"message": "Status updated successfully", "data": serializer.data}, status=status.HTTP_200_OK)
276+
277+
# Return validation errors
278+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
279+
280+
281+
282+
#This api for Director silver accepting and rejecting the application by convenor and assistant
283+
284+
class DirectorSilverDecisionView(APIView):
285+
def post(self, request):
286+
# Deserialize the request data
287+
serializer = DirectorSilverDecisionSerializer(data=request.data)
288+
289+
if serializer.is_valid():
290+
try:
291+
# Retrieve the Director_silver instance using the provided id
292+
director_silver = Director_silver.objects.get(id=request.data['id'])
293+
294+
# Update the status field
295+
director_silver.status = serializer.validated_data['status']
296+
director_silver.save()
297+
298+
return Response({"message": f"Application has been {director_silver.status.lower()}."},
299+
status=status.HTTP_200_OK)
300+
301+
except Director_silver.DoesNotExist:
302+
return Response({"error": "Director_silver entry not found."},
303+
status=status.HTTP_404_NOT_FOUND)
304+
305+
# If the data is invalid
306+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
307+
308+
309+
310+
##This api for Director gold accepting and rejecting the application by convenor and assistant
311+
312+
class DirectorGoldAcceptRejectView(APIView):
313+
def post(self, request):
314+
# Get the ID of the Director_gold entry to update
315+
director_gold_id = request.data.get('id')
316+
action = request.data.get('action') # 'accept' or 'reject'
317+
318+
# Check if the action is valid
319+
if action not in ['accept', 'reject']:
320+
return Response({'error': 'Invalid action. Please choose either "accept" or "reject".'}, status=status.HTTP_400_BAD_REQUEST)
321+
322+
try:
323+
# Fetch the Director_gold entry from the database using the ID
324+
director_gold = Director_gold.objects.get(id=director_gold_id)
325+
except Director_gold.DoesNotExist:
326+
return Response({'error': 'Director_gold entry not found.'}, status=status.HTTP_404_NOT_FOUND)
327+
328+
# Update the status based on the action
329+
if action == 'accept':
330+
director_gold.status = 'ACCEPTED'
331+
else:
332+
director_gold.status = 'REJECTED'
333+
334+
# Save the updated Director_gold entry
335+
director_gold.save()
336+
337+
# Return the updated entry as a response
338+
serializer = DirectorGoldSerializer(director_gold)
339+
return Response(serializer.data, status=status.HTTP_200_OK)
340+
341+
342+
class DirectorSilverListView(APIView):
343+
"""
344+
API View to list all entries of the Director_silver model.
345+
"""
346+
def get(self, request):
347+
director_silver_entries = Director_silver.objects.all()
348+
serializer = DirectorSilverSerializer(director_silver_entries, many=True)
349+
return Response(serializer.data, status=status.HTTP_200_OK)
350+
351+
class DirectorSilverAcceptRejectView(APIView):
352+
def post(self, request):
353+
# Get the ID of the Director_silver entry to update
354+
director_silver_id = request.data.get('id')
355+
action = request.data.get('action') # 'accept' or 'reject'
356+
357+
# Check if the action is valid
358+
if action not in ['accept', 'reject']:
359+
return Response({'error': 'Invalid action. Choose either "accept" or "reject".'}, status=status.HTTP_400_BAD_REQUEST)
360+
361+
try:
362+
# Fetch the Director_silver entry from the database using the ID
363+
director_silver = Director_silver.objects.get(id=director_silver_id)
364+
except Director_silver.DoesNotExist:
365+
return Response({'error': 'Director_silver entry not found.'}, status=status.HTTP_404_NOT_FOUND)
366+
367+
# Update the status based on the action
368+
if action == 'accept':
369+
director_silver.status = 'ACCEPTED'
370+
else:
371+
director_silver.status = 'REJECTED'
372+
373+
# Save the updated Director_silver entry
374+
director_silver.save()
375+
376+
# Return the updated entry as a response
377+
serializer = DirectorSilverSerializer(director_silver)
378+
return Response(serializer.data, status=status.HTTP_200_OK)

FusionIIIT/applications/scholarships/models.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ class Constants:
99
('Complete', 'COMPLETE'),
1010
('Incomplete', 'INCOMPLETE'),
1111
('Reject', 'REJECT'),
12-
('Accept', 'ACCEPT')
12+
('Accept', 'ACCEPT'),
13+
('ACCEPT', 'Accept'),
14+
('REJECT', 'Reject'),
15+
('UNDER_REVIEW', 'Under Review')
1316

1417
)
1518
TIME = (
@@ -114,7 +117,7 @@ class Mcm(models.Model):
114117
Aadhar_card = models.FileField(null=False, blank=False)
115118
Fee_Receipt = models.FileField(null=False, blank=False)
116119
forms = models.FileField(null=True, blank=True)
117-
status = models.CharField(max_length=10, choices=Constants.STATUS_CHOICES, default='INCOMPLETE')
120+
status = models.CharField(max_length=20, choices=Constants.STATUS_CHOICES, default='INCOMPLETE')
118121
student = models.ForeignKey(Student,
119122
on_delete=models.CASCADE, related_name='mcm_info')
120123
annual_income = models.IntegerField(default=0)
@@ -196,7 +199,7 @@ class Director_silver(models.Model):
196199
student = models.ForeignKey(Student, on_delete=models.CASCADE)
197200
award_id = models.ForeignKey(Award_and_scholarship, on_delete=models.CASCADE)
198201
award_type = models.CharField(max_length=50, null=True)
199-
status = models.CharField(max_length=10, choices=Constants.STATUS_CHOICES,default='INCOMPLETE')
202+
status = models.CharField(max_length=20, choices=Constants.STATUS_CHOICES,default='INCOMPLETE')
200203
Marksheet = models.FileField(null=False, blank=False)
201204
date = models.DateField(default=datetime.date.today)
202205
financial_assistance = models.TextField(max_length=1000 ,null=True)
@@ -216,7 +219,7 @@ class Proficiency_dm(models.Model):
216219
student = models.ForeignKey(Student, on_delete=models.CASCADE)
217220
award_id = models.ForeignKey(Award_and_scholarship, on_delete=models.CASCADE)
218221
award_type = models.CharField(max_length=50, null=True)
219-
status = models.CharField(max_length=10, choices=Constants.STATUS_CHOICES,default='INCOMPLETE')
222+
status = models.CharField(max_length=20, choices=Constants.STATUS_CHOICES,default='INCOMPLETE')
220223
nearest_policestation = models.TextField(max_length=30, default='station')
221224
nearest_railwaystation = models.TextField(max_length=30, default='station')
222225
correspondence_address = models.TextField(max_length=150, null=True)
@@ -252,7 +255,7 @@ class Meta:
252255

253256
class Director_gold(models.Model):
254257
student = models.ForeignKey(Student, on_delete=models.CASCADE)
255-
status = models.CharField(max_length=10,choices=Constants.STATUS_CHOICES, default='INCOMPLETE')
258+
status = models.CharField(max_length=20,choices=Constants.STATUS_CHOICES, default='INCOMPLETE')
256259
correspondence_address = models.TextField(max_length=40, default='address')
257260
nearest_policestation = models.TextField(max_length=30, default='station')
258261
nearest_railwaystation = models.TextField(max_length=30, default='station')

FusionIIIT/applications/scholarships/urls.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from . import views
66
from applications.scholarships.api.views import GetWinnersView
77
from applications.scholarships.api.views import create_award,McmUpdateView, McmRetrieveView, DirectorSilverRetrieveView,DirectorSilverUpdateView,DirectorGoldRetrieveView,DirectorGoldUpdateView,ProficiencyDmRetrieveView,ProficiencyDmUpdateView,AwardAndScholarshipCreateView
8-
from applications.scholarships.api.views import ScholarshipDetailView,StudentDetailView,DirectorSilverDetailView,DirectorGoldDetailView,DirectorGoldListView,ReleaseCreateView
8+
from applications.scholarships.api.views import ScholarshipDetailView,StudentDetailView,DirectorSilverDetailView,DirectorGoldDetailView,DirectorGoldListView,ReleaseCreateView,McmStatusUpdateView,DirectorSilverDecisionView,DirectorGoldAcceptRejectView,DirectorSilverListView,DirectorSilverAcceptRejectView
9+
910

1011

1112
app_name = 'spacs'
@@ -43,4 +44,11 @@
4344
path('director_silver_show/', DirectorSilverDetailView.as_view(), name='director_silver_detail'),
4445
path('director_gold_view/', DirectorGoldDetailView.as_view(), name='director_gold_detail'),
4546
path('release', ReleaseCreateView.as_view(), name='release_create'),
47+
48+
url(r'student_file_show/', StudentDetailView.as_view(), name='student-file-show'),
49+
path('mcm/status-update/', McmStatusUpdateView.as_view(), name='mcm-status-update'),
50+
path('api/director_silver/decision/', DirectorSilverDecisionView.as_view(), name='director_silver_decision'),
51+
path('director-gold/accept-reject/', DirectorGoldAcceptRejectView.as_view(), name='director-gold-accept-reject'),
52+
path('director-silver/', DirectorSilverListView.as_view(), name='director-silver-list'),
53+
path('director-silver/accept-reject/', DirectorSilverAcceptRejectView.as_view(), name='director-silver-accept-reject'),
4654
]

0 commit comments

Comments
 (0)