-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate AliExpress functionality, update models, views, and settings
- Loading branch information
Robocoders
committed
Nov 24, 2024
1 parent
7ca841e
commit 3b3f58b
Showing
47 changed files
with
484 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Use an official Python runtime as the base image | ||
FROM python:3.9 | ||
|
||
# Set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the project files into the container | ||
COPY . /app/ | ||
|
||
# Install project dependencies | ||
RUN pip install --upgrade pip | ||
RUN pip install -r requirements.txt | ||
|
||
# Run the setup script | ||
RUN python setup.py | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8000 | ||
|
||
# Start the application | ||
CMD ["python", "dropship_project/manage.py", "runserver", "0.0.0.0:8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,54 @@ | ||
# Dropship V2 | ||
|
||
Dropship V2 is a Django-based e-commerce platform for dropshipping. It includes features for product management, user authentication, shopping cart functionality, order processing, and integration with various third-party services. | ||
Dropship V2 is an e-commerce application built with Django. | ||
|
||
## Key Features | ||
## Prerequisites | ||
|
||
1. User authentication and registration (including social auth and two-factor authentication) | ||
2. Product listing and management | ||
3. Shopping cart functionality | ||
4. Checkout process with payment integration | ||
5. Order management for administrators | ||
6. Inventory management with stock tracking | ||
7. Email notifications for order updates | ||
8. Responsive design using Bootstrap | ||
9. API with OAuth2 authentication | ||
- Docker | ||
- Docker Compose | ||
|
||
## Technology Stack | ||
## Getting Started | ||
|
||
- Backend: Django 5.1.3 | ||
- Database: PostgreSQL | ||
- Frontend: HTML, CSS (Bootstrap), JavaScript | ||
- Authentication: django-allauth 65.2.0, django-two-factor-auth | ||
- API: Django REST framework 3.15.2 | ||
- Security: django-axes 7.0.0 | ||
- OAuth2: django-oauth-toolkit 3.0.1 | ||
1. Clone the repository: | ||
``` | ||
git clone https://github.com/CrzyHAX91/dropshipv2.git | ||
cd dropshipv2 | ||
``` | ||
|
||
## Setup | ||
2. Run the start script: | ||
``` | ||
./start.sh | ||
``` | ||
|
||
1. Clone the repository | ||
2. Install dependencies: `pip install -r requirements.txt` | ||
3. Set up environment variables (see `.env.example`) | ||
4. Run migrations: `python manage.py migrate` | ||
5. Create a superuser: `python manage.py createsuperuser` | ||
6. Start the development server: `python manage.py runserver` | ||
3. Access the application at http://localhost:8000 | ||
|
||
## Contributing | ||
## Features | ||
|
||
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests. | ||
- Product catalog | ||
- Shopping cart | ||
- User authentication | ||
- Order management | ||
|
||
## License | ||
## Admin Access | ||
|
||
This project is licensed under the MIT License - see the LICENSE file for details. | ||
To access the admin panel: | ||
|
||
1. Go to http://localhost:8000/admin | ||
2. Login with the following credentials: | ||
- Username: admin | ||
- Password: adminpassword | ||
|
||
## Running Tests | ||
|
||
To run the tests, use the following command: | ||
``` | ||
docker-compose exec web python dropship_project/manage.py test | ||
``` | ||
|
||
## Stopping the Application | ||
|
||
To stop the application, run: | ||
``` | ||
docker-compose down | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: '3.8' | ||
|
||
services: | ||
web: | ||
build: . | ||
command: python dropship_project/manage.py runserver 0.0.0.0:8000 | ||
volumes: | ||
- .:/app | ||
ports: | ||
- "8000:8000" | ||
environment: | ||
- DEBUG=1 | ||
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] | ||
depends_on: | ||
- db | ||
|
||
db: | ||
image: postgres:13 | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data/ | ||
environment: | ||
- POSTGRES_DB=dropship_db | ||
- POSTGRES_USER=dropship_user | ||
- POSTGRES_PASSWORD=dropship_password | ||
|
||
volumes: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,21 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
from .models import CustomUser, Order, CartItem, Product | ||
from .models import CustomUser, Product, CartItem, Order | ||
|
||
class CustomUserAdmin(UserAdmin): | ||
model = CustomUser | ||
list_display = ['email', 'username', 'is_staff', 'is_active'] | ||
list_filter = ['is_staff', 'is_active'] | ||
fieldsets = UserAdmin.fieldsets + ( | ||
('Additional Info', {'fields': ('phone_number', 'address', 'date_of_birth')}), | ||
) | ||
add_fieldsets = UserAdmin.add_fieldsets + ( | ||
('Additional Info', {'fields': ('phone_number', 'address', 'date_of_birth')}), | ||
) | ||
@admin.register(CustomUser) | ||
class CustomUserAdmin(admin.ModelAdmin): | ||
list_display = ('username', 'email', 'phone_number') | ||
|
||
class OrderAdmin(admin.ModelAdmin): | ||
list_display = ['id', 'user', 'created_at', 'total_price'] | ||
list_filter = ['created_at'] | ||
@admin.register(Product) | ||
class ProductAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'cost_price', 'selling_price', 'stock') | ||
list_filter = ('stock',) | ||
|
||
@admin.register(CartItem) | ||
class CartItemAdmin(admin.ModelAdmin): | ||
list_display = ['user', 'product', 'quantity'] | ||
list_display = ('user', 'product', 'quantity') | ||
|
||
class ProductAdmin(admin.ModelAdmin): | ||
list_display = ['name', 'price', 'stock'] | ||
list_filter = ['price', 'stock'] | ||
|
||
admin.site.register(CustomUser, CustomUserAdmin) | ||
admin.site.register(Order, OrderAdmin) | ||
admin.site.register(CartItem, CartItemAdmin) | ||
admin.site.register(Product, ProductAdmin) | ||
@admin.register(Order) | ||
class OrderAdmin(admin.ModelAdmin): | ||
list_display = ('user', 'total_price', 'created_at', 'status') | ||
list_filter = ('status',) | ||
|
47 changes: 47 additions & 0 deletions
47
dropship_project/management/commands/add_sample_products.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from django.core.management.base import BaseCommand | ||
from dropship_project.models import Product | ||
from django.core.files import File | ||
from django.conf import settings | ||
import os | ||
|
||
class Command(BaseCommand): | ||
help = 'Adds sample products to the database' | ||
|
||
def handle(self, *args, **kwargs): | ||
products = [ | ||
{ | ||
'name': 'Laptop', | ||
'description': 'High-performance laptop with 16GB RAM and 512GB SSD', | ||
'price': 999.99, | ||
'stock': 50, | ||
'image': 'laptop.jpg' | ||
}, | ||
{ | ||
'name': 'Smartphone', | ||
'description': '5G-enabled smartphone with 128GB storage', | ||
'price': 699.99, | ||
'stock': 100, | ||
'image': 'smartphone.jpg' | ||
}, | ||
{ | ||
'name': 'Wireless Headphones', | ||
'description': 'Noise-cancelling wireless headphones with 30-hour battery life', | ||
'price': 199.99, | ||
'stock': 200, | ||
'image': 'headphones.jpg' | ||
} | ||
] | ||
|
||
for product_data in products: | ||
product = Product.objects.create( | ||
name=product_data['name'], | ||
description=product_data['description'], | ||
price=product_data['price'], | ||
stock=product_data['stock'] | ||
) | ||
image_path = os.path.join(settings.BASE_DIR, 'sample_images', product_data['image']) | ||
if os.path.exists(image_path): | ||
with open(image_path, 'rb') as f: | ||
product.image.save(product_data['image'], File(f), save=True) | ||
self.stdout.write(self.style.SUCCESS(f'Successfully added product: {product.name}')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from django.core.management.base import BaseCommand | ||
from django.contrib.auth import get_user_model | ||
from dropship_project.models import Product, Order, CartItem | ||
import random | ||
|
||
User = get_user_model() | ||
|
||
class Command(BaseCommand): | ||
help = 'Populate the database with sample data' | ||
|
||
def handle(self, *args, **kwargs): | ||
self.stdout.write('Populating database...') | ||
|
||
# Create users | ||
for i in range(5): | ||
username = f'user{i}' | ||
email = f'user{i}@example.com' | ||
password = 'password123' | ||
User.objects.create_user(username=username, email=email, password=password) | ||
|
||
# Create products | ||
products = [ | ||
{'name': 'Laptop', 'description': 'High-performance laptop', 'price': 999.99, 'stock': 50}, | ||
{'name': 'Smartphone', 'description': '5G-enabled smartphone', 'price': 699.99, 'stock': 100}, | ||
{'name': 'Headphones', 'description': 'Noise-cancelling headphones', 'price': 199.99, 'stock': 200}, | ||
{'name': 'Tablet', 'description': '10-inch tablet', 'price': 299.99, 'stock': 75}, | ||
{'name': 'Smartwatch', 'description': 'Fitness tracking smartwatch', 'price': 149.99, 'stock': 150}, | ||
] | ||
for product in products: | ||
Product.objects.create(**product) | ||
|
||
# Create orders and cart items | ||
users = User.objects.all() | ||
products = Product.objects.all() | ||
|
||
for user in users: | ||
# Create an order | ||
order = Order.objects.create(user=user, total_price=0) | ||
total_price = 0 | ||
|
||
# Add random products to the order | ||
for _ in range(random.randint(1, 3)): | ||
product = random.choice(products) | ||
quantity = random.randint(1, 3) | ||
CartItem.objects.create(user=user, product=product, quantity=quantity, order=order) | ||
total_price += product.price * quantity | ||
|
||
order.total_price = total_price | ||
order.save() | ||
|
||
# Add random products to the cart | ||
for _ in range(random.randint(0, 2)): | ||
product = random.choice(products) | ||
quantity = random.randint(1, 2) | ||
CartItem.objects.create(user=user, product=product, quantity=quantity) | ||
|
||
self.stdout.write(self.style.SUCCESS('Database populated successfully!')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.