hisham-cmd commited on
Commit
bf166e2
·
verified ·
1 Parent(s): 1f0f9fa

Delete scripts with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/init_home_sections.py +0 -81
scripts/init_home_sections.py DELETED
@@ -1,81 +0,0 @@
1
- import os
2
- import sys
3
-
4
- # Add backend to path
5
- sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
6
-
7
- from app.db.base import SessionLocal, engine, Base
8
- from app.models.home import HomeSection
9
-
10
- def init_home_sections():
11
- # Ensure tables exist
12
- Base.metadata.create_all(bind=engine)
13
-
14
- db = SessionLocal()
15
- try:
16
- # Check if already seeded
17
- if db.query(HomeSection).count() > 0:
18
- print("Home sections already initialized.")
19
- return
20
-
21
- sections = [
22
- {
23
- "title_ar": "ميزانيتك تهمنا",
24
- "title_en": "Your Budget Matters",
25
- "subtitle_ar": "أفضل الصفقات بأسعار لا تقاوم",
26
- "subtitle_en": "Best deals at unbeatable prices",
27
- "section_type": "AUTOMATIC",
28
- "rule": {"sort_by": "price", "sort_order": "asc", "limit": 8},
29
- "display_order": 0,
30
- "color_theme": "emerald",
31
- "icon": "💰"
32
- },
33
- {
34
- "title_ar": "عروض حصرية",
35
- "title_en": "Exclusive Offers",
36
- "subtitle_ar": "خصومات لفترة محدودة فقط",
37
- "subtitle_en": "Limited time discounts only",
38
- "section_type": "AUTOMATIC",
39
- "rule": {"sort_by": "discount", "sort_order": "desc", "limit": 8},
40
- "display_order": 1,
41
- "color_theme": "amber",
42
- "icon": "⚡"
43
- },
44
- {
45
- "title_ar": "جديدنا",
46
- "title_en": "New Arrivals",
47
- "subtitle_ar": "أحدث المنتجات في متجرنا",
48
- "subtitle_en": "The latest products in our store",
49
- "section_type": "AUTOMATIC",
50
- "rule": {"sort_by": "created_at", "sort_order": "desc", "limit": 8},
51
- "display_order": 2,
52
- "color_theme": "blue",
53
- "icon": "✨"
54
- },
55
- {
56
- "title_ar": "وصلنا حديثاً",
57
- "title_en": "Recently Arrived",
58
- "subtitle_ar": "اكتشف ما وصل للتو",
59
- "subtitle_en": "Explore what just arrived",
60
- "section_type": "AUTOMATIC",
61
- "rule": {"sort_by": "created_at", "sort_order": "desc", "limit": 4},
62
- "display_order": 3,
63
- "color_theme": "rose",
64
- "icon": "🚚"
65
- }
66
- ]
67
-
68
- for s_data in sections:
69
- section = HomeSection(**s_data)
70
- db.add(section)
71
-
72
- db.commit()
73
- print(f"Successfully initialized {len(sections)} home sections.")
74
- except Exception as e:
75
- print(f"Error initializing home sections: {e}")
76
- db.rollback()
77
- finally:
78
- db.close()
79
-
80
- if __name__ == "__main__":
81
- init_home_sections()