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

Business central auth fixed #61

Merged
merged 2 commits into from
Jan 2, 2024
Merged

Conversation

ruuushhh
Copy link
Contributor

@ruuushhh ruuushhh commented Jan 2, 2024

Summary by CodeRabbit

  • Refactor
    • Simplified the process for connecting Business Central accounts.
  • Chores
    • Removed unused code and imports to improve maintainability.

@ruuushhh ruuushhh self-assigned this Jan 2, 2024
Copy link

coderabbitai bot commented Jan 2, 2024

Walkthrough

The recent updates reflect a restructuring in the management of Business Central credentials within a workspace application. The process for connecting to Business Central has been simplified, with some of the logic being shifted away from serializers to views, indicating a possible move towards a more view-centric approach for handling credentials.

Changes

File Path Change Summary
apps/workspaces/helpers.py
apps/workspaces/serializers.py
apps/workspaces/views.py
Removal of imports; modifications to credential retrieval and creation; simplification of connect_business_central function. Shift in logic related to creating Business Central credentials.
apps/business_central/helpers.py
apps/business_central/serializers.py
apps/business_central/urls.py
apps/business_central/utils.py
apps/business_central/views.py
Adjustments to imports; addition of new view class CompanySelectionView; modifications to various functions and methods related to Business Central integration.
tests/test_business_central/test_views.py
tests/test_mappings/test_imports/test_modules/test_expense_custom_fields.py
Addition of new test function; removal of a print statement in a test file.

🐇✨🌟
To the code that changes, we hop and cheer,
For cleaner paths and logic clear.
In views and helpers, we now confide,
With every commit, a smoother ride. 🚀
🌟✨🐇

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

github-actions bot commented Jan 2, 2024

Tests Skipped Failures Errors Time
47 0 💤 0 ❌ 0 🔥 4.218s ⏱️

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b965983 and ee85c74.
Files selected for processing (3)
  • apps/workspaces/helpers.py (3 hunks)
  • apps/workspaces/serializers.py (2 hunks)
  • apps/workspaces/views.py (2 hunks)
Additional comments: 5
apps/workspaces/views.py (3)
  • 8-8: The import of connect_business_central is correctly placed and follows the Python convention of grouping third-party imports separately from local application imports.

  • 81-95: The post method implementation correctly uses the connect_business_central function to create Business Central credentials and returns a serialized response. Ensure that the authorization_code and redirect_uri are validated before use to prevent security issues.

  • 97-98: The get_queryset method is implemented correctly, returning all instances of BusinessCentralCredentials. This is a standard Django ORM practice for views that require a queryset.

apps/workspaces/helpers.py (1)
  • 88-93: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [88-102]

The connect_business_central function has been refactored to remove the dependency on Workspace attributes. Ensure that the removal of this logic does not affect other parts of the application that may rely on these attributes. The function correctly handles the creation or update of BusinessCentralCredentials.

apps/workspaces/serializers.py (1)
  • 84-86: The create method has been removed from the BusinessCentralCredentialsSerializer class. This change implies that the creation logic has been moved elsewhere, likely to the ConnectBusinessCentralView class. Verify that this change aligns with the application's design and that the credential creation process is still secure and functional.

Copy link

github-actions bot commented Jan 2, 2024

Tests Skipped Failures Errors Time
47 0 💤 0 ❌ 0 🔥 4.189s ⏱️

@codecov-commenter
Copy link

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (b965983) 90.29% compared to head (ee85c74) 90.91%.

Files Patch % Lines
apps/workspaces/views.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #61      +/-   ##
==========================================
+ Coverage   90.29%   90.91%   +0.61%     
==========================================
  Files          51       51              
  Lines        2504     2487      -17     
==========================================
  Hits         2261     2261              
+ Misses        243      226      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ruuushhh ruuushhh requested a review from ashwin1111 January 2, 2024 03:54
* Company Selection API

* test case fixed

* moved to business central
Copy link

github-actions bot commented Jan 2, 2024

Tests Skipped Failures Errors Time
48 0 💤 0 ❌ 0 🔥 4.338s ⏱️

@ruuushhh ruuushhh merged commit 9d2d9bc into master Jan 2, 2024
1 check passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ee85c74 and 8bcf894.
Files selected for processing (7)
  • apps/business_central/helpers.py (2 hunks)
  • apps/business_central/serializers.py (1 hunks)
  • apps/business_central/urls.py (2 hunks)
  • apps/business_central/utils.py (2 hunks)
  • apps/business_central/views.py (2 hunks)
  • tests/test_business_central/test_views.py (1 hunks)
  • tests/test_mappings/test_imports/test_modules/test_expense_custom_fields.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/test_mappings/test_imports/test_modules/test_expense_custom_fields.py
Additional comments: 10
apps/business_central/urls.py (2)
  • 3-3: The import statement has been updated to include CompanySelectionView. Ensure that this view is indeed used within this file and that the import is necessary.

  • 12-12: The new URL path for CompanySelectionView is correctly added with the name company-selection. Ensure that this naming convention is consistent with the rest of the application.

apps/business_central/views.py (2)
  • 3-7: The import statements have been updated to include BusinessCentralFieldSerializer, CompanySelectionSerializer, and ImportBusinessCentralAttributesSerializer. Confirm that these serializers are used within this file.

  • 28-32: The CompanySelectionView class has been added with a serializer_class attribute set to CompanySelectionSerializer. Ensure that the CompanySelectionSerializer is defined and that it contains the necessary logic for this view to function correctly.

tests/test_business_central/test_views.py (1)
  • 45-64: The new test function test_post_company_selection is added to test the POST request for company selection. Verify that the test covers all necessary scenarios and that the assertions are appropriate for the expected outcomes. Additionally, ensure that the test function name and docstring accurately describe its purpose.
apps/business_central/helpers.py (2)
  • 7-7: The import order in helpers.py has been modified. Confirm that this new order follows the project's conventions and that there are no circular dependencies introduced.

  • 51-51: The 'companies' dimension has been added to the dimensions list in the sync_dimensions function. Ensure that this addition is consistent with the intended behavior of the function and that the necessary logic to handle this new dimension is in place.

apps/business_central/serializers.py (1)
  • 98-121: The CompanySelectionSerializer class has been added with a Meta inner class and a create method. Ensure that the Meta class correctly specifies the model and fields, and that the create method contains the appropriate logic for updating Workspace attributes based on the request data and context.
apps/business_central/utils.py (2)
  • 64-71: The logic in the _sync_data method has been modified to include 'COMPANY' in the attribute_type parameter check and to handle the display_name parameter using the 'displayName' field if available. Confirm that this logic is correct and that it aligns with the data structure of the items being synchronized.

  • 84-86: The sync_companies method now passes an empty list as the field_names parameter to the _sync_data method. Ensure that this is the intended behavior and that it does not negatively impact the synchronization process.

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.

3 participants