Skip to content
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

Merged
merged 38 commits into from
Feb 25, 2024
Merged

feat: PBI-Profil #4

merged 38 commits into from
Feb 25, 2024

Conversation

carlenee
Copy link
Contributor

@carlenee carlenee commented Feb 25, 2024

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

  • The code builds clean without any errors or warnings
  • The code does not contain commented out code
  • The code does not log anything to console
  • I have added unit test(s) to cover new code and successfully executed ran it
  • I have thoroughly tested the new code and any adjacent features it may affect

Link to related issue(s)
N / A

Screenshots or videos (before and after if appropriate)
Before
N / A

After
N / A

JohannesSetiawan and others added 30 commits February 22, 2024 17:08
…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.
…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.
Copy link
Contributor

@JohannesSetiawan JohannesSetiawan left a 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.

authentication/tests.py Outdated Show resolved Hide resolved
Copy link
Member

@emiriko emiriko left a 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)

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'),
Copy link
Member

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.

Comment on lines 131 to 141
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)
Copy link
Member

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!

Copy link
Member

@emiriko emiriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@carlenee carlenee merged commit 4d8dc76 into staging Feb 25, 2024
3 checks passed
@swastikanata
Copy link
Contributor

Looks good to me, very detail description too!

catherineeangel added a commit that referenced this pull request May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants