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: refactor Create Update user additional info to one api endpoint #101

Conversation

mtreacy002
Copy link
Member

Description

Refactor POST and PUT /user/additional_info to one api endpoint

Fixes #100

Type of Change:

  • Code

Code/Quality Assurance Only

  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

  • login as user who has no additional info record
  • send GET /user/personal_details request to get user id
  • send PUT /user/additional_info to create additional info data. See success response 201 Created if additional info instance is successfully created.

Screen Shot 2020-08-03 at 7 33 18 pm

  • Now update the details and resend PUT /user/additional_info. On success update, see response 200 OK.

Screen Shot 2020-08-03 at 7 34 33 pm

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas

Code/Quality Assurance Only

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@mtreacy002 mtreacy002 self-assigned this Aug 3, 2020
@mtreacy002 mtreacy002 added Category: Coding Changes to code base or refactored code that doesn't fix a bug. Program: GSOC Related to work completed during the Google Summer of Code Program. labels Aug 3, 2020
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers . I've refactor POST and PUT /user/additional_info. Now backend only has one endpoint (PUT /user/additional_info) that will do either Create or Update user additional info. Please review when you have time. Thanks

@mtreacy002
Copy link
Member Author

Note @anitab-org/bridgeintech-maintainers. I've just pushed a typo fix for mocking test patch on test create, now using requests.put patch instead of post

@mtreacy002 mtreacy002 force-pushed the issue100-refactor-post-put-additional-info branch 2 times, most recently from 803beb4 to eccb1ce Compare August 3, 2020 13:05
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers . I've just pushed the last change to this refactoring PRR (hopefully). Now Create personal background dao is removed as there's no need for this anymore.

@mtreacy002 mtreacy002 requested review from ramitsawhney27 and a team August 3, 2020 14:31
@mtreacy002 mtreacy002 force-pushed the issue100-refactor-post-put-additional-info branch from eccb1ce to 8f1e65e Compare August 5, 2020 03:46
Fix bug on testing

fix typo requests.put mock patch

Remove POST user/personal_background

Remove Create personal background dao

Refactor update method to reemove duplication

Rename user_extension instance
@mtreacy002 mtreacy002 force-pushed the issue100-refactor-post-put-additional-info branch from 8f1e65e to 98dced8 Compare August 5, 2020 03:52
return messages.ADDITIONAL_INFO_SUCCESSFULLY_UPDATED, HTTPStatus.OK
user_additional_info = UserExtensionModel.find_by_user_id(user_id)
if not user_additional_info:
user_additional_info = UserExtensionModel(user_id, timezone)

Choose a reason for hiding this comment

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

Sorry I didn't know if userextension is synonymous to user_additional_info. If it is then this also seems fine 👍

Copy link

@meenakshi-dhanani meenakshi-dhanani left a comment

Choose a reason for hiding this comment

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

Just did a code review seems fine.

Copy link

@foongminwong foongminwong left a comment

Choose a reason for hiding this comment

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

The changes made in this PR were tested locally. Following are the results:

  1. Code review - Done

  2. All possible responses were tested as below:

    • Test PR 101
      Screenshot/gif/url: This GIF is too big to upload. View here

      Expected Result: As a user, I should be able to update my additional information on BIT API.
      Actual Result: Same as expected.

  3. Tested JSON:

{
  "is_organization_rep": true,
  "timezone": "UTC-05:00/Eastern Standard Time",
  "phone": "777-777-7777",
  "mobile": "888-888-8888",
  "personal_website": "https://dd.com"
}

4. OS Version: Windows 10

@ramitsawhney27 ramitsawhney27 merged commit 0b214ac into anitab-org:develop Aug 10, 2020
@mtreacy002 mtreacy002 deleted the issue100-refactor-post-put-additional-info branch August 30, 2020 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Program: GSOC Related to work completed during the Google Summer of Code Program.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Refactor POST/PUT /user/personal_details
4 participants