diff --git a/FusionIIIT/Fusion/settings/development.py b/FusionIIIT/Fusion/settings/development.py
index 63587a11f..ad928f103 100644
--- a/FusionIIIT/Fusion/settings/development.py
+++ b/FusionIIIT/Fusion/settings/development.py
@@ -12,7 +12,7 @@
'NAME': 'fusionlab',
'HOST': os.environ.get("DB_HOST", default='localhost'),
'USER': 'fusion_admin',
- 'PASSWORD': 'hello123',
+ 'PASSWORD': 'hello123'
}
}
diff --git a/FusionIIIT/applications/gymkhana/admin.py b/FusionIIIT/applications/gymkhana/admin.py
index 10dd3b792..0139a3865 100644
--- a/FusionIIIT/applications/gymkhana/admin.py
+++ b/FusionIIIT/applications/gymkhana/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
-from .models import (Club_budget,Club_info,Club_member,Club_report,Core_team,Fest_budget,Other_report,Session_info,Voting_choices,Voting_polls,Voting_voters,Event_info,Registration_form,Form_available,Inventory)
+from .models import (Club_budget,Club_info,Club_member,Club_report,Fest_budget,Fest,Other_report,Session_info,Event_info,Registration_form,Form_available,Inventory,Budget,Budget_Comments,Event_Comments)
# Register your models here.
@@ -15,16 +15,20 @@ class ClubMemberAdmin(admin.ModelAdmin):
admin.site.register(Club_info, ClubInfoAdmin)
admin.site.register(Club_member, ClubMemberAdmin)
-admin.site.register(Core_team)
+# admin.site.register(Core_team)
admin.site.register(Club_budget)
admin.site.register(Session_info)
admin.site.register(Event_info)
admin.site.register(Club_report)
admin.site.register(Fest_budget)
admin.site.register(Other_report)
-admin.site.register(Voting_polls)
-admin.site.register(Voting_choices)
-admin.site.register(Voting_voters)
+# admin.site.register(Voting_polls)
+# admin.site.register(Voting_choices)
+# admin.site.register(Voting_voters)
admin.site.register(Registration_form)
admin.site.register(Form_available)
admin.site.register(Inventory)
+admin.site.register(Budget)
+admin.site.register(Budget_Comments)
+admin.site.register(Event_Comments)
+admin.site.register(Fest)
\ No newline at end of file
diff --git a/FusionIIIT/applications/gymkhana/api/serializers.py b/FusionIIIT/applications/gymkhana/api/serializers.py
index 77a92726c..08aa6b0fa 100644
--- a/FusionIIIT/applications/gymkhana/api/serializers.py
+++ b/FusionIIIT/applications/gymkhana/api/serializers.py
@@ -2,13 +2,13 @@
from django.contrib.auth import get_user_model
from rest_framework.authtoken.models import Token
from rest_framework import serializers
-from applications.gymkhana.models import Club_info,Session_info,Event_info, Voting_choices
-from applications.gymkhana.models import Club_member,Core_team,Club_budget,Club_report,Fest_budget,Registration_form,Voting_polls
+from applications.gymkhana.models import Club_info,Session_info,Event_info
+from applications.gymkhana.models import Club_member,Club_budget,Club_report,Fest_budget,Fest,Registration_form,Budget,Budget_Comments,Event_Comments,Achievements,ClubPosition, EventInput, EventReport
-class Voting_choicesSerializer(serializers.ModelSerializer):
- class Meta:
- model = Voting_choices
- fields = ['poll_event', 'title', 'description', 'votes']
+# class Voting_choicesSerializer(serializers.ModelSerializer):
+# class Meta:
+# model = Voting_choices
+# fields = ['poll_event', 'title', 'description', 'votes']
class Club_infoSerializer(serializers.ModelSerializer):
@@ -28,16 +28,16 @@ class Meta:
fields = ['member','club','description', 'status','remarks','id']
-class Core_teamSerializer(serializers.ModelSerializer):
+# class Core_teamSerializer(serializers.ModelSerializer):
- class Meta:
- model=Core_team
- fields=('all')
+# class Meta:
+# model=Core_team
+# fields=('all')
class Club_DetailsSerializer(serializers.ModelSerializer):
class Meta:
model=Club_info
- fields=['club_name',"co_ordinator","co_coordinator","activity_calender","category",'faculty_incharge',"club_file", "status"]
+ fields=['club_name',"co_ordinator","co_coordinator","activity_calender","category",'faculty_incharge',"club_file", "status" ,"description"]
class Session_infoSerializer(serializers.ModelSerializer):
class Meta:
@@ -50,13 +50,13 @@ class event_infoserializer(serializers.ModelSerializer):
class Meta:
model=Event_info
- fields=['club','event_name','incharge','date','venue','start_time','id','details','status']
+ fields=['club','event_name','incharge','start_date','end_date','venue','start_time','id','details','status','end_time','details']
class club_budgetserializer(serializers.ModelSerializer):
class Meta:
model=Club_budget
- fields=['club','budget_for','budget_amt','budget_file','status','id','description']
+ fields=['club','budget_for','budget_amt','budget_file','status','id','description','remarks']
class Club_reportSerializers(serializers.ModelSerializer):
class Meta:
@@ -73,8 +73,48 @@ class Meta:
model=Registration_form
fields=['roll','user_name','branch','cpi','programme']
-class Voting_pollSerializer(serializers.ModelSerializer):
+# class Voting_pollSerializer(serializers.ModelSerializer):
+
+# class Meta:
+# model=Voting_polls
+# fields=['title','pub_date','exp_date','created_by','groups','id','description']
+class BudgetSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = Budget
+ fields = ['id', 'club', 'budget_for', 'budget_requested', 'budget_allocated', 'budget_file', 'description', 'status', 'remarks', 'budget_comment']
+class AchievementsSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = Achievements
+ fields = ['id', 'club_name', 'title', 'achievement']
+class Budget_CommentsSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = Budget_Comments
+ fields = ['budget_id', 'commentator_designation', 'comment', 'comment_date', 'comment_time']
+class Event_CommentsSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = Event_Comments
+ fields = ['event_id', 'commentator_designation', 'comment', 'comment_date', 'comment_time']
+class ClubPositionSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = ClubPosition
+ fields = ['id', 'name', 'position', 'club']
+
+class FestSerializer(serializers.ModelSerializer):
+ class Meta:
+ model=Fest
+ fields= ['id', 'name', 'category', 'description', 'date', 'link']
+
+class EventInputSerializer(serializers.ModelSerializer):
+ # Use event name for dropdown-like functionality
+ event = serializers.SlugRelatedField(
+ queryset=Event_info.objects.all(),
+ slug_field='id')
+
+ class Meta:
+ model = EventInput
+ fields = ['id', 'event', 'description','images']
+class EventReportSerializer(serializers.ModelSerializer):
class Meta:
- model=Voting_polls
- fields=['title','pub_date','exp_date','created_by','groups','id','description']
\ No newline at end of file
+ model = EventReport
+ fields = '__all__'
diff --git a/FusionIIIT/applications/gymkhana/api/views.py b/FusionIIIT/applications/gymkhana/api/views.py
index 0ec4b524e..0b0c9c80e 100644
--- a/FusionIIIT/applications/gymkhana/api/views.py
+++ b/FusionIIIT/applications/gymkhana/api/views.py
@@ -1,19 +1,64 @@
import genericpath
import json
import tempfile
-from datetime import datetime
+from datetime import datetime, timedelta
from venv import logger
from rest_framework.permissions import IsAuthenticated
from rest_framework.authentication import TokenAuthentication
from rest_framework import status
from rest_framework.views import APIView
-from rest_framework.decorators import api_view, permission_classes,authentication_classes
+from rest_framework.decorators import (
+ api_view,
+ permission_classes,
+ authentication_classes,
+)
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from django.shortcuts import render
-from applications.gymkhana.models import Voting_choices, Registration_form, Student ,Club_info,Club_member,Core_team,Session_info,Event_info,Club_budget,Club_report,Fest_budget,Registration_form,Voting_polls
-from .serializers import Club_memberSerializer,Core_teamSerializer,Club_DetailsSerializer,Session_infoSerializer, Voting_choicesSerializer,event_infoserializer,club_budgetserializer,Club_reportSerializers,Fest_budgerSerializer,Registration_formSerializer,Voting_pollSerializer, Club_infoSerializer
-
+from applications.gymkhana.models import (
+ Registration_form,
+ Student,
+ Club_info,
+ Club_member,
+ Session_info,
+ Event_info,
+ Club_budget,
+ Club_report,
+ Fest_budget,
+ Registration_form,
+ Budget,
+ Achievements,
+ ClubPosition,
+ Fest,
+)
+from .serializers import (
+ Club_memberSerializer,
+ Club_DetailsSerializer,
+ Session_infoSerializer,
+ event_infoserializer,
+ club_budgetserializer,
+ Club_reportSerializers,
+ Fest_budgerSerializer,
+ Registration_formSerializer,
+ Club_infoSerializer,
+ BudgetSerializer,
+ AchievementsSerializer,
+ Event_CommentsSerializer,
+ Budget_CommentsSerializer,
+ ClubPositionSerializer,
+ FestSerializer,
+ EventInputSerializer,
+ EventReportSerializer
+)
+
+from io import BytesIO
+from django.http import FileResponse
+from reportlab.lib.pagesizes import letter
+from reportlab.lib import colors
+from reportlab.platypus import (
+ SimpleDocTemplate, Paragraph, Spacer, Image, HRFlowable, PageBreak
+)
+from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from django.contrib.auth.models import User
from applications.gymkhana.views import *
from rest_framework import generics
@@ -22,102 +67,161 @@
from rest_framework.parsers import MultiPartParser
+
+class Budgetinfo(APIView):
+ def get(self, request):
+ budgets = Budget.objects.all()
+ serializer = BudgetSerializer(budgets, many=True)
+ return Response(serializer.data)
+
+
+class Club_Detail(APIView):
+ def post(self, request):
+ club_name = request.data.get("club_name")
+ if not club_name:
+ return Response(
+ {"error": "club_name is required"}, status=status.HTTP_400_BAD_REQUEST
+ )
+ clubdetail = get_object_or_404(Club_info, club_name=club_name)
+ serializer = Club_DetailsSerializer(clubdetail)
+ return Response(serializer.data, status=status.HTTP_200_OK)
+
+
+class UpcomingEventsAPIView(APIView):
+ def get(self, request):
+ events = Event_info.objects.filter(
+ start_date__gte=datetime.datetime.now()
+ ).order_by("start_date")
+ serializer = event_infoserializer(events, many=True)
+ return Response(serializer.data, status=status.HTTP_200_OK)
+
+
+class PastEventsAPIView(APIView):
+ def get(self, request):
+ events = Event_info.objects.filter(
+ end_date__lt=datetime.datetime.now()
+ ).order_by("end_date")
+ serializer = event_infoserializer(events, many=True)
+ return Response(serializer.data, status=status.HTTP_200_OK)
+
+
class UploadActivityCalendarAPIView(APIView):
parser_classes = [MultiPartParser]
def post(self, request, format=None):
# Get the club name from the request data
- club_name = request.data.get('club_name')
+ club_name = request.data.get("club_name")
# Retrieve the club object from the database
try:
club = Club_info.objects.get(club_name=club_name)
except Club_info.DoesNotExist:
- return Response({'error': f'Club with name {club_name} does not exist'}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": f"Club with name {club_name} does not exist"},
+ status=status.HTTP_404_NOT_FOUND,
+ )
# Update the activity calendar file
- club.activity_calender = request.data.get('activity_calender')
+ club.activity_calender = request.data.get("activity_calender")
# Save the updated club object
club.save()
- return Response({'message': 'Activity calendar updated successfully'}, status=status.HTTP_200_OK)
+ return Response(
+ {"message": "Activity calendar updated successfully"},
+ status=status.HTTP_200_OK,
+ )
-class VoteIncrementAPIView(APIView):
- def post(self, request):
- serializer = Voting_choicesSerializer(data=request.data, many=True)
- if not serializer.is_valid():
- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
-
- data = serializer.validated_data
- for choice_data in data:
- poll_event_id = choice_data.get('poll_event')
- title = choice_data.get('title')
- try:
- choice_instance = Voting_choices.objects.get(poll_event_id=poll_event_id, title=title)
- choice_instance.votes += 1
- choice_instance.save()
- except Voting_choices.DoesNotExist:
- pass # Do nothing if the choice with the given poll_event and title doesn't exist
-
- return Response({'message': 'Votes incremented successfully'}, status=status.HTTP_200_OK)
+# class VoteIncrementAPIView(APIView):
+# def post(self, request):
+# serializer = Voting_choicesSerializer(data=request.data, many=True)
+# if not serializer.is_valid():
+# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+# data = serializer.validated_data
+# for choice_data in data:
+# poll_event_id = choice_data.get('poll_event')
+# title = choice_data.get('title')
+# try:
+# choice_instance = Voting_choices.objects.get(poll_event_id=poll_event_id, title=title)
+# choice_instance.votes += 1
+# choice_instance.save()
+# except Voting_choices.DoesNotExist:
+# pass # Do nothing if the choice with the given poll_event and title doesn't exist
-class VotingPollsDeleteAPIView(APIView):
- def post(self, request):
- Voting_poll_id = request.data.get('id') # Assuming the ID is sent in the request body
- try:
- Voting_poll = Voting_polls.objects.get(id=Voting_poll_id)
- except Voting_polls.DoesNotExist:
- return Response({"error": "Voting Poll not found."}, status=status.HTTP_404_NOT_FOUND)
-
- # Delete the club member object
- Voting_poll.delete()
+# return Response({'message': 'Votes incremented successfully'}, status=status.HTTP_200_OK)
- return Response({"message": "POll deleted successfully."}, status=status.HTTP_204_NO_CONTENT)
+# class VotingPollsDeleteAPIView(APIView):
+# def post(self, request):
+# Voting_poll_id = request.data.get('id') # Assuming the ID is sent in the request body
+# try:
+# Voting_poll = Voting_polls.objects.get(id=Voting_poll_id)
+# except Voting_polls.DoesNotExist:
+# return Response({"error": "Voting Poll not found."}, status=status.HTTP_404_NOT_FOUND)
+
+# # Delete the club member object
+# Voting_poll.delete()
+
+# return Response({"message": "POll deleted successfully."}, status=status.HTTP_204_NO_CONTENT)
+
+
+# class ShowVotingChoicesAPIView(APIView):
+# def get(self, request):
+# voting_choices = Voting_choices.objects.all()
+# serializer = Voting_choicesSerializer(voting_choices, many=True)
+# return Response(serializer.data, status=status.HTTP_200_OK)
-class ShowVotingChoicesAPIView(APIView):
- def get(self, request):
- voting_choices = Voting_choices.objects.all()
- serializer = Voting_choicesSerializer(voting_choices, many=True)
- return Response(serializer.data, status=status.HTTP_200_OK)
class ClubMemberApproveView(generics.UpdateAPIView):
def post(self, request):
- club_member_id = request.data.get('id') # Assuming the ID is sent in the request body
+ club_member_id = request.data.get(
+ "id"
+ ) # Assuming the ID is sent in the request body
try:
club_member = Club_member.objects.get(id=club_member_id)
except Club_member.DoesNotExist:
- return Response({"error": "Club member not found."}, status=status.HTTP_404_NOT_FOUND)
-
+ return Response(
+ {"error": "Club member not found."}, status=status.HTTP_404_NOT_FOUND
+ )
+
# Update the status of the club member
- club_member.status = 'confirmed' # Assuming 'confirmed' is the status for approval
+ club_member.status = "member" # Assuming 'member' is the status for approval
club_member.save()
- return Response({"message": "Status updated successfully."}, status=status.HTTP_200_OK)
+ return Response(
+ {"message": "Status updated successfully."}, status=status.HTTP_200_OK
+ )
class ClubMemberDeleteAPIView(APIView):
def post(self, request):
- club_member_id = request.data.get('id') # Assuming the ID is sent in the request body
+ club_member_id = request.data.get(
+ "id"
+ ) # Assuming the ID is sent in the request body
try:
club_member = Club_member.objects.get(id=club_member_id)
except Club_member.DoesNotExist:
- return Response({"error": "Club member not found."}, status=status.HTTP_404_NOT_FOUND)
-
+ return Response(
+ {"error": "Club member not found."}, status=status.HTTP_404_NOT_FOUND
+ )
+
# Delete the club member object
club_member.delete()
- return Response({"message": "Club member deleted successfully."}, status=status.HTTP_204_NO_CONTENT)
+ return Response(
+ {"message": "Club member deleted successfully."},
+ status=status.HTTP_204_NO_CONTENT,
+ )
+
# class UpdateClubDetailsAPIView(APIView):
# def post(self, request, *args, **kwargs):
# club_name = request.data.get('club_name')
# co_coordinator = request.data.get('co_coordinator')
# co_ordinator = request.data.get('co_ordinator')
-
+
# print(f"Received request data: club_name={club_name}, co_coordinator={co_coordinator}, co_ordinator={co_ordinator}")
# # Retrieve the Club_info object by club_name
@@ -125,9 +229,9 @@ def post(self, request):
# club_info = Club_info.objects.get(club_name=club_name)
# except Club_info.DoesNotExist:
# return Response({"message": "Club not found"}, status=status.HTTP_404_NOT_FOUND)
-
+
# print(f"Found Club_info object: {club_info}")
-
+
# # Update the details provided in the request
# serializer = Club_infoSerializer(instance=club_info, data={'co_coordinator': co_coordinator, 'co_ordinator': co_ordinator}, partial=True)
# if serializer.is_valid():
@@ -139,98 +243,127 @@ def post(self, request):
# print(f"Serializer errors: {serializer.errors}")
# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
class ChangeHeadAPIView(APIView):
def post(self, request):
club = request.data.get("club_name")
- co_ordinator = request.data.get('co_ordinator')
- co_coordinator = request.data.get('co_coordinator')
+ co_ordinator = request.data.get("co_ordinator")
+ co_coordinator = request.data.get("co_coordinator")
if not club or (not co_ordinator and not co_coordinator):
- return JsonResponse({'status': 'error', 'message': 'Invalid request parameters'})
+ return JsonResponse(
+ {"status": "error", "message": "Invalid request parameters"}
+ )
try:
club_info = Club_info.objects.get(club_name=club)
except Club_info.DoesNotExist:
- return JsonResponse({'status': 'error', 'message': 'Club not found'})
+ return JsonResponse({"status": "error", "message": "Club not found"})
message = ""
if co_ordinator:
- if not Club_member.objects.filter(club_id=club, member_id=co_ordinator).exists():
- return JsonResponse({'status': 'error', 'message': 'Selected student is not a member of the club'})
-
+ if not Club_member.objects.filter(
+ club_id=club, member_id=co_ordinator
+ ).exists():
+ return JsonResponse(
+ {
+ "status": "error",
+ "message": "Selected student is not a member of the club",
+ }
+ )
+
try:
co_ordinator_student = Student.objects.get(id_id=co_ordinator)
old_co_ordinator = club_info.co_ordinator_id
club_info.co_ordinator_id = co_ordinator_student
-
+
new_co_ordinator = HoldsDesignation(
user=User.objects.get(username=co_ordinator),
working=User.objects.get(username=co_ordinator),
- designation=Designation.objects.get(name="co-ordinator")
+ designation=Designation.objects.get(name="co-ordinator"),
)
new_co_ordinator.save()
HoldsDesignation.objects.filter(
user__username=old_co_ordinator,
- designation=Designation.objects.get(name="co-ordinator")
+ designation=Designation.objects.get(name="co-ordinator"),
).delete()
message += "Successfully changed co-ordinator !!!"
except Student.DoesNotExist:
- return JsonResponse({'status': 'error', 'message': 'Selected student not found'})
+ return JsonResponse(
+ {"status": "error", "message": "Selected student not found"}
+ )
if co_coordinator:
- if not Club_member.objects.filter(club_id=club, member_id=co_coordinator).exists():
- return JsonResponse({'status': 'error', 'message': 'Selected student is not a member of the club'})
+ if not Club_member.objects.filter(
+ club_id=club, member_id=co_coordinator
+ ).exists():
+ return JsonResponse(
+ {
+ "status": "error",
+ "message": "Selected student is not a member of the club",
+ }
+ )
try:
co_coordinator_student = Student.objects.get(id_id=co_coordinator)
old_co_coordinator = club_info.co_coordinator_id
club_info.co_coordinator_id = co_coordinator_student
-
+
new_co_coordinator = HoldsDesignation(
user=User.objects.get(username=co_coordinator),
working=User.objects.get(username=co_coordinator),
- designation=Designation.objects.get(name="co co-ordinator")
+ designation=Designation.objects.get(name="co co-ordinator"),
)
new_co_coordinator.save()
HoldsDesignation.objects.filter(
user__username=old_co_coordinator,
- designation=Designation.objects.get(name="co co-ordinator")
+ designation=Designation.objects.get(name="co co-ordinator"),
).delete()
message += "Successfully changed co-coordinator !!!"
except Student.DoesNotExist:
- return JsonResponse({'status': 'error', 'message': 'Selected student not found'})
+ return JsonResponse(
+ {"status": "error", "message": "Selected student not found"}
+ )
club_info.head_changed_on = timezone.now()
club_info.save()
- return JsonResponse({'status': "success", 'message': message})
+ return JsonResponse({"status": "success", "message": message})
+
+
class AddMemberToClub(APIView):
def post(self, request):
- serializer = Club_memberSerializer(data=request.data)
+ member = request.data.get("member")
+ club = request.data.get("club")
+ if Club_member.objects.filter(member=member, club=club).exists():
+ return Response({"error": "Member has already applied to this club."}, status=status.HTTP_400_BAD_REQUEST)
+ data = {
+ "member": member,
+ "club": club,
+ "description": request.data.get("description"),
+ "status": "open",
+ }
+ serializer = Club_memberSerializer(data=data)
if serializer.is_valid():
- club_id = request.data.get('club') # Assuming 'club_id' is passed in the request data
- try:
- club_member = serializer.save()
- # Implement logic to add member to the club here
- # For example, you can retrieve the club instance and add the member to it
- # club = Club.objects.get(pk=club_id)
- # club.members.add(club_member)
- return Response(serializer.data, status=status.HTTP_201_CREATED)
- except Exception as e:
- return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST)
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
class ClubMemberAPIView(APIView):
- def get(self, request):
- club_members = Club_member.objects.all()
+ def post(self, request):
+ club_member_id = request.data.get("club_name")
+ club_members = Club_member.objects.filter(club_id=club_member_id)
serializer = Club_memberSerializer(club_members, many=True)
- return Response(serializer.data)
-
+ return Response(serializer.data, status=status.HTTP_200_OK)
+
+
class RegistrationFormAPIView(APIView):
"""
API endpoint to handle registration form submissions.
@@ -249,107 +382,132 @@ def post(self, request):
branch = request.data.get("branch")
programme = request.data.get("programme")
print(programme)
-
+
# Check if the user has already submitted the form
if Registration_form.objects.filter(user_name=user_name).exists():
raise Exception("User has already filled the form.")
# Saving data to the database
- registration = Registration_form(user_name=user_name, branch=branch, roll=roll, cpi=cpi, programme=programme)
+ registration = Registration_form(
+ user_name=user_name,
+ branch=branch,
+ roll=roll,
+ cpi=cpi,
+ programme=programme,
+ )
try:
registration.save()
- # If no exception occurred, the save operation was successful
+ # If no exception occurred, the save operation was successful
print("Save operation successful")
serializer = Registration_formSerializer(registration)
return Response(serializer.data, status=status.HTTP_201_CREATED)
except Exception as e:
- # If an exception occurred, print the error message or log it
- print(f"Error occurred while saving registration: {e}")
+ # If an exception occurred, print the error message or log it
+ print(f"Error occurred while saving registration: {e}")
print(registration.user_name)
# Serialize the response
-
+
except Exception as e:
error_message = "Some error occurred"
logger.error(f"Error in registration form submission: {e}")
- return Response({"status": "error", "message": error_message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
+ return Response(
+ {"status": "error", "message": error_message},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR,
+ )
+
+
def coordinator_club(request):
club_info = []
for club in Club_info.objects.all():
if str(request.user) in [club.co_ordinator, club.co_coordinator]:
serialized_club = Club_infoSerializer(club).data
club_info.append(serialized_club)
- return club_info
+ return club_info
+
+
+# class core(APIView):
+# def get(self,request):
+# co=Core_team.objects.all()
+# serializer=Core_teamSerializer(co, many=True)
+# print(serializer.data)
+# return Response(serializer.data)
-class core(APIView):
- def get(self,request):
- co=Core_team.objects.all()
- serializer=Core_teamSerializer(co, many=True)
- print(serializer.data)
- return Response(serializer.data)
class clubname(APIView):
permission_classes = [IsAuthenticated]
- def get(self,request):
+
+ def get(self, request):
authentication_classes = [TokenAuthentication]
clubname1 = Club_info.objects.all()
- serializer = Club_infoSerializer(clubname1, many = True)
+ serializer = Club_infoSerializer(clubname1, many=True)
return Response(serializer.data)
-class Club_Details(APIView):
- def get(self,respect):
- clubdetail=Club_info.objects.all()
- serializer=Club_DetailsSerializer(clubdetail, many=True)
+class Club_Details(APIView):
+
+ def get(self, respect):
+ clubdetail = Club_info.objects.all()
+ serializer = Club_DetailsSerializer(clubdetail, many=True)
return Response(serializer.data)
+
class session_details(APIView):
- def get(self,respect):
+ def get(self, respect):
session = Session_info.objects.all()
- serializer = Session_infoSerializer(session, many = True)
+ serializer = Session_infoSerializer(session, many=True)
return Response(serializer.data)
+
class club_events(APIView):
- def get(self,respect):
- clubevents=Event_info.objects.all()
- serializer=event_infoserializer(clubevents, many = True)
+ def get(self, respect):
+ clubevents = Event_info.objects.all()
+ serializer = event_infoserializer(clubevents, many=True)
return Response(serializer.data)
+
class club_budgetinfo(APIView):
- def get(self,respect):
- clubbudget=Club_budget.objects.all()
- serializer=club_budgetserializer(clubbudget, many=True)
+ def get(self, respect):
+ clubbudget = Club_budget.objects.all()
+ serializer = club_budgetserializer(clubbudget, many=True)
return Response(serializer.data)
+
class club_report(APIView):
- def get(self,respect):
+ def get(self, respect):
clubreport = Club_report.objects.all()
- serializer = Club_reportSerializers(clubreport , many=True)
+ serializer = Club_reportSerializers(clubreport, many=True)
return Response(serializer.data)
+
class Fest_Budget(APIView):
- def get(self,respect):
- festbudget=Fest_budget.objects.all()
- serializer=Fest_budgerSerializer(festbudget, many=True)
+ def get(self, respect):
+ festbudget = Fest_budget.objects.all()
+ serializer = Fest_budgerSerializer(festbudget, many=True)
return Response(serializer.data)
+
class Registraion_form(APIView):
+ def get(self, respect):
+ registration = Registration_form.objects.all()
+ serializer = Registration_formSerializer(registration, many=True)
+ return Response(serializer.data)
+class FestListView(APIView):
def get(self,respect):
- registration=Registration_form.objects.all()
- serializer=Registration_formSerializer(registration, many=True)
+ fests=Fest.objects.all();
+ serializer=FestSerializer(fests, many=True)
return Response(serializer.data)
+# class Voting_Polls(APIView):
-class Voting_Polls(APIView):
+# def get(self,respect):
+# votingpolls=Voting_polls.objects.all()
+# serializer=Voting_pollSerializer(votingpolls, many=True)
+# return Response(serializer.data)
- def get(self,respect):
- votingpolls=Voting_polls.objects.all()
- serializer=Voting_pollSerializer(votingpolls, many=True)
- return Response(serializer.data)
##logger = logging.getLogger(_NamedFuncPointer)
class NewSessionAPIView(APIView):
@@ -357,9 +515,9 @@ def get(self, request):
sessions = Session_info.objects.all()
serializer = Session_infoSerializer(sessions, many=True)
return Response(serializer.data)
-
+
def post(self, request):
- serializer =Session_infoSerializer(data=request.data)
+ serializer = Session_infoSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
@@ -371,16 +529,27 @@ def get(self, request):
events = Event_info.objects.all()
serializer = event_infoserializer(events, many=True)
return Response(serializer.data)
-
+
def post(self, request):
serializer = event_infoserializer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
-
-
+class NewFestAPIView(APIView):
+ def get(self, request):
+ fests = Fest.objects.all()
+ serializer = FestSerializer(fests, many=True)
+ return Response(serializer.data)
+
+ def post(self, request):
+ serializer = FestSerializer(data=request.data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ print(serializer.errors)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
# class DeleteEventsView(APIView):
# """
@@ -394,7 +563,7 @@ def post(self, request):
# try:
# events_deleted = []
# events_not_found = []
-
+
# # Ensure that request.data is a dictionary
# event_data_list = request.data if isinstance(request.data, list) else []
@@ -429,59 +598,80 @@ def post(self, request):
# except Exception as e:
# return Response(str(e), status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
class EventDeleteAPIView(APIView):
def post(self, request, *args, **kwargs):
# Retrieve data from request
event_data = request.data
# Check if 'id' parameter is provided
- if 'id' not in event_data:
- return Response({'error': 'The "id" parameter is required'}, status=status.HTTP_400_BAD_REQUEST)
+ if "id" not in event_data:
+ return Response(
+ {"error": 'The "id" parameter is required'},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
# Get the event by id
- event_id = event_data['id']
+ event_id = event_data["id"]
try:
event = Event_info.objects.get(id=event_id)
except Event_info.DoesNotExist:
- return Response({'error': 'Event not found with the provided id'}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Event not found with the provided id"},
+ status=status.HTTP_404_NOT_FOUND,
+ )
# Delete the event
event.delete()
- return Response({'message': 'Event deleted successfully'}, status=status.HTTP_200_OK)
+ return Response(
+ {"message": "Event deleted successfully"}, status=status.HTTP_200_OK
+ )
class SessionUpdateAPIView(APIView):
def post(self, request):
- session_id = request.data.get('id')
+ session_id = request.data.get("id")
if session_id is None:
- return Response({'error': 'Session ID not provided'}, status=status.HTTP_400_BAD_REQUEST)
+ return Response(
+ {"error": "Session ID not provided"}, status=status.HTTP_400_BAD_REQUEST
+ )
try:
session_instance = Session_info.objects.get(id=session_id)
except Session_info.DoesNotExist:
- return Response({'error': 'Session not found'}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Session not found"}, status=status.HTTP_404_NOT_FOUND
+ )
- serializer = Session_infoSerializer(instance=session_instance, data=request.data, partial=True)
+ serializer = Session_infoSerializer(
+ instance=session_instance, data=request.data, partial=True
+ )
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
-
+
class EventUpdateAPIView(APIView):
def post(self, request):
- event_id = request.data.get('id')
+ event_id = request.data.get("id")
if event_id is None:
- return Response({'error': 'Event ID not provided'}, status=status.HTTP_400_BAD_REQUEST)
+ return Response(
+ {"error": "Event ID not provided"}, status=status.HTTP_400_BAD_REQUEST
+ )
try:
event_instance = Event_info.objects.get(id=event_id)
except Event_info.DoesNotExist:
- return Response({'error': 'Event not found'}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Event not found"}, status=status.HTTP_404_NOT_FOUND
+ )
- serializer = event_infoserializer(instance=event_instance, data=request.data, partial=True)
+ serializer = event_infoserializer(
+ instance=event_instance, data=request.data, partial=True
+ )
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)
@@ -507,10 +697,10 @@ def post(self, request):
# Iterate over each session data
for session_data in session_data_list:
- venue = session_data.get('venue')
- date = session_data.get('date')
- start_time = session_data.get('start_time')
- end_time = session_data.get('end_time')
+ venue = session_data.get("venue")
+ date = session_data.get("date")
+ start_time = session_data.get("start_time")
+ end_time = session_data.get("end_time")
# Query Session_info based on the provided parameters
session = Session_info.objects.filter(
@@ -528,7 +718,7 @@ def post(self, request):
response_data = {
"sessions_deleted": sessions_deleted,
- "sessions_not_found": sessions_not_found
+ "sessions_not_found": sessions_not_found,
}
return JsonResponse(response_data, status=200)
@@ -536,62 +726,71 @@ def post(self, request):
return JsonResponse({"error": str(e)}, status=500)
-class CreateVotingPollAPIView(APIView):
- def post(self, request):
- voting_poll_serializer = Voting_pollSerializer(data=request.data)
- if voting_poll_serializer.is_valid():
- voting_poll_instance = voting_poll_serializer.save()
-
- # Extract ID of the created Voting_poll instance
- voting_poll_id = voting_poll_instance.id
+# class CreateVotingPollAPIView(APIView):
+# def post(self, request):
+# voting_poll_serializer = Voting_pollSerializer(data=request.data)
+# if voting_poll_serializer.is_valid():
+# voting_poll_instance = voting_poll_serializer.save()
+
+# # Extract ID of the created Voting_poll instance
+# voting_poll_id = voting_poll_instance.id
+
+# # Modify the request data to include poll_event ID for each choice
+# choices_data = request.data.get('choices', [])
+# for choice_data in choices_data:
+# choice_data['poll_event'] = voting_poll_id
+
+# voting_choices_serializer = Voting_choicesSerializer(data=choices_data, many=True)
+# if voting_choices_serializer.is_valid():
+# voting_choices_serializer.save()
+# return Response({'message': 'Voting poll created successfully'}, status=status.HTTP_201_CREATED)
+# else:
+# return Response({'voting_choices_errors': voting_choices_serializer.errors}, status=status.HTTP_400_BAD_REQUEST)
+# else:
+# return Response({'voting_poll_errors': voting_poll_serializer.errors}, status=status.HTTP_400_BAD_REQUEST)
- # Modify the request data to include poll_event ID for each choice
- choices_data = request.data.get('choices', [])
- for choice_data in choices_data:
- choice_data['poll_event'] = voting_poll_id
- voting_choices_serializer = Voting_choicesSerializer(data=choices_data, many=True)
- if voting_choices_serializer.is_valid():
- voting_choices_serializer.save()
- return Response({'message': 'Voting poll created successfully'}, status=status.HTTP_201_CREATED)
- else:
- return Response({'voting_choices_errors': voting_choices_serializer.errors}, status=status.HTTP_400_BAD_REQUEST)
- else:
- return Response({'voting_poll_errors': voting_poll_serializer.errors}, status=status.HTTP_400_BAD_REQUEST)
-
class UpdateClubBudgetAPIView(APIView):
def post(self, request):
- budget_id = request.data.get('id')
+ budget_id = request.data.get("id")
if budget_id is None:
- return Response({'error': 'Club budget ID not provided'}, status=status.HTTP_400_BAD_REQUEST)
+ return Response(
+ {"error": "Club budget ID not provided"},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
try:
budget_instance = Club_budget.objects.get(pk=budget_id)
except Club_budget.DoesNotExist:
- return Response({'error': 'Club budget not found'}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Club budget not found"}, status=status.HTTP_404_NOT_FOUND
+ )
- serializer = club_budgetserializer(instance=budget_instance, data=request.data, partial = True)
+ serializer = club_budgetserializer(
+ instance=budget_instance, data=request.data, partial=True
+ )
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)
- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
class AddClub_BudgetAPIView(APIView):
def post(self, request):
# Get the string representation of the file content
- budget_file_content = request.data.get('budget_file')
+ budget_file_content = request.data.get("budget_file")
# Convert the string to a file object
file_obj = None
if budget_file_content:
- # Create a ContentFile object
- file_obj = ContentFile(budget_file_content.encode(), name='temp_file.txt')
+ # Create a ContentFile object
+ file_obj = ContentFile(budget_file_content.encode(), name="temp_file.txt")
-# Update the request data with the File object
- request.data['budget_file'] = file_obj
+ # Update the request data with the File object
+ request.data["budget_file"] = file_obj
# Update the request data with the file object
- request.data['budget_file'] = file_obj
+ request.data["budget_file"] = file_obj
# Initialize the serializer with the modified request data
serializer = club_budgetserializer(data=request.data)
@@ -600,22 +799,29 @@ def post(self, request):
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
class DeleteClubBudgetAPIView(APIView):
def post(self, request):
- budget_id = request.data.get('id')
+ budget_id = request.data.get("id")
if budget_id is None:
- return Response({'error': 'Club budget ID not provided'}, status=status.HTTP_400_BAD_REQUEST)
+ return Response(
+ {"error": "Club budget ID not provided"},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
try:
budget_instance = Club_budget.objects.get(pk=budget_id)
except Club_budget.DoesNotExist:
- return Response({'error': 'Club budget not found'}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Club budget not found"}, status=status.HTTP_404_NOT_FOUND
+ )
budget_instance.delete()
- return Response({'message': 'Club budget deleted successfully'}, status=status.HTTP_200_OK)
+ return Response(
+ {"message": "Club budget deleted successfully"}, status=status.HTTP_200_OK
+ )
class DeleteClubAPIView(APIView):
@@ -624,15 +830,19 @@ def post(self, request):
club_data = request.data
# Extract fields for filtering
- club_name = club_data.get('club_name')
- category = club_data.get('category')
- co_ordinator = club_data.get('co_ordinator')
- co_coordinator = club_data.get('co_coordinator')
- faculty_incharge = club_data.get('faculty_incharge')
+ club_name = club_data.get("club_name")
+ category = club_data.get("category")
+ co_ordinator = club_data.get("co_ordinator")
+ co_coordinator = club_data.get("co_coordinator")
+ faculty_incharge = club_data.get("faculty_incharge")
# Check if all required fields are provided
- if not all([club_name, category, co_ordinator, co_coordinator, faculty_incharge]):
- return Response({"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST)
+ if not all(
+ [club_name, category, co_ordinator, co_coordinator, faculty_incharge]
+ ):
+ return Response(
+ {"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST
+ )
# Try to find the club based on provided fields
try:
@@ -641,16 +851,20 @@ def post(self, request):
category=category,
co_ordinator=co_ordinator,
co_coordinator=co_coordinator,
- faculty_incharge=faculty_incharge
+ faculty_incharge=faculty_incharge,
)
except Club_info.DoesNotExist:
- return Response({"error": "Club not found"}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Club not found"}, status=status.HTTP_404_NOT_FOUND
+ )
# Delete the club from the database
club.delete()
- return Response({"message": "Club deleted successfully"}, status=status.HTTP_200_OK)
-
+ return Response(
+ {"message": "Club deleted successfully"}, status=status.HTTP_200_OK
+ )
+
# class ClubCreateAPIView(APIView):
# def post(self, request, format=None):
@@ -677,18 +891,20 @@ def post(self, request):
class CreateClubAPIView(APIView):
def post(self, request):
# Get the string representation of the file content for club_file
- club_file_content = request.data.get('club_file')
+ club_file_content = request.data.get("club_file")
# Convert the string to a file object for club_file
club_file_obj = None
if club_file_content:
- club_file_obj = ContentFile(club_file_content.encode(), name='club_file.txt')
+ club_file_obj = ContentFile(
+ club_file_content.encode(), name="club_file.txt"
+ )
# Update the request data with the file object for club_file
- request.data['club_file'] = club_file_obj
+ request.data["club_file"] = club_file_obj
# Get the string representation of the file content for activity_calendar
- description = request.data.get('description')
+ description = request.data.get("description")
# Initialize the serializer with the modified request data
serializer = Club_infoSerializer(data=request.data)
@@ -700,21 +916,22 @@ def post(self, request):
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
-
class UpdateClubStatusAPIView(APIView):
def post(self, request):
# Retrieve data from request
club_data = request.data
# Extract fields for filtering
- club_name = club_data.get('club_name')
- co_ordinator = club_data.get('co_ordinator')
- co_coordinator = club_data.get('co_coordinator')
- faculty_incharge = club_data.get('faculty_incharge')
+ club_name = club_data.get("club_name")
+ co_ordinator = club_data.get("co_ordinator")
+ co_coordinator = club_data.get("co_coordinator")
+ faculty_incharge = club_data.get("faculty_incharge")
# Check if all required fields are provided
if not all([club_name, co_ordinator, co_coordinator, faculty_incharge]):
- return Response({"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST)
+ return Response(
+ {"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST
+ )
# Try to find the club based on provided fields
try:
@@ -722,20 +939,21 @@ def post(self, request):
club_name=club_name,
co_ordinator=co_ordinator,
co_coordinator=co_coordinator,
- faculty_incharge=faculty_incharge
+ faculty_incharge=faculty_incharge,
)
except Club_info.DoesNotExist:
- return Response({"error": "Club not found"}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Club not found"}, status=status.HTTP_404_NOT_FOUND
+ )
# Update the status of the club
- club.status = 'confirmed'
+ club.status = "confirmed"
club.save()
- return Response({"message": "Club status updated to 'confirmed' successfully"}, status=status.HTTP_200_OK)
-
-
-
-
+ return Response(
+ {"message": "Club status updated to 'confirmed' successfully"},
+ status=status.HTTP_200_OK,
+ )
# class UpdateClubNameAPIView(APIView):
@@ -772,22 +990,25 @@ def post(self, request):
# return Response({"message": "Club name updated successfully"}, status=status.HTTP_200_OK)
-
class UpdateClubNameAPIView(APIView):
def post(self, request):
# Retrieve data from request
club_data = request.data
# Extract fields for filtering
- club_name = club_data.get('club_name')
- co_ordinator = club_data.get('co_ordinator')
- co_coordinator = club_data.get('co_coordinator')
- faculty_incharge = club_data.get('faculty_incharge')
- new_club = club_data.get('new_club')
+ club_name = club_data.get("club_name")
+ co_ordinator = club_data.get("co_ordinator")
+ co_coordinator = club_data.get("co_coordinator")
+ faculty_incharge = club_data.get("faculty_incharge")
+ new_club = club_data.get("new_club")
# Check if all required fields are provided
- if not all([club_name, co_ordinator, co_coordinator, faculty_incharge, new_club]):
- return Response({"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST)
+ if not all(
+ [club_name, co_ordinator, co_coordinator, faculty_incharge, new_club]
+ ):
+ return Response(
+ {"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST
+ )
# Try to find the club based on provided fields
try:
@@ -795,14 +1016,19 @@ def post(self, request):
club_name=club_name,
co_ordinator=co_ordinator,
co_coordinator=co_coordinator,
- faculty_incharge=faculty_incharge
+ faculty_incharge=faculty_incharge,
)
except Club_info.DoesNotExist:
- return Response({"error": "Club not found"}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Club not found"}, status=status.HTTP_404_NOT_FOUND
+ )
# Check if a club with the new name already exists
if Club_info.objects.filter(club_name=new_club).exists():
- return Response({"error": f"A club with the name '{new_club}' already exists"}, status=status.HTTP_400_BAD_REQUEST)
+ return Response(
+ {"error": f"A club with the name '{new_club}' already exists"},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
# Update the status of the club
club.club_name = new_club
@@ -811,41 +1037,792 @@ def post(self, request):
# Delete the original club entry
Club_info.objects.filter(club_name=club_name).delete()
- return Response({"message": "Club name updated successfully"}, status=status.HTTP_200_OK)
-
+ return Response(
+ {"message": "Club name updated successfully"}, status=status.HTTP_200_OK
+ )
class ApproveEvent(APIView):
def post(self, request):
- # Retrieve data from request
event_data = request.data
-
- # Extract fields for filtering
- event_name = event_data.get('event_name')
- incharge = event_data.get('incharge')
- date = event_data.get('date')
- venue = event_data.get('venue')
- event_id = event_data.get('id')
- # status = event_data.get('status')
-
- # Check if all required fields are provided
+ event_name = event_data.get("event_name")
+ incharge = event_data.get("incharge")
+ date = event_data.get("date")
+ venue = event_data.get("venue")
+ event_id = event_data.get("id")
if not all([event_name, incharge, date, venue, event_id]):
- return Response({"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST)
-
- # Try to find the event based on provided fields
+ return Response(
+ {"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST
+ )
try:
event = Event_info.objects.get(
event_name=event_name,
incharge=incharge,
date=date,
venue=venue,
- id=event_id
+ id=event_id,
)
except Event_info.DoesNotExist:
- return Response({"error": "Event not found"}, status=status.HTTP_404_NOT_FOUND)
+ return Response(
+ {"error": "Event not found"}, status=status.HTTP_404_NOT_FOUND
+ )
+ event.status = "confirmed"
+ event.save()
+ return Response(
+ {"message": "event status updated successfully"}, status=status.HTTP_200_OK
+ )
+
+
+class AddClubAPI(APIView):
+ def post(self, request):
+ serializer = Club_infoSerializer(data=request.data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(
+ {"message": "Club added successfully!"}, status=status.HTTP_201_CREATED
+ )
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+class NewEventAPIView(APIView):
+ def put(self, request):
+ request.data["status"] = "FIC"
+ serializer = event_infoserializer(data=request.data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_200_OK)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
+class FICApproveEventAPIView(APIView):
+ def put(self, request):
+ event_id = request.data.get("id")
+ event = get_object_or_404(Event_info, id=event_id)
+ if event.status != "FIC":
+ return Response(
+ {"error": "Event is not under FIC review."},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+ event.status = "COUNSELLOR"
+ event.save()
+
+ return Response(
+ {"message": "Event status changed to 'Counsellor Review'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class CounsellorApproveEventAPIView(APIView):
+ def put(self, request):
+ event_id = request.data.get("id")
+ event = get_object_or_404(Event_info, id=event_id)
+ if event.status != "COUNSELLOR":
+ return Response(
+ {"error": "Event is not under Counsellor review."},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+ event.status = "DEAN"
+ event.save()
+
+ return Response(
+ {"message": "Event status changed to 'Dean Review'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class DeanApproveEventAPIView(APIView):
+ def put(self, request):
+ event_id = request.data.get("id")
+ event = get_object_or_404(Event_info, id=event_id)
+ if event.status != "DEAN":
+ return Response(
+ {"error": "Event is not under Dean review."},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+ event.status = "ACCEPT"
+ event.save()
+
+ return Response(
+ {"message": "Event status changed to 'Accepted'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class NewBudgetAPIView(APIView):
+ def put(self, request):
+ request.data["status"] = "FIC"
+ serializer = BudgetSerializer(data=request.data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_200_OK)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
+class FICApproveBudgetAPIView(APIView):
+ def put(self, request):
+ budget_id = request.data.get("id")
+ budget = get_object_or_404(Budget, id=budget_id)
+ if budget.status != "FIC":
+ return Response(
+ {"error": "Budget is not under FIC review."},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+ budget.status = "COUNSELLOR"
+ budget.save()
+ return Response(
+ {"message": "Budget status changed to 'Counsellor Review'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class CounsellorApproveBudgetAPIView(APIView):
+ def put(self, request):
+ budget_id = request.data.get('id')
+ budget = get_object_or_404(Budget, id=budget_id)
+ if budget.status != 'COUNSELLOR' and budget.status != 'REREVIEW':
+ return Response({"error": "Budget is not under Counsellor review."}, status=status.HTTP_400_BAD_REQUEST)
+ if budget.status == 'REREVIEW':
+ budget.status = 'ACCEPT'
+ else:
+ budget.status = 'DEAN'
+ serializer = BudgetSerializer(budget, data=request.data, partial=True)
+ if serializer.is_valid():
+ serializer.save(status=budget.status)
+ return Response({"message": "Budget updated and status changed"}, status=status.HTTP_200_OK)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
+class DeanApproveBudgetAPIView(APIView):
+ def put(self, request):
+ budget_id = request.data.get("id")
+ budget = get_object_or_404(Budget, id=budget_id)
+ if budget.status != "DEAN":
+ return Response(
+ {"error": "Budget is not under Dean review."},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+ budget.status = "ACCEPT"
+ budget.save()
+ return Response(
+ {"message": "Budget status changed to 'Accepted'."},
+ status=status.HTTP_200_OK,
+ )
+
+class DeanReviewBudgetAPIView(APIView):
+ def put(self, request):
+ budget_id = request.data.get('id')
+ budget = get_object_or_404(Budget, id=budget_id)
+
+ if budget.status != 'DEAN':
+ return Response({"error": "Budget is not under Dean review."}, status=status.HTTP_400_BAD_REQUEST)
+
+ serializer = BudgetSerializer(budget, data=request.data, partial=True)
+ if serializer.is_valid():
+ serializer.save(status='REREVIEW')
+ return Response({"message": "Budget updated and status changed to 'Dean Review'."}, status=status.HTTP_200_OK)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+class RejectBudgetAPIView(APIView):
+ def put(self, request):
+ budget_id = request.data.get("id")
+ budget = get_object_or_404(Budget, id=budget_id)
+ budget.status = "REJECT"
+ budget.save()
+ return Response(
+ {"message": "Budget status changed to 'Rejected'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class RejectEventAPIView(APIView):
+ def put(self, request):
+ event_id = request.data.get("id")
+ event = get_object_or_404(Event_info, id=event_id)
+ event.status = "REJECT"
+ event.save()
+ return Response(
+ {"message": "Event status changed to 'Rejected'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class AchievementsAPIView(APIView):
+ def post(self, request):
+ club_name = request.data.get("club_name")
+ achievements = Achievements.objects.filter(club_name=club_name)
+ if not achievements.exists():
+ return Response(
+ {"message": "No achievements found for this club."}, status=404
+ )
+
+ serializer = AchievementsSerializer(achievements, many=True)
+ return Response(serializer.data, status=200)
+
+
+class AddAchievementAPIView(APIView):
+ def post(self, request):
+ serializer = AchievementsSerializer(data=request.data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
+class CreateBudgetCommentAPIView(APIView):
+ def post(self, request):
+ data = request.data.copy()
+ data["comment_date"] = timezone.now().date()
+ data["comment_time"] = timezone.now().time()
+
+ serializer = Budget_CommentsSerializer(data=data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
- # Update the status of the event
- event.status = 'confirmed'
+
+class CreateEventCommentAPIView(APIView):
+ def post(self, request):
+ data = request.data.copy()
+ data["comment_date"] = timezone.now().date()
+ data["comment_time"] = timezone.now().time()
+
+ serializer = Event_CommentsSerializer(data=data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
+class ListBudgetCommentsAPIView(APIView):
+ def post(self, request):
+ budget_id = request.data.get("budget_id")
+ if not budget_id:
+ return Response(
+ {"error": "Budget ID is required."}, status=status.HTTP_400_BAD_REQUEST
+ )
+
+ comments = Budget_Comments.objects.filter(budget_id=budget_id).order_by(
+ "comment_date", "comment_time"
+ )
+ serializer = Budget_CommentsSerializer(comments, many=True)
+ return Response(serializer.data, status=status.HTTP_200_OK)
+
+
+class ListEventCommentsAPIView(APIView):
+ def post(self, request):
+ event_id = request.data.get("event_id")
+ if not event_id:
+ return Response(
+ {"error": "Event ID is required."}, status=status.HTTP_400_BAD_REQUEST
+ )
+
+ comments = Event_Comments.objects.filter(event_id=event_id).order_by(
+ "comment_date", "comment_time"
+ )
+ serializer = Event_CommentsSerializer(comments, many=True)
+ return Response(serializer.data, status=status.HTTP_200_OK)
+
+
+class RejectEventAPIView(APIView):
+ def put(self, request):
+ event_id = request.data.get("id")
+ event = get_object_or_404(Event_info, id=event_id)
+ event.status = "REJECT"
+ event.save()
+ return Response(
+ {"message": "Event status changed to 'Rejected'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class ModifyEventAPIView(APIView):
+ def put(self, request):
+ event_id = request.data.get("id")
+ event = get_object_or_404(Event_info, id=event_id)
+ event.status = "COORDINATOR"
event.save()
+ return Response(
+ {"message": "Event status changed to 'Coordinator review'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class ModifyBudgetAPIView(APIView):
+ def put(self, request):
+ budget_id = request.data.get("id")
+ budget = get_object_or_404(Budget, id=budget_id)
+ budget.status = "COORDINATOR"
+ budget.save()
+ return Response(
+ {"message": "Budget status changed to 'Coordinator Review'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class RejectMemberAPIView(APIView):
+ def put(self, request):
+ member_id = request.data.get("id")
+ member = get_object_or_404(Club_member, id=member_id)
+ member.status = "rejected"
+ member.save()
+ return Response(
+ {"message": "Member status changed to 'rejected'."},
+ status=status.HTTP_200_OK,
+ )
+
+
+class AddClubPositionAPIView(APIView):
+ def post(self, request):
+ serializer = ClubPositionSerializer(data=request.data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
+class ListClubPositionAPIView(APIView):
+ def post(self, request):
+ name = request.data.get("name")
+ positions = ClubPosition.objects.filter(name=name)
+ serializer = ClubPositionSerializer(positions, many=True)
+ return Response(serializer.data, status=status.HTTP_200_OK)
- return Response({"message": "event status updated successfully"}, status=status.HTTP_200_OK)
\ No newline at end of file
+
+class UpdateEventAPIView(APIView):
+ def put(self, request):
+ try:
+ # Fetch the event to be updated
+ pk = request.data.get("id")
+ event = Event_info.objects.get(pk=pk)
+ except Event_info.DoesNotExist:
+ return Response(
+ {"error": "Event not found"}, status=status.HTTP_404_NOT_FOUND
+ )
+
+ # Partial update for 'details' and 'event_poster'
+ data = {}
+ if "details" in request.data:
+ data["details"] = request.data["details"]
+ if "event_poster" in request.FILES:
+ data["event_poster"] = request.FILES["event_poster"]
+ data["status"] = "FIC"
+
+ # Create serializer instance with partial=True to allow partial updates
+ serializer = event_infoserializer(event, data=data, partial=True)
+
+ # Validate and update
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_200_OK)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+
+class UpdateBudgetAPIView(APIView):
+ def put(self, request):
+ try:
+ # Fetch the event to be updated
+ pk = request.data.get("id")
+ budget = Budget.objects.get(pk=pk)
+ except Budget.DoesNotExist:
+ return Response(
+ {"error": "Event not found"}, status=status.HTTP_404_NOT_FOUND
+ )
+
+ # Partial update for 'details' and 'event_poster'
+ data = {}
+ if "budget_amt" in request.data:
+ data["budget_amt"] = request.data["budget_amt"]
+ if "remarks" in request.data:
+ data["remarks"] = request.data["remarks"]
+ if "budget_file" in request.FILES:
+ data["budget_file"] = request.FILES["budget_file"]
+ data["status"] = "FIC"
+
+ # Create serializer instance with partial=True to allow partial updates
+ serializer = BudgetSerializer(budget, data=data, partial=True)
+
+ # Validate and update
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_200_OK)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+class FreeMembersForClubAPIView(APIView):
+ def get(self, request):
+ club_id = request.data.get('club_id') # Use query_params for GET request
+ if not club_id:
+ return Response({"error": "Club id is required."}, status=status.HTTP_400_BAD_REQUEST)
+
+ try:
+ # Get upcoming events for the club
+ events = Event_info.objects.filter(club_id=club_id, start_date__gte =timezone.now().date())
+
+ # Map incharge members to their events
+ incharge_map = {}
+ for event in events:
+ if event.incharge: # Ensure incharge is not None
+ incharge_map[str(event.incharge)] = event.event_name
+
+ # Get all club members
+ members = Club_member.objects.filter(club_id=club_id)
+
+ # Prepare the response data
+ response_data = []
+ for memb in members:
+ roll_no = str(memb.member_id) # Ensure same type as incharge_map keys
+ response_data.append({
+ "roll_no": roll_no,
+ "event_name": incharge_map.get(roll_no, None) # Set event_name or None
+ })
+
+ return Response(response_data, status=status.HTTP_200_OK)
+
+ except Exception as e:
+ return Response({"error": str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+class CoordinatorEventsAPIView(APIView):
+ """
+ API View to fetch events for clubs where the given person (by roll number) is a coordinator.
+ Filters by accepted events and those in the current month.
+ """
+
+ def post(self, request):
+ # Extract roll number from the request data
+ roll_number = request.data.get("roll_number")
+ if not roll_number:
+ return Response(
+ {"error": "Roll number is required."},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+
+ try:
+ clubs = Club_info.objects.filter(co_ordinator=roll_number)
+ # Get the current month and year
+ current_month = datetime.datetime.now().month
+ current_year = datetime.datetime.now().year
+
+ # Fetch events associated with those clubs, with status 'accepted' and within the same month
+ events = Event_info.objects.filter(
+ club__in=clubs,
+ # status="Accepted", # Replace with your actual status choice
+ # start_date__year=current_year,
+ # start_date__month=current_month,
+ )
+
+ # Serialize and return the events
+ serializer = event_infoserializer(events, many=True)
+ return Response(serializer.data, status=status.HTTP_200_OK)
+
+ except Student.DoesNotExist:
+ return Response(
+ {"error": "Student not found with the given roll number."},
+ status=status.HTTP_404_NOT_FOUND,
+ )
+
+class EventInputAPIView(APIView):
+ def get(self, request):
+ """
+ Returns a list of all Event_info objects (dropdown options).
+ """
+ events = Event_info.objects.all()
+ events_data = [{"id": event.id, "name": event.event_name} for event in events] # Adjust fields as needed
+ return Response(events_data, status=status.HTTP_200_OK)
+
+ def post(self, request):
+ """
+ Creates a new EventInput instance.
+ """
+ # print(request.data["event"])
+ # request.data["images"]=None
+ print(request.data)
+ serializer = EventInputSerializer(data=request.data)
+ if serializer.is_valid():
+ serializer.save()
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+#helper
+def add_page_decorations(canvas, doc):
+ canvas.saveState()
+ page_num = canvas.getPageNumber()
+ canvas.setFont('Helvetica', 10)
+ canvas.drawCentredString(letter[0] / 2.0, 20, f"Page {page_num}")
+ canvas.restoreState()
+
+class NewsletterPDFAPIView(APIView):
+ def get(self, request):
+ # Determine timeframe filter based on query parameter
+ timeframe = request.GET.get('timeframe', '').lower()
+ now = timezone.now()
+ if timeframe == 'weekly':
+ time_threshold = (now - timedelta(weeks=1))
+ elif timeframe == 'monthly':
+ time_threshold = now - timedelta(days=30)
+ elif timeframe == '6 months':
+ time_threshold = now - timedelta(days=182) # Approximation for half a year
+ else:
+ time_threshold = None
+ print(time_threshold,now)
+ # Fetch all unique clubs
+ clubs = Event_info.objects.values_list('club', flat=True).distinct()
+ has_events = False
+ print(clubs)
+ for club in clubs:
+ club_events = EventInput.objects.filter(event__club=club)
+ if time_threshold:
+ club_events = club_events.filter(event__end_date__range=(time_threshold, now))
+ print(club_events)
+ if club_events.exists():
+ has_events = True
+ break
+
+ if not has_events:
+ return Response({"message": "No events found for the selected timeframe."}, status=status.HTTP_404_NOT_FOUND)
+
+ # Create an in-memory file
+ buffer = BytesIO()
+ doc = SimpleDocTemplate(buffer, pagesize=letter)
+
+ # Get the default style sheet and create custom styles
+ styles = getSampleStyleSheet()
+ story = []
+
+ # --- Banner Section ---
+ banner_path = "path/to/your/banner.jpg" # Update this path to your banner image
+ try:
+ banner = Image(banner_path, width=letter[0], height=150)
+ story.append(banner)
+ except Exception:
+ pass
+
+ story.append(Spacer(1, 20))
+
+ # Catchy Title and Tagline
+ title_style = ParagraphStyle(
+ name='TitleStyle',
+ parent=styles['Title'],
+ fontName='Helvetica-Bold',
+ fontSize=26,
+ leading=30,
+ alignment=1,
+ textColor=colors.darkblue
+ )
+ tagline_style = ParagraphStyle(
+ name='Tagline',
+ parent=styles['BodyText'],
+ fontName='Helvetica-Oblique',
+ fontSize=14,
+ leading=18,
+ alignment=1,
+ textColor=colors.darkgray
+ )
+
+ story.append(Paragraph("IIITDM Jabalpur Gymkhana Newsletter", title_style))
+ story.append(Spacer(1, 10))
+ story.append(Paragraph("Stay tuned for the latest happenings and exclusive updates!", tagline_style))
+ story.append(Spacer(1, 30))
+
+ # Introductory paragraph
+ intro_style = ParagraphStyle(
+ name='Intro',
+ parent=styles['BodyText'],
+ fontSize=12,
+ leading=16,
+ alignment=1,
+ textColor=colors.black
+ )
+ intro_text = (
+ "Welcome to our monthly newsletter where we bring you the most exciting events from various clubs. "
+ "Dive into details, get inspired, and mark your calendars for a memorable experience!"
+ )
+ story.append(Paragraph(intro_text, intro_style))
+ story.append(Spacer(1, 40))
+
+ # --- Newsletter Content ---
+ club_header_style = ParagraphStyle(
+ name='ClubHeader',
+ fontName='Helvetica-Bold',
+ fontSize=18,
+ leading=22,
+ textColor=colors.darkred,
+ backColor=colors.whitesmoke,
+ spaceAfter=10,
+ borderPadding=(5, 5, 5, 5)
+ )
+
+ event_heading_style = ParagraphStyle(
+ name='EventHeading',
+ fontName='Helvetica-Bold',
+ fontSize=14,
+ leading=18,
+ textColor=colors.darkgreen
+ )
+
+ body_text_style = ParagraphStyle(
+ name='BodyText',
+ parent=styles['BodyText'],
+ fontSize=12,
+ leading=15,
+ textColor=colors.black
+ )
+
+ italic_style = ParagraphStyle(
+ name='Italic',
+ parent=styles['BodyText'],
+ fontName='Helvetica-Oblique',
+ fontSize=12,
+ leading=15,
+ textColor=colors.gray
+ )
+
+ for club in clubs:
+ story.append(Paragraph(f"Club: {club}", club_header_style))
+ story.append(Spacer(1, 20))
+
+ club_events = EventInput.objects.filter(event__club=club)
+ if time_threshold:
+ club_events = club_events.filter(event__end_date__range=(time_threshold, now))
+
+ for event in club_events:
+ event_info = event.event
+
+ story.append(HRFlowable(width="100%", thickness=1, color=colors.lightgrey))
+ story.append(Spacer(1, 10))
+ story.append(Paragraph("Event Details", event_heading_style))
+ story.append(Spacer(1, 10))
+
+ story.append(Paragraph(f"Event: {event_info.event_name}", body_text_style))
+ story.append(Spacer(1, 10))
+
+ story.append(Paragraph(
+ f"Start Date: {event_info.start_date.strftime('%B %d, %Y')}",
+ body_text_style))
+ story.append(Spacer(1, 10))
+
+ story.append(Paragraph(
+ f"Start Time: {event_info.start_time.strftime('%I:%M %p')}",
+ body_text_style))
+ story.append(Spacer(1, 10))
+
+ story.append(Paragraph(
+ f"Venue: {event_info.venue}",
+ body_text_style))
+ story.append(Spacer(1, 10))
+
+ story.append(Paragraph("Description:", event_heading_style))
+ story.append(Paragraph(f"{event.description}", body_text_style))
+ story.append(Spacer(1, 10))
+
+ if event.images:
+ image_path = event.images.path
+ try:
+ story.append(Image(image_path, width=200, height=150))
+ except Exception:
+ story.append(Paragraph("[Image could not be loaded]", body_text_style))
+ else:
+ story.append(Paragraph("[Image Placeholder]", body_text_style))
+
+ story.append(Spacer(1, 10))
+ story.append(Paragraph(
+ "Additional Information: Stay tuned for more updates and behind-the-scenes insights!",
+ italic_style))
+ story.append(Spacer(1, 30))
+
+ story.append(PageBreak())
+
+ doc.build(story, onFirstPage=add_page_decorations, onLaterPages=add_page_decorations)
+ buffer.seek(0)
+
+ return FileResponse(buffer, as_attachment=True, filename="newsletter.pdf")
+
+class EventReportAPIView(APIView):
+ def post(self, request):
+ data = request.data.copy()
+ event_id = data.get("event")
+
+ if isinstance(event_id, str) and event_id.isdigit():
+ event_id = int(event_id)
+
+ try:
+ event_instance = Event_info.objects.get(pk=event_id)
+ data["event"] = event_instance.pk # Assigning the ID, not the instance
+ except Event_info.DoesNotExist:
+ return Response({"error": "Invalid event ID"}, status=status.HTTP_400_BAD_REQUEST)
+
+ serializer = EventReportSerializer(data=data)
+ if serializer.is_valid():
+ event_report = serializer.save()
+
+ # Generate PDF using ReportLab
+ buffer = BytesIO()
+ doc = SimpleDocTemplate(buffer, pagesize=letter)
+ elements = []
+
+ styles = getSampleStyleSheet()
+ title_style = ParagraphStyle(
+ "TitleStyle",
+ parent=styles["Title"],
+ fontSize=16,
+ textColor=colors.darkblue,
+ alignment=1, # Center alignment
+ )
+ normal_style = styles["Normal"]
+
+ elements.append(Paragraph(f"Event Report for {event_instance.event_name}", title_style))
+ elements.append(HRFlowable(width="100%", thickness=1, color=colors.black))
+ elements.append(Spacer(1, 12))
+ elements.append(Paragraph(f"Club: {event_instance.club}", normal_style))
+ elements.append(Paragraph(f"Venue: {event_report.venue}", normal_style))
+ elements.append(Paragraph(f"Incharge: {event_report.incharge}", normal_style))
+ elements.append(Paragraph(f"Start Date: {event_report.start_date}", normal_style))
+ elements.append(Paragraph(f"End Date: {event_report.end_date}", normal_style))
+ elements.append(Paragraph(f"Start Time: {event_report.start_time}", normal_style))
+ elements.append(Paragraph(f"End Time: {event_report.end_time}", normal_style))
+ elements.append(Paragraph(f"Budget: {event_report.event_budget}", normal_style))
+ elements.append(Paragraph(f"Special Announcement: {event_report.special_announcement or 'None'}", normal_style))
+ elements.append(PageBreak())
+
+ doc.build(elements)
+ buffer.seek(0)
+
+ file_name = f"event_report_{event_report.id}.pdf"
+ event_report.report_pdf.save(file_name, ContentFile(buffer.getvalue()), save=True)
+
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+class EventReportListAPIView(APIView):
+ def get(self, request):
+ club_id = request.query_params.get("club")
+ if not club_id:
+ return Response({"error": "Club ID is required"}, status=status.HTTP_400_BAD_REQUEST)
+ print(club_id)
+ events = Event_info.objects.filter(club=club_id)
+ print(events)
+ event_reports = EventReport.objects.filter(event_id__in=events)
+ serializer = EventReportSerializer(event_reports, many=True)
+ return Response(serializer.data, status=status.HTTP_200_OK)
+class EventReportPDFView(APIView):
+ def get(self, request, report_id):
+ try:
+ event_report = EventReport.objects.get(pk=report_id)
+ if not event_report.report_pdf:
+ return Response({"error": "No PDF report available for this event"}, status=status.HTTP_404_NOT_FOUND)
+
+ return FileResponse(event_report.report_pdf.open('rb'), content_type='application/pdf')
+
+ except EventReport.DoesNotExist:
+ return Response({"error": "Event report not found"}, status=status.HTTP_404_NOT_FOUND)
+
+class UpdateBudgetAPIView(APIView):
+ def put(self, request):
+ budget_id = request.data.get('id')
+ budget = get_object_or_404(Budget, id=budget_id)
+ if budget.status != 'COORDINATOR':
+ return Response({"error": "Budget is not under Coordinator."}, status=status.HTTP_400_BAD_REQUEST)
+ budget.status = 'FIC'
+ serializer = BudgetSerializer(budget, data=request.data, partial=True)
+ if serializer.is_valid():
+ serializer.save(status=budget.status)
+ return Response({"message": "Budget updated and status changed"}, status=status.HTTP_200_OK)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
\ No newline at end of file
diff --git a/FusionIIIT/applications/gymkhana/models.py b/FusionIIIT/applications/gymkhana/models.py
index 3544f2f3b..d33450eaf 100644
--- a/FusionIIIT/applications/gymkhana/models.py
+++ b/FusionIIIT/applications/gymkhana/models.py
@@ -27,23 +27,55 @@ class Constants:
("Sports", "Sports"),
("Cultural", "Cultural"),
)
- status = (("open", "Open"), ("confirmed", "Confirmed"), ("rejected", "Rejected"))
+ status = (("open", "Open"), ("confirmed", "Confirmed"), ("rejected", "Rejected") ,("member", "Member"),("co-ordinator", "Co-ordinator"),("Co-cordinator", "Co-cordinator"))
+ STATUS_CHOICES = (
+ ('ACCEPT', 'Accepted'),
+ ('REJECT', 'Rejected'),
+ ('COORDINATOR', 'Coordinator Review'),
+ ('FIC', 'FIC Review'),
+ ('COUNSELLOR', 'Counsellor Review'),
+ ('DEAN', 'Dean Review'),
+ ('REREVIEW', 'ReReview'),
+ )
fest = (("Abhikalpan", "Abhikalpan"), ("Gusto", "Gusto"), ("Tarang", "Tarang"))
venue = (
- (
- "Classroom",
- (
- ("CR101", "CR101"),
- ("CR102", "CR102"),
- ),
- ),
- (
- "Lecturehall",
- (
- ("L101", "L101"),
- ("L102", "L102"),
- ),
- ),
+ ("CR101", "CR101"),
+ ("CR102", "CR102"),
+ ("CR103", "CR103"),
+ ("CR104", "CR104"),
+ ("CR107", "CR107"),
+ ("CR108", "CR108"),
+ ("CR109", "CR109"),
+ ("CR201", "CR201"),
+ ("CR202", "CR202"),
+ ("CR208", "CR208"),
+ ("L101", "L101"),
+ ("L102", "L102"),
+ ("L103", "L103"),
+ ("L104", "L104"),
+ ("L105", "L105"),
+ ("L106", "L106"),
+ ("L107", "L107"),
+ ("L108", "L108"),
+ ("L201", "L201"),
+ ("L202", "L202"),
+ ("L206", "L206"),
+ ("L207", "L207"),
+ ("Football Ground", "Football Ground"),
+ ("Cricket Ground", "Cricket Ground"),
+ ("Basketball Ground", "Basketball Ground"),
+ ("Volleyball Ground", "Volleyball Ground"),
+ ("Tennis Court", "Tennis Court"),
+ ("Athletics Ground", "Athletics Ground"),
+ ("Badminton Court", "Badminton Court"),
+ ("Table Tennis Court", "Table Tennis Court"),
+ ("Chess Room", "Chess Room"),
+ ("Carrom Room", "Carrom Room"),
+ ("Gym", "Gym"),
+ ("CC First Floor", "CC First Floor"),
+ ("CC Second Floor", "CC Second Floor"),
+ ("CC Third Floor", "CC Third Floor"),
+ ("OAT", "OAT"),
)
@@ -180,36 +212,37 @@ class Meta:
db_table = "Club_member"
-class Core_team(models.Model):
- """
- The details about the main members who conducted/take care of the fest.
- It stores the indormation of those members.
+# class Core_team(models.Model):
+# """
+# The details about the main members who conducted/take care of the fest.
+# It stores the indormation of those members.
- id - serial number
- student_id - roll number of student
- team - name of the core_team
- year - year in which this team conducted the fest
- fest_name - name of the fest the core_team students takes care of
- pda - achievements they achieved through the fest
- remarks - remarks(if there are any) in the fest
+# id - serial number
+# student_id - roll number of student
+# team - name of the core_team
+# year - year in which this team conducted the fest
+# fest_name - name of the fest the core_team students takes care of
+# pda - achievements they achieved through the fest
+# remarks - remarks(if there are any) in the fest
- """
+# """
- id = models.AutoField(primary_key=True)
- student_id = models.ForeignKey(
- Student, on_delete=models.CASCADE, related_name="applied_for"
- )
- team = models.CharField(max_length=50, null=False)
- year = models.DateTimeField(max_length=6, null=True)
- fest_name = models.CharField(max_length=256, null=False, choices=Constants.fest)
- pda = models.TextField(max_length=256, null=False)
- remarks = models.CharField(max_length=256, null=True)
+# id = models.AutoField(primary_key=True)
+# student_id = models.ForeignKey(
+# Student, on_delete=models.CASCADE, related_name="applied_for"
+# )
+# team = models.CharField(max_length=50, null=False)
+# year = models.DateTimeField(max_length=6, null=True)
+# fest_name = models.CharField(max_length=256, null=False, choices=Constants.fest)
+# pda = models.TextField(max_length=256, null=False)
+# remarks = models.CharField(max_length=256, null=True)
- def __str__(self):
- return str(self.student_id)
+# def __str__(self):
+# return str(self.student_id)
+
+# class Meta:
+# db_table = "Core_team"
- class Meta:
- db_table = "Core_team"
class Club_budget(models.Model):
@@ -284,7 +317,8 @@ class Event_info(models.Model):
event_name - name of the event
venue - the place at which they conducting the event
incharge - name of faculty who is incharge for the event
- date - date of the event
+ start_date - start date of the event
+ end_date - end date of event
start_time - the time at which event starts
end_time - the time at which event ends
event_poster - the logo/poster for the event(image)
@@ -300,13 +334,14 @@ class Event_info(models.Model):
event_name = models.CharField(max_length=256, null=False)
venue = models.CharField(max_length=50, null=False, choices=Constants.venue)
incharge = models.CharField(max_length=256, null=False)
- date = models.DateField(default=None, auto_now=False, null=False)
+ end_date = models.DateField(default=None, auto_now=False, null=False)
+ start_date=models.DateField(default=None, auto_now=False, null=False)
start_time = models.TimeField(default=None, auto_now=False, null=False)
end_time = models.TimeField(default=None, auto_now=False, null=True)
event_poster = models.FileField(upload_to="gymkhana/event_poster", blank=True)
details = models.TextField(max_length=256, null=True)
- status = models.CharField(max_length=50, choices=Constants.status, default="open")
-
+ status = models.CharField(max_length=50, choices=Constants.STATUS_CHOICES, default="open")
+ #change the status choices
def __str__(self):
return str(self.id)
@@ -347,6 +382,18 @@ def __str__(self):
class Meta:
db_table = "Club_report"
+class Fest(models.Model):
+ id=models.AutoField(primary_key=True)
+ name=models.CharField(max_length=50, null=False)
+ category=models.CharField(max_length=50, null=False, choices=Constants.categoryCh)
+ description=models.TextField(max_length=256, null=True)
+ date = models.DateField(default=None, auto_now=False, null=False)
+ link=models.CharField(max_length=256, null=True)
+
+ def _str_(self):
+ return str(self.id)
+ class Meta:
+ db_table="fest"
class Fest_budget(models.Model):
"""
@@ -445,71 +492,71 @@ class Meta:
db_table = "Change_office"
-class Voting_polls(models.Model):
- """
- It shows the information about the voting poll.
+# class Voting_polls(models.Model):
+# """
+# It shows the information about the voting poll.
- title - title of the poll
- description - explanation about the voting
- pub_date - the date at which polling starts
- exp_date - the date at which polling ends
- created_by - name of the person who created this poll
- groups - the groups that are participating in the voting
+# title - title of the poll
+# description - explanation about the voting
+# pub_date - the date at which polling starts
+# exp_date - the date at which polling ends
+# created_by - name of the person who created this poll
+# groups - the groups that are participating in the voting
- """
+# """
- title = models.CharField(max_length=200, null=False)
- description = models.CharField(max_length=5000, null=False)
- pub_date = models.DateTimeField(default=timezone.now)
- exp_date = models.DateTimeField(default=timezone.now)
- created_by = models.CharField(max_length=100, null=True)
- groups = models.CharField(max_length=500, default="{}")
+# title = models.CharField(max_length=200, null=False)
+# description = models.CharField(max_length=5000, null=False)
+# pub_date = models.DateTimeField(default=timezone.now)
+# exp_date = models.DateTimeField(default=timezone.now)
+# created_by = models.CharField(max_length=100, null=True)
+# groups = models.CharField(max_length=500, default="{}")
- def groups_data(self):
- return self.groups
+# def groups_data(self):
+# return self.groups
- def __str__(self):
- return self.title
+# def __str__(self):
+# return self.title
- class Meta:
- ordering = ["-pub_date"]
+# class Meta:
+# ordering = ["-pub_date"]
-class Voting_choices(models.Model):
- """
- poll_event - name of the poll_event
- title - name of the poll
- description - description about choices if any
- votes - no.of votes recorded
+# class Voting_choices(models.Model):
+# """
+# poll_event - name of the poll_event
+# title - name of the poll
+# description - description about choices if any
+# votes - no.of votes recorded
- """
+# """
- poll_event = models.ForeignKey(Voting_polls, on_delete=models.CASCADE)
- title = models.CharField(max_length=200, null=False)
- description = models.CharField(max_length=500, default="")
- votes = models.IntegerField(default=0)
+# poll_event = models.ForeignKey(Voting_polls, on_delete=models.CASCADE)
+# title = models.CharField(max_length=200, null=False)
+# description = models.CharField(max_length=500, default="")
+# votes = models.IntegerField(default=0)
- def __str__(self):
- return self.title
+# def __str__(self):
+# return self.title
- class Meta:
- get_latest_by = "votes"
+# class Meta:
+# get_latest_by = "votes"
-class Voting_voters(models.Model):
- """
- records students who has voted in the poll.
+# class Voting_voters(models.Model):
+# """
+# records students who has voted in the poll.
- poll_event - name of the poll
- student_id - roll number of student
+# poll_event - name of the poll
+# student_id - roll number of student
- """
+# """
- poll_event = models.ForeignKey(Voting_polls, on_delete=models.CASCADE)
- student_id = models.CharField(max_length=50, null=False)
+# poll_event = models.ForeignKey(Voting_polls, on_delete=models.CASCADE)
+# student_id = models.CharField(max_length=50, null=False)
- def __str__(self):
- return self.student_id
+# def __str__(self):
+# return self.student_id
class Inventory(models.Model):
@@ -526,4 +573,119 @@ def __str__(self):
return str(self.club_name)
class Meta:
- db_table = "Inventory"
\ No newline at end of file
+ db_table = "Inventory"
+class Budget(models.Model):
+ id = models.AutoField(primary_key=True)
+ club = models.ForeignKey(
+ Club_info, on_delete=models.CASCADE, max_length=50, null=False
+ )
+ budget_for = models.CharField(max_length=256, null=False)
+ budget_requested = models.IntegerField(default=0, null=False)
+ budget_allocated = models.IntegerField(default=0, null=True)
+ budget_file = models.FileField(upload_to="uploads/", null=True)
+ description = models.TextField(max_length=256, null=False)
+ status = models.CharField(max_length=50, choices=Constants.STATUS_CHOICES, default="COORDINATOR")
+ remarks = models.CharField(max_length=256, null=True)
+ budget_comment = models.CharField(max_length=2000, null=True)
+
+ def __str__(self):
+ return str(self.id)
+
+ class Meta:
+ db_table = "Budget"
+class Budget_Comments(models.Model):
+ """
+ This table stores the comments related to budgets.
+
+ Fields:
+ - budget_id: ForeignKey to the related budget entry
+ - commentator_designation: Designation of the person commenting
+ - comment: The content of the comment
+ - comment_date: The date the comment was made
+ - comment_time: The time the comment was made
+ """
+
+ budget_id = models.ForeignKey('Budget', on_delete=models.CASCADE, related_name='comments')
+ commentator_designation = models.CharField(max_length=100, null=False)
+ comment = models.TextField(null=False) # The actual comment
+ comment_date = models.DateField(default=timezone.now, null=False) # Date of the comment
+ comment_time = models.TimeField(default=timezone.now, null=False) # Time of the comment
+
+ def __str__(self):
+ return f"Comment by {self.commentator_designation} on {self.comment_date}"
+
+ class Meta:
+ db_table = "Budget_Comments"
+class Event_Comments(models.Model):
+ """
+ This table stores the comments related to budgets.
+
+ Fields:
+ - Event_id: ForeignKey to the related budget entry
+ - commentator_designation: Designation of the person commenting
+ - comment: The content of the comment
+ - comment_date: The date the comment was made
+ - comment_time: The time the comment was made
+ """
+
+ event_id = models.ForeignKey('Event_info', on_delete=models.CASCADE, related_name='comments')
+ commentator_designation = models.CharField(max_length=100, null=False)
+ comment = models.TextField(null=False) # The actual comment
+ comment_date = models.DateField(default=timezone.now, null=False) # Date of the comment
+ comment_time = models.TimeField(default=timezone.now, null=False) # Time of the comment
+
+ def __str__(self):
+ return f"Comment by {self.commentator_designation} on {self.comment_date}"
+
+ class Meta:
+ db_table = "Event_Comments"
+class Achievements(models.Model):
+ id = models.AutoField(primary_key=True)
+ club_name = models.CharField(max_length=100, null=False)
+ title = models.CharField(max_length=100, null=False)
+ achievement = models.TextField(null=False)
+ def _str_(self):
+ return f"{self.club_name} - {self.achievement}"
+
+ class Meta:
+ db_table = "Achievements"
+class ClubPosition(models.Model):
+ POSITION_CHOICES = [
+ ('FIC', 'FIC'),
+ ('COORDINATOR', 'Coordinator'),
+ ('TECHNICAL_COUNSELLOR','Technical counsellor'),
+ ('SPORTS_COUNSELLOR','Sports counsellor'),
+ ('CULTURAL_COUNSELLOR','Cultural counsellor')
+ ]
+ name = models.CharField(max_length=100, null=False)
+ position = models.CharField(max_length=50, choices=POSITION_CHOICES, null=False)
+ club = models.ForeignKey(Club_info, on_delete=models.CASCADE)
+ class Meta:
+ db_table = 'ClubPosition'
+ def _str_(self):
+ return f"{self.club.club_name} - {self.name} - {self.position}"
+ class Meta:
+ db_table = "ClubPosition"
+
+class EventInput(models.Model):
+ event=models.ForeignKey(Event_info,on_delete=models.CASCADE)
+ description=models.TextField(max_length=500)
+ images=models.ImageField(upload_to="gymkhana/event_images",null=True)
+ def _str_(self):
+ return str(self.event)
+
+class EventReport(models.Model):
+ event = models.ForeignKey(Event_info, on_delete=models.CASCADE)
+ description = models.TextField(null=True, blank=True)
+ venue = models.CharField(max_length=100, null=False)
+ incharge = models.CharField(max_length=50, null=False)
+ start_date = models.DateField(null=False)
+ end_date = models.DateField(null=False)
+ start_time = models.TimeField(null=False)
+ end_time = models.TimeField(null=False)
+ event_budget = models.DecimalField(max_digits=10, decimal_places=2, null=False)
+ special_announcement = models.TextField(null=True, blank=True)
+ report_pdf = models.FileField(upload_to='event_reports/', null=True, blank=True)
+
+ class Meta:
+ db_table = "EventReport"
\ No newline at end of file
diff --git a/FusionIIIT/applications/gymkhana/urls.py b/FusionIIIT/applications/gymkhana/urls.py
index 3c8c20de1..08be988c8 100644
--- a/FusionIIIT/applications/gymkhana/urls.py
+++ b/FusionIIIT/applications/gymkhana/urls.py
@@ -1,16 +1,86 @@
from django.conf.urls import url
from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns
-from applications.gymkhana.api.views import AddClub_BudgetAPIView, AddMemberToClub, ApproveEvent, ChangeHeadAPIView, ClubMemberAPIView, ClubMemberApproveView, ClubMemberDeleteAPIView, CreateClubAPIView, DeleteClubAPIView, DeleteClubBudgetAPIView, EventDeleteAPIView, EventUpdateAPIView, SessionUpdateAPIView, UpdateClubBudgetAPIView, UpdateClubNameAPIView, UpdateClubStatusAPIView, UploadActivityCalendarAPIView
-from applications.gymkhana.api.views import clubname,Club_Details,club_events,club_budgetinfo,Fest_Budget,club_report,Registraion_form
-from applications.gymkhana.api.views import session_details
-from applications.gymkhana.api.views import DeleteSessionsView, NewEventAPIView, NewSessionAPIView, ShowVotingChoicesAPIView, VoteIncrementAPIView, VotingPollsDeleteAPIView
+from applications.gymkhana.api.views import (
+ AddClub_BudgetAPIView,
+ AddMemberToClub,
+ ApproveEvent,
+ ChangeHeadAPIView,
+ ClubMemberAPIView,
+ ClubMemberApproveView,
+ ClubMemberDeleteAPIView,
+ CreateClubAPIView,
+ DeanReviewBudgetAPIView,
+ DeleteClubAPIView,
+ DeleteClubBudgetAPIView,
+ EventDeleteAPIView,
+ EventUpdateAPIView,
+ FreeMembersForClubAPIView,
+ SessionUpdateAPIView,
+ UpdateClubBudgetAPIView,
+ UpdateClubNameAPIView,
+ UpdateClubStatusAPIView,
+ UploadActivityCalendarAPIView,
+ ModifyEventAPIView,
+ ModifyBudgetAPIView,
+ RejectEventAPIView,
+ RejectBudgetAPIView,
+ UpdateEventAPIView,
+ FestListView,
+ EventReportListAPIView,
+ EventReportAPIView,
+ EventReportPDFView
+)
+from applications.gymkhana.api.views import (
+ clubname,
+ Club_Details,
+ club_events,
+ club_budgetinfo,
+ Fest_Budget,
+ club_report,
+ Registraion_form,
+)
+from applications.gymkhana.api.views import session_details, UpdateBudgetAPIView
+from applications.gymkhana.api.views import (
+ DeleteSessionsView,
+ NewEventAPIView,
+ NewSessionAPIView,
+ Club_Detail,
+ UpcomingEventsAPIView,
+ PastEventsAPIView,
+ Budgetinfo,
+ AddClubAPI,
+ NewBudgetAPIView,
+ FICApproveBudgetAPIView,
+ CounsellorApproveBudgetAPIView,
+ DeanApproveBudgetAPIView,
+ FICApproveEventAPIView,
+ CounsellorApproveEventAPIView,
+ DeanApproveEventAPIView,
+ AddAchievementAPIView,
+ AchievementsAPIView,
+ CreateBudgetCommentAPIView,
+ CreateEventCommentAPIView,
+ ListBudgetCommentsAPIView,
+ ListEventCommentsAPIView,
+ AddClubPositionAPIView,
+ ListClubPositionAPIView,
+ NewFestAPIView,
+ CoordinatorEventsAPIView,
+ EventInputAPIView,
+ NewsletterPDFAPIView
+)
from . import views
from rest_framework.authtoken.views import obtain_auth_token
-app_name = 'gymkhana'
+app_name = "gymkhana"
urlpatterns = [
+ # for club_detail,upcomingevents and past events
+ url(r"^club_detail/$", Club_Detail.as_view()),
+ url(r"^upcoming_events/$", UpcomingEventsAPIView.as_view()),
+ url(r"^past_events/$", PastEventsAPIView.as_view()),
+ url(r"^budget/$", Budgetinfo.as_view()),
url(r"^session_details/$", session_details.as_view()),
url(r"^event_info/$", club_events.as_view()),
url(r"^club_budgetinfo/$", club_budgetinfo.as_view()),
@@ -64,10 +134,8 @@
url(r"^date_events/$", views.date_events, name="date_events"),
url(r"^delete_sessions/$", views.delete_sessions, name="delete_sessions"),
url(r"^delete_events/$", views.delete_events, name="delete_events"),
- url(r"^(?P\d+)/edit_event/$",
- views.edit_event, name="edit_event"),
- url(r"^(?P\d+)/editsession/$",
- views.editsession, name="editsession"),
+ url(r"^(?P\d+)/edit_event/$", views.edit_event, name="edit_event"),
+ url(r"^(?P\d+)/editsession/$", views.editsession, name="editsession"),
url(r"^delete_memberform/$", views.delete_memberform, name="delete_memberform"),
# url(r'^voting_poll/$', views.voting_poll, name='voting_poll'),
# url(r'^delete_poll/(?P\d+)/$', views.delete_poll, name='delete_poll'),
@@ -81,18 +149,21 @@
url(r"^form_avail/$", views.form_avail, name="form_avail"),
url(r"^faculty_data/$", views.facultyData, name="faculty_data"),
url(r"^students_data/$", views.studentsData, name="students_data"),
- url(r"^students_club_members/$",
- views.studentsClubMembers, name="students_data"),
+ url(r"^students_club_members/$", views.studentsClubMembers, name="students_data"),
url(r"^get_venue/$", views.getVenue, name="get_venue"),
# core_team
- url(r"^core_team/$", views.core_team, name="core_team"),
+ # url(r"^core_team/$", views.core_team, name="core_team"),
url(r"^festbudget/$", views.fest_budget, name="fest_budget"),
# fic
- url(r"^Inventory_update/$", views.core_team, name="Inventory_update"),
+ # url(r"^Inventory_update/$", views.core_team, name="Inventory_update"),
url(r"^del_club/$", views.del_club, name="del_club"),
url(r"^approve_events/$", views.approve_events, name="approve_events"),
- url(r"^update-club-name/$", views.update_club_name, name='update-club-name'),
- url(r"^update-budget-amount/$", views.update_budget_amount, name='update_budget_amount'),
+ url(r"^update-club-name/$", views.update_club_name, name="update-club-name"),
+ url(
+ r"^update-budget-amount/$",
+ views.update_budget_amount,
+ name="update_budget_amount",
+ ),
# url(r"^update-spent-amount/$", views.update_spent_amount, name='update_spent_amount'),
@@ -112,16 +183,125 @@
url(r'^api/member_approve/$', ClubMemberApproveView.as_view(), name='approval'),
url(r'^api/member_reject/$', ClubMemberDeleteAPIView.as_view(), name='reject'),
url(r'^api/club_membership/$', AddMemberToClub.as_view(), name='new_club_member'),
- url(r'^api/show_voting_choices/$', ShowVotingChoicesAPIView.as_view(), name='voting_choices'),
- url(r'^api/delete_poll/$', VotingPollsDeleteAPIView.as_view(), name='delete poll'),
- url(r'^api/vote/$', VoteIncrementAPIView.as_view(), name='give vote'),
- url(r'^api/edit_session/$', SessionUpdateAPIView.as_view(), name='edit session'),
- url(r'^api/edit_event/$', EventUpdateAPIView.as_view(), name='edit event'),
- url(r'^api/delete_budget/$',DeleteClubBudgetAPIView.as_view(), name='delete budget'),
- url(r'^api/upload_activitycalender/$', UploadActivityCalendarAPIView.as_view(), name='calender'),
- url(r'^api/create_club/$', CreateClubAPIView.as_view(), name='new club'),
- url(r'^api/update_clubStatus/$', UpdateClubStatusAPIView.as_view(),name = 'update club status' ),
- url(r'^api/updateClubName/$', UpdateClubNameAPIView.as_view(), name = 'update club name'),
- url(r'^api/approve_event/$', ApproveEvent.as_view(), name = 'approve event'),
-
+ # url(r'^api/show_voting_choices/$', ShowVotingChoicesAPIView.as_view(), name='voting_choices'),
+ # url(r'^api/delete_poll/$', VotingPollsDeleteAPIView.as_view(), name='delete poll'),
+ # url(r'^api/vote/$', VoteIncrementAPIView.as_view(), name='give vote'),
+ url(r"^api/edit_session/$", SessionUpdateAPIView.as_view(), name="edit session"),
+ url(r"^api/edit_event/$", EventUpdateAPIView.as_view(), name="edit event"),
+ url(
+ r"^api/delete_budget/$", DeleteClubBudgetAPIView.as_view(), name="delete budget"
+ ),
+ url(
+ r"^api/upload_activitycalender/$",
+ UploadActivityCalendarAPIView.as_view(),
+ name="calender",
+ ),
+ url(r"^api/create_club/$", CreateClubAPIView.as_view(), name="new club"),
+ url(
+ r"^api/update_clubStatus/$",
+ UpdateClubStatusAPIView.as_view(),
+ name="update club status",
+ ),
+ url(
+ r"^api/updateClubName/$",
+ UpdateClubNameAPIView.as_view(),
+ name="update club name",
+ ),
+ url(r"^api/approve_event/$", ApproveEvent.as_view(), name="approve event"),
+ # add club api
+ url(r"^api/add_club/$", AddClubAPI.as_view(), name="add club"),
+ # new budget api
+ url(r"^api/new_budget/$", NewBudgetAPIView.as_view(), name="new budget"),
+ # fic approve budget api
+ url(
+ r"^api/fic_approve_budget/$",
+ FICApproveBudgetAPIView.as_view(),
+ name="fic approve budget",
+ ),
+ # counsellor approve budget api
+ url(
+ r"^api/counsellor_approve_budget/$",
+ CounsellorApproveBudgetAPIView.as_view(),
+ name="counsellor approve budget",
+ ),
+ # dean approve budget api
+ url(
+ r"^api/dean_approve_budget/$",
+ DeanApproveBudgetAPIView.as_view(),
+ name="dean approve budget",
+ ),
+ url(r'^api/dean_review_budget/$', DeanReviewBudgetAPIView.as_view(), name = 'review budget'),
+ # new event api
+ url(r"^api/new_events/$", NewEventAPIView.as_view(), name="new events"),
+ # fic approve event api
+ url(
+ r"^api/fic_approve_event/$",
+ FICApproveEventAPIView.as_view(),
+ name="fic approve event",
+ ),
+ # counsellor approve event api
+ url(
+ r"^api/counsellor_approve_event/$",
+ CounsellorApproveEventAPIView.as_view(),
+ name="counsellor approve event",
+ ),
+ # dean approve event api
+ url(
+ r"^api/dean_approve_event/$",
+ DeanApproveEventAPIView.as_view(),
+ name="dean approve event",
+ ),
+ url(
+ r"^api/add_achievement/$", AddAchievementAPIView.as_view(), name="approve event"
+ ),
+ url(
+ r"^api/show_achievement/$", AchievementsAPIView.as_view(), name="approve event"
+ ),
+ url(
+ r"^api/create_budget_comment/$",
+ CreateBudgetCommentAPIView.as_view(),
+ name="create budget comment",
+ ),
+ url(
+ r"^api/create_event_comment/$",
+ CreateEventCommentAPIView.as_view(),
+ name="create event comment",
+ ),
+ url(
+ r"^api/list_budget_comments/$",
+ ListBudgetCommentsAPIView.as_view(),
+ name="list budget comments",
+ ),
+ url(
+ r"^api/list_event_comments/$",
+ ListEventCommentsAPIView.as_view(),
+ name="list event comments",
+ ),
+ url(r"^api/modify_event/$", ModifyEventAPIView.as_view(), name="modify event"),
+ url(r"^api/modify_budget/$", ModifyBudgetAPIView.as_view(), name="modify budget"),
+ url(r"^api/reject_event/$", RejectEventAPIView.as_view(), name="reject event"),
+ url(r"^api/reject_budget/$", RejectBudgetAPIView.as_view(), name="reject budget"),
+ url(
+ r"^api/add_club_position/$",
+ AddClubPositionAPIView.as_view(),
+ name="add club position",
+ ),
+ url(
+ r"^api/list_club_position/$",
+ ListClubPositionAPIView.as_view(),
+ name="list club position",
+ ),
+ url(r"^api/new_event/$", UpdateEventAPIView.as_view(), name="update event"),
+ url(r"^api/update_event/$", UpdateEventAPIView.as_view(), name="update event"),
+ url(r"^api/update_budget/$", UpdateBudgetAPIView.as_view(), name="update budget"),
+ url(r"^fest/$" , FestListView.as_view(), name="fest"),
+ url(r'^api/new_fest/$', NewFestAPIView.as_view(), name='new_fest'),
+ url(r'^api/event_allocation/$', FreeMembersForClubAPIView.as_view(), name='event allocation'),
+ url(r'^api/coordinator_events/$', CoordinatorEventsAPIView.as_view(), name='coordinator_events'),
+ url(r'^api/coordinator_eventsinput/$', EventInputAPIView.as_view(), name='coordinator_eventsinput'),
+ url(r'^api/newsletter_pdf/$', NewsletterPDFAPIView.as_view(), name='newsletter_pdf'),
+ url(r'^api/event_report_list/$', EventReportListAPIView.as_view(), name='event_report_list'),
+ url(r'^api/add_event_report/$', EventReportAPIView.as_view(), name='add_event_report'),
+ url(r'^api/event_report_pdf/(?P\d+)/$', EventReportPDFView.as_view(), name='event_report_pdf'),
+ url(r'^api/update_budget/$', UpdateBudgetAPIView.as_view(), name='update event'),
]
diff --git a/FusionIIIT/applications/gymkhana/views.py b/FusionIIIT/applications/gymkhana/views.py
index 393d26986..259bdedd3 100644
--- a/FusionIIIT/applications/gymkhana/views.py
+++ b/FusionIIIT/applications/gymkhana/views.py
@@ -133,8 +133,7 @@ def editsession(request, session_id):
end_time = body.get("end_time")
desc = body.get("d_d")
club_name = coordinator_club(request)
- result = conflict_algorithm_session(
- date, start_time, end_time, venue)
+ result = conflict_algorithm_session(date, start_time, end_time, venue)
message = ""
if result == "success":
event = Session_info.objects.select_related(
@@ -288,8 +287,7 @@ def edit_event(request, event_id):
end_time = body.get("end_time")
desc = body.get("d_d")
club_name = coordinator_club(request)
- result = conflict_algorithm_event(
- date, start_time, end_time, venue)
+ result = conflict_algorithm_event(date, start_time, end_time, venue)
message = ""
if result == "success":
event = Event_info.objects.select_related(
@@ -316,7 +314,7 @@ def edit_event(request, event_id):
event.end_time = end_time
event.event_poster = event_poster
event.details = desc
- event.status = 'confirmed'
+ event.status = "confirmed"
event.save()
# e = Event_info.objects.filter(id=event_id).update(club = club_name, event_name=event_name, incharge=incharge, venue = venue, date =date, start_time=start_time , end_time = end_time ,event_poster = event_poster , details = desc)
message += "Your form has been dispatched for further process"
@@ -488,11 +486,7 @@ def studentsClubMembers(request):
print(club_filter)
try:
# students = ExtraInfo.objects.all().filter(user_type="student").filter(id__startswith=current_value)
- students = (
- Club_member.objects.select_related()
- .all()
- .filter(club=club_filter)
- )
+ students = Club_member.objects.select_related().all().filter(club=club_filter)
students = serializers.serialize("json", students)
return HttpResponse(students)
except Exception as e:
@@ -743,8 +737,7 @@ def registration_form(request):
try:
# getting form data
info = (
- Student.objects.select_related(
- "id", "id__user", "id__department")
+ Student.objects.select_related("id", "id__user", "id__department")
.get(id__user=request.user)
.cpi
)
@@ -920,11 +913,9 @@ def return_content(request, roll, name, desig, club__, student_clubs, notificati
)
try:
- form_name = Form_available.objects.get(
- roll=request.user.username).form_name
+ form_name = Form_available.objects.get(roll=request.user.username).form_name
logger.info(f"{form_name} MKNCjncknisncs")
- status = Form_available.objects.get(
- roll=request.user.username).status
+ status = Form_available.objects.get(roll=request.user.username).status
except Exception as e:
forms = Form_available.objects.all()
for form in forms:
@@ -1078,8 +1069,7 @@ def gymkhana(request):
roll = request.user
name = request.user.first_name + "_" + request.user.last_name
designations = list(
- HoldsDesignation.objects.select_related(
- "user", "working", "designation")
+ HoldsDesignation.objects.select_related("user", "working", "designation")
.all()
.filter(working=request.user)
.values_list("designation")
@@ -1114,7 +1104,9 @@ def gymkhana(request):
return render(
request,
"gymkhanaModule/gymkhana.html",
- return_content(request, roll, name, roll_, club__, student_clubs, notifications),
+ return_content(
+ request, roll, name, roll_, club__, student_clubs, notifications
+ ),
)
@@ -1169,45 +1161,45 @@ def club_membership(request):
# return redirect('/gymkhana/')
-@login_required
-def core_team(request):
- """
- core_team:
- This view takes the data of students. Data like, their name, fest name, team, pda and
- year. And finally saving this data to the database of the core team.
- This will done only when the method is POST and at the end it will redirect to '/gymkhana/'
- @params:
- request : trivial
- @variables:
- user : Name of the user
- fest : Name of the fest
- team : Name of the team
- achievements : Achievements of the user
- year : Acedamic year of the core team
-
- """
- if request.method == "POST":
- # getting form data
- user = request.POST.get("user_name")
- fest = request.POST.get("fest")
- team = request.POST.get("team")
- achievements = request.POST.get("pda")
- year = request.POST.get("year")
-
- # getting queryset class objects
- USER = user.split(" - ")
- user_name = get_object_or_404(User, username=USER[1])
- extra = get_object_or_404(ExtraInfo, id=USER[00], user=user_name)
- student = get_object_or_404(Student, id=extra)
+# @login_required
+# def core_team(request):
+# """
+# core_team:
+# This view takes the data of students. Data like, their name, fest name, team, pda and
+# year. And finally saving this data to the database of the core team.
+# This will done only when the method is POST and at the end it will redirect to '/gymkhana/'
+# @params:
+# request : trivial
+# @variables:
+# user : Name of the user
+# fest : Name of the fest
+# team : Name of the team
+# achievements : Achievements of the user
+# year : Acedamic year of the core team
- # saving data to the database
- core_team = Core_team(
- student_id=student, fest_name=fest, team=team, pda=achievements, year=year
- )
- core_team.save()
- messages.success(request, "Successfully applied for the post !!!")
+# """
+# if request.method == "POST":
+# # getting form data
+# user = request.POST.get("user_name")
+# fest = request.POST.get("fest")
+# team = request.POST.get("team")
+# achievements = request.POST.get("pda")
+# year = request.POST.get("year")
+
+# # getting queryset class objects
+# USER = user.split(" - ")
+# user_name = get_object_or_404(User, username=USER[1])
+# extra = get_object_or_404(ExtraInfo, id=USER[00], user=user_name)
+# student = get_object_or_404(Student, id=extra)
+
+# # saving data to the database
+# core_team = Core_team(
+# student_id=student, fest_name=fest, team=team, pda=achievements, year=year
+# )
+# core_team.save()
+# messages.success(request, "Successfully applied for the post !!!")
- return redirect("/gymkhana/")
+# return redirect("/gymkhana/")
@login_required
@@ -1391,44 +1383,73 @@ def club_report(request):
def change_head(request):
if request.method == "POST":
club = request.POST.get("club")
- co_ordinator = request.POST.get('co')
- co_coordinator = request.POST.get('coco')
+ co_ordinator = request.POST.get("co")
+ co_coordinator = request.POST.get("coco")
- desc = "co-ordinator and co co-ordinator changed on " + \
- str(timezone.now())
+ desc = "co-ordinator and co co-ordinator changed on " + str(timezone.now())
message = ""
club_info = Club_info.objects.get(club_name=club)
if co_ordinator:
check = Club_member.objects.filter(
- club_id=club, member_id=co_ordinator).exists()
+ club_id=club, member_id=co_ordinator
+ ).exists()
if check == False:
- return HttpResponse(json.dumps({'status': 'error', 'message': 'Selected student is not a member of the club'}))
+ return HttpResponse(
+ json.dumps(
+ {
+ "status": "error",
+ "message": "Selected student is not a member of the club",
+ }
+ )
+ )
co_ordinator_student = Student.objects.get(id_id=co_ordinator)
old_co_ordinator = club_info.co_ordinator_id
club_info.co_ordinator_id = co_ordinator_student
- new_co_ordinator = HoldsDesignation(user=User.objects.get(username=co_ordinator), working=User.objects.get(
- username=co_ordinator), designation=Designation.objects.get(name="co-ordinator"))
+ new_co_ordinator = HoldsDesignation(
+ user=User.objects.get(username=co_ordinator),
+ working=User.objects.get(username=co_ordinator),
+ designation=Designation.objects.get(name="co-ordinator"),
+ )
new_co_ordinator.save()
- old_co_ordinator_obj = HoldsDesignation.objects.select_related('user', 'working', 'designation').filter(
- user__username=old_co_ordinator, designation=Designation.objects.get(name="co-ordinator"))
+ old_co_ordinator_obj = HoldsDesignation.objects.select_related(
+ "user", "working", "designation"
+ ).filter(
+ user__username=old_co_ordinator,
+ designation=Designation.objects.get(name="co-ordinator"),
+ )
old_co_ordinator_obj.delete()
message += "Successfully changed co-ordinator !!!"
if co_coordinator:
check = Club_member.objects.filter(
- club_id=club, member_id=co_coordinator).exists()
+ club_id=club, member_id=co_coordinator
+ ).exists()
if check == False:
- return HttpResponse(json.dumps({'status': 'error', 'message': 'Selected student is not a member of the club'}))
+ return HttpResponse(
+ json.dumps(
+ {
+ "status": "error",
+ "message": "Selected student is not a member of the club",
+ }
+ )
+ )
co_coordinator_student = Student.objects.get(id_id=co_coordinator)
old_co_coordinator = club_info.co_coordinator_id
club_info.co_coordinator_id = co_coordinator_student
- new_co_coordinator = HoldsDesignation(user=User.objects.get(username=co_coordinator), working=User.objects.get(
- username=co_coordinator), designation=Designation.objects.get(name="co co-ordinator"))
+ new_co_coordinator = HoldsDesignation(
+ user=User.objects.get(username=co_coordinator),
+ working=User.objects.get(username=co_coordinator),
+ designation=Designation.objects.get(name="co co-ordinator"),
+ )
new_co_coordinator.save()
- old_co_coordinator_obj = HoldsDesignation.objects.select_related('user', 'working', 'designation').filter(
- user__username=old_co_coordinator, designation=Designation.objects.get(name="co co-ordinator"))
+ old_co_coordinator_obj = HoldsDesignation.objects.select_related(
+ "user", "working", "designation"
+ ).filter(
+ user__username=old_co_coordinator,
+ designation=Designation.objects.get(name="co co-ordinator"),
+ )
old_co_coordinator_obj.delete()
message += " Successfully changed co-coordinator !!!"
@@ -1436,8 +1457,8 @@ def change_head(request):
club_info.save()
content = {
- 'status': "success",
- 'message': message,
+ "status": "success",
+ "message": message,
}
content = json.dumps(content)
@@ -1480,8 +1501,7 @@ def new_session(request):
end_time = request.POST.get("end_time")
desc = request.POST.get("d_d")
club_name = coordinator_club(request)
- result = conflict_algorithm_session(
- date, start_time, end_time, venue)
+ result = conflict_algorithm_session(date, start_time, end_time, venue)
message = ""
getstudents = ExtraInfo.objects.select_related("user", "department").filter(
user_type="student"
@@ -1556,8 +1576,7 @@ def new_event(request):
end_time = request.POST.get("end_time")
desc = request.POST.get("d_d")
club_name = coordinator_club(request)
- result = conflict_algorithm_event(
- date, start_time, end_time, venue)
+ result = conflict_algorithm_event(date, start_time, end_time, venue)
message = ""
getstudents = ExtraInfo.objects.select_related("user", "department").filter(
user_type="student"
@@ -1690,15 +1709,13 @@ def club_approve(request):
club_info.created_on = timezone.now()
club_info.save()
- user_name1 = get_object_or_404(
- User, username=club_info.co_ordinator)
+ user_name1 = get_object_or_404(User, username=club_info.co_ordinator)
extra1 = get_object_or_404(
ExtraInfo, id=club_info.co_ordinator, user=user_name1
)
student1 = get_object_or_404(Student, id=extra1)
- user_name2 = get_object_or_404(
- User, username=club_info.co_coordinator)
+ user_name2 = get_object_or_404(User, username=club_info.co_coordinator)
extra2 = get_object_or_404(
ExtraInfo, id=club_info.co_coordinator, user=user_name2
)
@@ -1808,8 +1825,7 @@ def cancel(request):
extra1 = get_object_or_404(ExtraInfo, id=info[0], user=user_name)
student = get_object_or_404(Student, id=extra1)
- club_member = get_object_or_404(
- Club_member, club=user[1], member=student)
+ club_member = get_object_or_404(Club_member, club=user[1], member=student)
club_member.delete()
messages.success(request, "Successfully deleted !!!")
@@ -2136,7 +2152,8 @@ def budget_approve(request):
for club in first_words:
print(club)
club_budget_list = Club_budget.objects.filter(
- club_id=club, status="open") # Ensure status is open
+ club_id=club, status="open"
+ ) # Ensure status is open
print(club_budget)
for single_club in club_budget_list:
single_club.status = "confirmed"
@@ -2144,9 +2161,7 @@ def budget_approve(request):
# single_club.alloted_budget = single_club.alloted_budget + single_club.budget_amt
single_club.save()
# club_budget.save()
- messages.success(
- request, f"Successfully budget approved for club."
- )
+ messages.success(request, f"Successfully budget approved for club.")
return redirect("/gymkhana/")
@@ -2170,13 +2185,10 @@ def budget_reject(request):
for club in first_words:
print(club)
- club_budget = Club_budget.objects.get(
- club_id=club, status="open"
- )
+ club_budget = Club_budget.objects.get(club_id=club, status="open")
club_budget.status = "rejected"
club_budget.save()
- messages.success(
- request, f"Successfully budget rejected for club.")
+ messages.success(request, f"Successfully budget rejected for club.")
return redirect("/gymkhana/")
@@ -2545,6 +2557,7 @@ def del_club(request):
return redirect("/gymkhana/")
+
def approve_events(request):
selected_ids = request.POST.get("ids")
@@ -2559,7 +2572,12 @@ def approve_events(request):
event.status = "confirmed"
event.save()
except ObjectDoesNotExist:
- return JsonResponse({"status": "error", "message": f"Event with ID {event_id} does not exist"})
+ return JsonResponse(
+ {
+ "status": "error",
+ "message": f"Event with ID {event_id} does not exist",
+ }
+ )
return JsonResponse({"status": "success"})
except Exception as e:
@@ -2567,8 +2585,8 @@ def approve_events(request):
def update_club_name(request):
- club_id = request.POST.get('club_id')
- new_name = request.POST.get('new_name')
+ club_id = request.POST.get("club_id")
+ new_name = request.POST.get("new_name")
if club_id and new_name:
try:
@@ -2594,73 +2612,87 @@ def update_club_name(request):
status="open",
description=description,
activity_calender=activity_calender,
- category=category
-
-
+ category=category,
)
new_club.save()
- return JsonResponse({'status': 'success'})
+ return JsonResponse({"status": "success"})
except Club_info.DoesNotExist:
- return JsonResponse({'status': 'error', 'message': 'Club not found'})
-
-
-
+ return JsonResponse({"status": "error", "message": "Club not found"})
+
+
@csrf_exempt
def update_budget_amount(request):
print("inside function")
- if request.method == 'POST':
- budget_id = request.POST.get('budget_id')
- req_id=request.POST.get('req_id')
-
+ if request.method == "POST":
+ budget_id = request.POST.get("budget_id")
+ req_id = request.POST.get("req_id")
+
print(budget_id)
print(req_id)
# Fetch the budget object
-
+
budget = Club_budget.objects.get(id=budget_id)
- if req_id=="spent":
- new_budget = float(request.POST.get('new_budget')) # convert new_budget to float
+ if req_id == "spent":
+ new_budget = float(
+ request.POST.get("new_budget")
+ ) # convert new_budget to float
- # Fetch the budget object
+ # Fetch the budget object
budget = Club_budget.objects.get(id=budget_id)
- # Update the budget amount
+ # Update the budget amount
if new_budget > budget.budget_amt:
- return JsonResponse({'status': 'error', 'message': 'Spent amount cannot be greater than available amount!'})
+ return JsonResponse(
+ {
+ "status": "error",
+ "message": "Spent amount cannot be greater than available amount!",
+ }
+ )
budget.budget_amt = budget.budget_amt - new_budget
budget.save()
-
+
else:
- # Update the budget amount
- new_budget = request.POST.get('new_budget')
+ # Update the budget amount
+ new_budget = request.POST.get("new_budget")
budget.budget_amt = new_budget
budget.save()
- # Return a success response
- return JsonResponse({'status': 'success', 'message': 'Budget amount updated successfully'})
+ # Return a success response
+ return JsonResponse(
+ {"status": "success", "message": "Budget amount updated successfully"}
+ )
# Return an error response if not a POST request
- return JsonResponse({'status': 'error', 'message': 'Invalid request'})
-
+ return JsonResponse({"status": "error", "message": "Invalid request"})
@csrf_exempt
def update_spent_amount(request):
- if request.method == 'POST':
- budget_id = request.POST.get('budget_id')
- new_budget = float(request.POST.get('new_budget')) # convert new_budget to float
+ if request.method == "POST":
+ budget_id = request.POST.get("budget_id")
+ new_budget = float(
+ request.POST.get("new_budget")
+ ) # convert new_budget to float
# Fetch the budget object
budget = Club_budget.objects.get(id=budget_id)
# Update the budget amount
if new_budget > budget.budget_amt:
- return JsonResponse({'status': 'error', 'message': 'Spent amount cannot be greater than available amount!'})
+ return JsonResponse(
+ {
+ "status": "error",
+ "message": "Spent amount cannot be greater than available amount!",
+ }
+ )
budget.budget_amt = budget.budget_amt - new_budget
budget.save()
# Return a success response
- return redirect('/gymkhana/')
+ return redirect("/gymkhana/")
# Return an error response if not a POST request
- return JsonResponse({'status': 'error', 'message': 'Invalid request'})
\ No newline at end of file
+ return JsonResponse({"status": "error", "message": "Invalid request"})
+
+