Repository navigation
Expand file tree
/
Copy pathseed.py
More file actions
72 lines (61 loc) · 2.6 KB
/
Copy pathseed.py
File metadata and controls
72 lines (61 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
سكريبت لإنشاء البيانات الأولية
"""
from app.models.setting import Setting
from app.models.category import Category
from app.models.user import User
from app import create_app, db
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def create_initial_data():
"""إنشاء البيانات الأولية"""
app = create_app()
with app.app_context():
# التحقق من وجود مستخدم admin
admin = User.query.filter_by(username='admin').first()
if not admin:
admin = User(
username='admin',
full_name='مدير النظام',
email='admin@taqsit.local',
phone='01000000000',
role='admin',
is_active=True
)
admin.set_password('admin123')
db.session.add(admin)
print('✓ تم إنشاء المستخدم الإداري (admin / admin123)')
else:
print('○ المستخدم الإداري موجود بالفعل')
# إنشاء تصنيفات افتراضية
default_categories = [
{'name': 'أجهزة كهربائية', 'icon': 'electrical_services', 'color': '#1e88e5'},
{'name': 'موبايلات', 'icon': 'phone_iphone', 'color': '#10b981'},
{'name': 'أثاث منزلي', 'icon': 'chair', 'color': '#f59e0b'},
{'name': 'إلكترونيات', 'icon': 'devices', 'color': '#ef4444'},
]
for cat_data in default_categories:
if not Category.query.filter_by(name=cat_data['name']).first():
cat = Category(**cat_data)
db.session.add(cat)
print(f'✓ تم إنشاء التصنيف: {cat_data["name"]}')
# إعدادات افتراضية
default_settings = [
('store_name', 'نظام تقسيط'),
('store_phone', '01000000000'),
('store_address', 'مصر'),
('currency', 'ج.م'),
('default_installment_months', '12'),
('late_fee_percentage', '0'),
]
for key, value in default_settings:
Setting.set(key, value)
print('✓ تم تحديث الإعدادات الافتراضية')
db.session.commit()
print('\n✅ تم إنشاء البيانات الأولية بنجاح!')
print('\n📋 بيانات الدخول:')
print(' اسم المستخدم: admin')
print(' كلمة المرور: admin123')
if __name__ == '__main__':
create_initial_data()