igorsimb / mp-monitor

Django app for scraping Wildberries
1 stars 0 forks source link

feature: create Demo functionality #130

Closed igorsimb closed 4 months ago

igorsimb commented 4 months ago

Fixes https://github.com/igorsimb/mp-monitor/issues/52

coderabbitai[bot] commented 4 months ago

[!WARNING]

Review failed

The pull request is closed.

Walkthrough

The update introduces several enhancements and new features to the project. The backend has been upgraded to Django 5.0, and Alpine.js has been added to the frontend stack. A new demo functionality allows users to create demo accounts with specific quotas and restrictions. Additionally, admin and user management features have been expanded, including new fields and models for user quotas and demo user management. Various templates and views have been updated to support these changes.

Changes

Files/Paths Change Summaries
README.md Updated to reflect the backend upgrade to Django 5.0 and the addition of Alpine.js to the frontend stack.
accounts/admin.py Added UserQuota model, QuotaInline class, new fields, filters, and methods in CustomUserAdmin.
accounts/migrations/0001_initial.py Added new fields created_at, is_demo_user, and is_demo_active with default values.
accounts/migrations/0002_initial.py Reordered dependencies in the Migration class.
accounts/migrations/0003_userquota.py Created UserQuota model with fields for tracking user quotas.
accounts/migrations/0004_rename_number_of_skus_userquota_max_skus.py Renamed field number_of_skus to max_skus in userquota model.
accounts/migrations/0005_alter_customuser_options.py Changed model options for CustomUser for better readability in the admin interface.
accounts/migrations/0006_alter_userquota_options_and_more.py Altered model options and renamed field max_skus to max_allowed_skus in userquota model.
accounts/models.py Introduced new fields and properties to CustomUser, created UserQuota model, and updated Meta class.
accounts/templates/.../demo_error.html Added error page for failed demo creation.
accounts/views.py Updated logout_view, added demo_view, and check_expired_demo_users functions.
config.py Introduced configuration settings for the project, including demo user settings and Shepherd.js configuration.
main/exceptions.py Introduced QuotaExceededException class to handle quota-related exceptions.
main/migrations/0001_initial.py Updated Django version, reordered imports, added fields to HistoricalTenant, and created new Tenant model.
main/migrations/0002_alter_historicaltenant_status_alter_tenant_status.py Changed status field in historicaltenant and tenant models to use integer field with predefined choices.
main/models.py Changed default value for status field in Status class from TRIALING to ACTIVE.
main/tasks.py Added QuotaExceededException import, new function for updating user quotas, and task for demo user deactivation.
main/templates/.../base.html Added script tags for "Collapse Plugin" and "Shepherd.js", updated navigation links.
main/templates/.../index.html Added CSS class slide-transition to main element.
main/templates/.../item_detail.html Added conditional blocks for demo-related information and accessibility improvements to pagination.
main/templates/.../item_list.html Added offcanvas panel for demo users, displayed user statistics, and adjusted visual elements.
main/templates/.../partials/add_items_form.html Introduced form for adding new items with conditional rendering based on user type and quota limits.
main/templates/.../partials/create_interval_form.html Added logic to disable submit button and display message when quota is reached.
main/templates/.../partials/demo_user_quota.html Introduced offcanvas display for demo user quotas with registration link.
main/templates/.../partials/homepage/hero_section.html Updated hero section with new button for demo feature and layout adjustments.
main/views.py Added new imports, demo user functionality, updated user quotas, and handled quota-related exceptions.
mp_monitor/celery.py Added periodic task for checking and deactivating expired demo users.
mp_monitor/settings.py Added CELERY_TIMEZONE setting with value "Europe/Moscow".
mp_monitor/urls.py Added demo_view and check_expired_demo_users to imports and urlpatterns.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant System
    participant Admin
    participant Scheduler

    User->>System: Request demo account
    System->>System: Create demo user
    System->>System: Set quotas and restrictions
    System->>User: Provide access to demo account
    Scheduler->>System: Check for expired demo users
    System->>System: Deactivate expired demo users
    Admin->>System: Manage user quotas
    User->>System: Use demo account features
    System->>User: Enforce quotas and restrictions

Assessment against linked issues

Objective (Issue #52) Addressed Explanation
Create Demo functionality
Demo user is created for demo session duration
TaskForm for the user (max 10-50 SKUs)
ScrapeIntervalForm for the user
Demo user is deleted after demo session
Demo user is deleted every 24 hours

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` 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. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### 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 an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@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. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - 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/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.