Skip to content

Commit

Permalink
it was never same between us after that detailsForm
Browse files Browse the repository at this point in the history
  • Loading branch information
exploring-solver committed Oct 24, 2023
2 parents fa70a7f + 76bb231 commit 670eab8
Show file tree
Hide file tree
Showing 9 changed files with 535 additions and 67 deletions.
5 changes: 0 additions & 5 deletions backend/student/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,5 @@ class StudentDetailsSerializer(serializers.ModelSerializer):
class Meta:
model = StudentDetails
fields = '__all__'


# def update(self, instance, validated_data):
# print("update called")
# return super().update(instance, validated_data)


24 changes: 14 additions & 10 deletions backend/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ def msteams(self, request, *args, **kwargs):


class StudentDetailsView(APIView):
# only authenticated users can access this view

# only authenticated users can access this view
permission_classes = (IsAuthenticated,)

# For submitting personal details of student
def post(self, request):

student_instance = StudentDetails.objects.filter(enrollment_number=request.user.user_id).first()

# appending the enrollment_number to request data for saving
request.data._mutable = True
request.data['enrollment_number'] = request.user.user_id
Expand All @@ -175,15 +175,15 @@ def post(self, request):
# print(request.data)
# Serialize using StudentDetailsSerializer for validation and saving

if student_instance:
student = StudentDetails.objects.filter(enrollment_number=request.user.user_id).first()

if student:
# If the record exists, update it with the new data
student_serializer = StudentDetailsSerializer(student_instance, data=request.data)
student_serializer = StudentDetailsSerializer(student, data=request.data)
else:
# If the record doesn't exist, create a new record
student_serializer = StudentDetailsSerializer(data=request.data)

# print(student_serializer.errors)

if student_serializer.is_valid():
student_serializer.save()
return Response({'message': 'Details Submitted Successfully'}, status=status.HTTP_200_OK)
Expand All @@ -195,6 +195,10 @@ def post(self, request):
def get(self, request):

enrollment_number = request.user.user_id
serializer = StudentDetailsSerializer(StudentDetails.objects.get(enrollment_number=enrollment_number))
# print(serializer.data)
return Response(serializer.data, status=status.HTTP_200_OK)
student = StudentDetails.objects.filter(enrollment_number=enrollment_number).first()

if student:
serializer = StudentDetailsSerializer(student)
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response({'message': 'Student details not found'}, status=status.HTTP_204_NO_CONTENT)
48 changes: 48 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"private": true,
"dependencies": {
"@babel/traverse": ">=7.23.2",
"@heroicons/react": "^2.0.18",
"@tailwindcss/forms": "^0.5.6",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
54 changes: 25 additions & 29 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}
/* Tailwind.css or App.css */

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
.sidebar {
width: 0;
height: 100%;
position: fixed;
top: 0;
left: 0;
background-color: #333;
overflow-x: hidden;
transition: 0.3s;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
padding-top: 60px;
z-index: 1;
}

.sidebar.open {
width: 250px;
}

.App-link {
color: #61dafb;
.hamburger {
cursor: pointer;
margin-left: 15px;
margin-top: 15px;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
.line {
width: 30px;
height: 3px;
background-color: white;
margin: 6px 0;
}
Loading

0 comments on commit 670eab8

Please sign in to comment.