Skip to content

Commit

Permalink
Merge remote master branch with local changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Robocoders committed Nov 22, 2024
2 parents e8d9dae + 17adcfa commit 17c8b66
Show file tree
Hide file tree
Showing 82 changed files with 1,484 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .bash_logout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
11 changes: 11 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export PATH=/opendevin/plugins/agent_skills:$PATH
export PYTHONPATH=/opendevin/plugins/agent_skills:$PYTHONPATH
export PATH=$PATH:/opendevin/plugins/jupyter
export PATH=$PATH:/user/.local/bin
export OPENDEVIN_PYTHON_INTERPRETER=/usr/bin/python3
export JUPYTER_GATEWAY_PID=766
export JUPYTER_GATEWAY_KERNEL_ID=default
export JUPYTER_EXEC_SERVER_PORT=30000
export JUPYTER_EXEC_SERVER_PID=775
export JUPYTER_BASH_EXEC_SERVER_PORT=30001
export JUPYTER_EXEC_BASH_SERVER_PID=784
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .cache/pylint/user.admin_1.stats
Binary file not shown.
Binary file added .cache/pylint/user.email_utils_1.stats
Binary file not shown.
Binary file added .cache/pylint/user.forms_1.stats
Binary file not shown.
Binary file added .cache/pylint/user.models_1.stats
Binary file not shown.
Binary file added .cache/pylint/user.settings_1.stats
Binary file not shown.
Binary file added .cache/pylint/user.urls_1.stats
Binary file not shown.
Binary file added .cache/pylint/user.views_1.stats
Binary file not shown.
5 changes: 5 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[user]
name = \"Robocoders\"
email = [email protected]
[safe]
directory = /home/user
Binary file added .ipython/profile_default/history.sqlite
Binary file not shown.
11 changes: 11 additions & 0 deletions .ipython/profile_default/startup/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This is the IPython startup directory

.py and .ipy files in this directory will be run *prior* to any code or files specified
via the exec_lines or exec_files configurables whenever you load this profile.

Files will be run in lexicographical order, so you can control the execution order of files
with a prefix, e.g.::

00-first.py
50-middle.py
99-last.ipy
1 change: 1 addition & 0 deletions .local/share/jupyter/runtime/jupyter_cookie_secret
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CJaJ76O3TO9lzTO/dzkwwzRkjalSthbl6pHN1qnDpbg=
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"shell_port": 50997,
"iopub_port": 35183,
"stdin_port": 40405,
"control_port": 54361,
"hb_port": 34203,
"ip": "127.0.0.1",
"key": "1102c097-ea50e80b67eb66f8766167a5",
"transport": "tcp",
"signature_scheme": "hmac-sha256",
"kernel_name": "python3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"shell_port": 35111,
"iopub_port": 41313,
"stdin_port": 45255,
"control_port": 50757,
"hb_port": 40857,
"ip": "127.0.0.1",
"key": "237b483c-c0a9d3fd2ca71e8fd5616fbf",
"transport": "tcp",
"signature_scheme": "hmac-sha256",
"kernel_name": "bash"
}
27 changes: 27 additions & 0 deletions .profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
Empty file added .sudo_as_admin_successful
Empty file.
39 changes: 39 additions & 0 deletions 0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 5.1.3 on 2024-11-19 16:19

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Product',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('description', models.TextField()),
('price', models.DecimalField(decimal_places=2, max_digits=10)),
('aliexpress_url', models.URLField()),
],
),
migrations.CreateModel(
name='Order',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.IntegerField(default=1)),
('total_price', models.DecimalField(decimal_places=2, max_digits=10)),
('created_at', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(default='pending', max_length=20)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.product')),
],
),
]
Empty file added __init__ (1).py
Empty file.
Empty file added __init__.py
Empty file.
42 changes: 42 additions & 0 deletions admin (1).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

from django.contrib import admin
from .models import Category, Product, Order, CartItem

@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
list_display = ('name', 'slug')
prepopulated_fields = {'slug': ('name',)}

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ('name', 'category', 'cost_price', 'selling_price', 'stock')
list_filter = ('category', 'name')
search_fields = ('name', 'description')

@admin.register(CartItem)
class CartItemAdmin(admin.ModelAdmin):
list_display = ('user', 'product', 'quantity', 'total_price')
list_filter = ('user', 'product')

@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
list_display = ('id', 'user', 'total_price', 'created_at', 'status', 'is_paid')
list_filter = ('status', 'created_at')
search_fields = ('user__username', 'id')
actions = ['mark_as_processing', 'mark_as_shipped', 'mark_as_delivered']

def is_paid(self, obj):
return obj.is_paid
is_paid.boolean = True

def mark_as_processing(self, request, queryset):
queryset.update(status='processing')
mark_as_processing.short_description = "Mark selected orders as processing"

def mark_as_shipped(self, request, queryset):
queryset.update(status='shipped')
mark_as_shipped.short_description = "Mark selected orders as shipped"

def mark_as_delivered(self, request, queryset):
queryset.update(status='delivered')
mark_as_delivered.short_description = "Mark selected orders as delivered"
47 changes: 47 additions & 0 deletions admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

import csv
from django.contrib import admin
from django.http import HttpResponse
from .models import Category, Product, Order, CartItem

class CartItemInline(admin.TabularInline):
model = CartItem
extra = 0

@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
list_display = ('name', 'slug')
prepopulated_fields = {'slug': ('name',)}

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ('name', 'category', 'cost_price', 'selling_price', 'profit_margin')
list_filter = ('category', 'name')
search_fields = ('name', 'description')

@admin.register(CartItem)
class CartItemAdmin(admin.ModelAdmin):
list_display = ('user', 'product', 'quantity', 'total_price')
list_filter = ('user', 'product')

@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
list_display = ('user', 'total_price', 'created_at', 'status', 'is_paid')
list_filter = ('status', 'created_at')
search_fields = ('user__username',)
inlines = [CartItemInline]
actions = ['export_to_csv']

def is_paid(self, obj):
return obj.is_paid
is_paid.boolean = True

def export_to_csv(self, request, queryset):
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="orders.csv"'
writer = csv.writer(response)
writer.writerow(['Order ID', 'User', 'Total Price', 'Created At', 'Status', 'Is Paid'])
for order in queryset:
writer.writerow([order.id, order.user.username, order.total_price, order.created_at, order.status, order.is_paid])
return response
export_to_csv.short_description = "Export selected orders to CSV"
60 changes: 60 additions & 0 deletions aliexpress_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

import os
from aliexpress_api import AliexpressApi, AliexpressCategory
from .models import Product

# Replace these with your actual AliExpress API credentials
APP_KEY = os.environ.get('ALIEXPRESS_APP_KEY')
APP_SECRET = os.environ.get('ALIEXPRESS_APP_SECRET')

api = AliexpressApi(APP_KEY, APP_SECRET)

def sync_products():
# Fetch products from AliExpress API
products = api.get_product_list(
fields="productId,productTitle,productUrl,imageUrl,salePrice",
keywords="dropshipping",
page_size=20
)

for product in products:
# Check if the product already exists in our database
existing_product = Product.objects.filter(aliexpress_url=product['productUrl']).first()

if existing_product:
# Update existing product
existing_product.name = product['productTitle']
existing_product.selling_price = float(product['salePrice']['amount'])
existing_product.save()
else:
# Create new product
new_product = Product(
name=product['productTitle'],
description=f"AliExpress Product ID: {product['productId']}",
cost_price=float(product['salePrice']['amount']),
selling_price=float(product['salePrice']['amount']) * 1.5, # 50% markup
aliexpress_url=product['productUrl']
)
new_product.save()

def place_order(order):
# This is a simplified example. In a real-world scenario, you'd need to handle
# shipping addresses, payment confirmation, etc.
for item in order.items.all():
product = item.product
quantity = item.quantity

# Place order on AliExpress
aliexpress_order = api.create_order(
product_id=product.aliexpress_url.split('/')[-1], # Assuming the product ID is the last part of the URL
quantity=quantity,
shipping_address={
# Add shipping address details here
}
)

if aliexpress_order:
order.status = 'processing'
order.save()
return True
return False
39 changes: 39 additions & 0 deletions analytics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

from django.db.models import Sum, Count
from django.utils import timezone
from datetime import timedelta
from .models import Order, Product

def get_sales_report(days=30):
end_date = timezone.now()
start_date = end_date - timedelta(days=days)

orders = Order.objects.filter(created_at__range=[start_date, end_date], status='paid')

total_sales = orders.aggregate(total=Sum('total_price'))['total'] or 0
order_count = orders.count()

top_products = Product.objects.filter(order__in=orders).annotate(
total_sales=Sum('order__total_price'),
quantity_sold=Count('order')
).order_by('-total_sales')[:5]

return {
'total_sales': total_sales,
'order_count': order_count,
'top_products': top_products,
'start_date': start_date,
'end_date': end_date
}

def get_inventory_report():
products = Product.objects.annotate(
total_sales=Sum('order__total_price'),
quantity_sold=Count('order')
).order_by('-quantity_sold')

return {
'products': products,
'total_products': products.count(),
'total_inventory_value': sum(product.cost_price * product.quantity for product in products)
}
23 changes: 23 additions & 0 deletions backup_database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Set variables
BACKUP_DIR="/path/to/backup/directory"
TIMESTAMP=20241120_122731
BACKUP_FILE="${BACKUP_DIR}/db_backup_${TIMESTAMP}.sql"

# Ensure backup directory exists
mkdir -p $BACKUP_DIR

# Perform database backup
python manage.py dumpdata > $BACKUP_FILE

# Compress the backup file
gzip $BACKUP_FILE

echo "Database backup completed: ${BACKUP_FILE}.gz"

# Optional: Upload to a secure off-site location (e.g., AWS S3)
# aws s3 cp ${BACKUP_FILE}.gz s3://your-bucket-name/backups/

# Remove backups older than 30 days
find $BACKUP_DIR -name "db_backup_*.sql.gz" -mtime +30 -delete
Loading

0 comments on commit 17c8b66

Please sign in to comment.