shanirub / ecommerce

ecommerce project
0 stars 0 forks source link

Add permissions #28

Open shanirub opened 5 days ago

shanirub commented 5 days ago

Phase 1: Basic Permissions Setup

Phase 2: Fine-Grained Control

Phase 3: Refine and Optimize

shanirub commented 5 days ago

Research and plan draft

  1. Customers

    Permissions: Can create, update, and delete their own orders and order items. Can only read products. Approach: You can assign customer users to a "Customer" group and apply these permissions via the views and models related to orders and products.

  2. Staff

    Permissions: Can create, update, and delete customer users. Can read orders and order items but cannot modify them. Full access (CRUD) to products and categories. Approach: Staff members will be part of a "Staff" group. Permissions can be managed using Django’s model-level permissions and some view-level logic for restricting order modifications.

  3. Admin

    Permissions: Full CRUD for users, orders, products, and categories. Primarily used to manage staff users. Approach: Admins can be in the "Admin" group with the highest level of access.

  4. Stock Personnel

    Permissions: Can only update product prices and quantities, without touching other fields. Approach: You can add a custom group "Stock Personnel" and restrict access to specific product fields using forms and model-level restrictions.

  5. Shift Manager

    Permissions: Combination of staff and customer permissions—full access to products and users, plus the ability to manage orders. Approach: The "Shift Manager" group would combine the permissions of both "Customer" and "Staff" groups.

shanirub commented 5 days ago
groups customers_group staff_group stock_personnel_group shift_manager_group
models
Product create v v
read v v v v
update v v v
delete v v
Category create v v
read v v v v
update v v
delete v v
Order create v v
read v v v
update v v
delete v v
OrderItem create v v
read v v v
update v v
delete v v
User create v
read v
update v
delete v