-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: PBI-Profil #4
Conversation
…be to accomodate TDD test phase
…represent Revelio users, set AUTH_USER_MODEL to Appuser in settngs.py and settings_dev.py, redo the migrations
…business logic in views.py without implementation and create one unit test.
…ing to change the authentication method
…ns for authentication. Change login functionality to accomodate JWT Tokens without failing the existing test.
…e requirements.txt, settings.py, and settings_dev.py to accomodate that feature.
…accomodate secrets for sending email. Adding tokens.py to create tokens for user email verification. Add templates for email that are sent to user during email verification process.
This commit introduces unit tests for the ProfileUpdateTest class, covering various scenarios including updating profile information with valid and empty data, uploading a profile picture, attempting to update profile with invalid data, and testing profile updates when unauthenticated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, the code are good. The models, views, and serializers are good. But i guess you didn't merge the staging branch to your branch before you made this request so some of my code were missing in tests.py. Please do that first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also try to git ignore the profile_pictures directory, because we don't need to save it on github (will use too much resource)
authentication/urls.py
Outdated
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), | ||
path('verify/', SendVerificationEmailView.as_view(), name='verify_email'), | ||
path('recover/', SendRecoverPasswordEmailView.as_view(), name='recover_password'), | ||
path('profile/update/', UpdateProfileView.as_view(), name='update_profile'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is to not use /update here. You can utilize ProfileView instead (change UpdateProfileView to ProfileView) to utilize the APIView from drf.
authentication/views.py
Outdated
class UpdateProfileView(APIView): | ||
permission_classes = [IsAuthenticated] | ||
def put(self, request): | ||
user = request.user | ||
profile = user.profile | ||
serializer = ProfileSerializer(instance=profile, data=request.data, partial=True) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response({'msg': 'Profile updated successfully!'}) | ||
else: | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the file to be ProfileView(APIView). Because u might want to get user profile so if that's the case, you will want to add get method on the class.
For example:
class ProfileView(APIView):
def get(self, request):
# Implement the get logic here.
def put(self, request):
user = request.user
profile = user.profile
serializer = ProfileSerializer(instance=profile, data=request.data, partial=True)
if serializer.is_valid():
serializer.save()
return Response({'msg': 'Profile updated successfully!'})
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
This will make your code more efficient. Overall great implementation, keep it up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
Looks good to me, very detail description too! |
Detailed description of changes
What's New
N / A
What's Updated
Added Update Profile Feature and Tests
New Package Added
N/A
Recommendations on how to test the changes
N / A
Checklist for developer
Link to related issue(s)
N / A
Screenshots or videos (before and after if appropriate)
Before
N / A
After
N / A