|
14 | 14 |
|
15 | 15 | def seed_data() -> None: |
16 | 16 | with Session(engine) as session: |
17 | | - # Get the default organization |
| 17 | + # Get the admin organization (created during init_db) |
18 | 18 | organization = session.exec( |
19 | | - select(Organization).where(Organization.name == "Default Organization") |
| 19 | + select(Organization).where(Organization.name == "Admin Organization") |
20 | 20 | ).first() |
21 | 21 |
|
22 | 22 | if not organization: |
23 | | - logger.error("Default organization not found! Run init_db first.") |
| 23 | + logger.error("Admin organization not found! Run initial_data.py first.") |
24 | 24 | return |
25 | 25 |
|
26 | 26 | logger.info(f"Using organization: {organization.name}") |
@@ -112,101 +112,69 @@ def seed_data() -> None: |
112 | 112 | session.refresh(project1) |
113 | 113 | session.refresh(project2) |
114 | 114 | session.refresh(project3) |
| 115 | + session.refresh(project4) |
115 | 116 | session.refresh(project5) |
116 | 117 |
|
117 | 118 | logger.info("Created 5 sample projects") |
118 | 119 |
|
119 | | - # Create sample galleries |
| 120 | + # Create one gallery per project |
120 | 121 | gallery1 = Gallery( |
121 | | - name="Engagement Shoot", |
122 | | - date=today - timedelta(days=10), |
123 | | - photo_count=87, |
124 | | - photographer="Alice Johnson", |
125 | | - status="published", |
126 | | - cover_image_url="https://images.unsplash.com/photo-1519741497674-611481863552?w=400&h=300&fit=crop", |
| 122 | + name=f"{project1.name} - Gallery", |
| 123 | + date=project1.start_date, |
| 124 | + photo_count=0, |
| 125 | + photographer=None, |
| 126 | + status="draft", |
| 127 | + cover_image_url=None, |
127 | 128 | project_id=project1.id, |
128 | 129 | ) |
129 | 130 | session.add(gallery1) |
130 | 131 |
|
131 | 132 | gallery2 = Gallery( |
132 | | - name="Wedding Day - Ceremony", |
133 | | - date=today - timedelta(days=3), |
134 | | - photo_count=234, |
135 | | - photographer="Alice Johnson", |
136 | | - status="processing", |
137 | | - cover_image_url="https://images.unsplash.com/photo-1606800052052-a08af7148866?w=400&h=300&fit=crop", |
138 | | - project_id=project1.id, |
| 133 | + name=f"{project2.name} - Gallery", |
| 134 | + date=project2.start_date, |
| 135 | + photo_count=0, |
| 136 | + photographer=None, |
| 137 | + status="draft", |
| 138 | + cover_image_url=None, |
| 139 | + project_id=project2.id, |
139 | 140 | ) |
140 | 141 | session.add(gallery2) |
141 | 142 |
|
142 | 143 | gallery3 = Gallery( |
143 | | - name="Wedding Day - Reception", |
144 | | - date=today - timedelta(days=3), |
145 | | - photo_count=198, |
146 | | - photographer="Bob Smith", |
147 | | - status="processing", |
148 | | - cover_image_url="https://images.unsplash.com/photo-1464366400600-7168b8af9bc3?w=400&h=300&fit=crop", |
149 | | - project_id=project1.id, |
| 144 | + name=f"{project3.name} - Gallery", |
| 145 | + date=project3.start_date, |
| 146 | + photo_count=0, |
| 147 | + photographer=None, |
| 148 | + status="draft", |
| 149 | + cover_image_url=None, |
| 150 | + project_id=project3.id, |
150 | 151 | ) |
151 | 152 | session.add(gallery3) |
152 | 153 |
|
153 | 154 | gallery4 = Gallery( |
154 | | - name="Smartphone Collection - White BG", |
155 | | - date=today - timedelta(days=3), |
156 | | - photo_count=52, |
157 | | - photographer="Charlie Davis", |
158 | | - status="published", |
159 | | - cover_image_url="https://images.unsplash.com/photo-1511707171634-5f897ff02aa9?w=400&h=300&fit=crop", |
160 | | - project_id=project2.id, |
| 155 | + name=f"{project4.name} - Gallery", |
| 156 | + date=project4.start_date, |
| 157 | + photo_count=0, |
| 158 | + photographer=None, |
| 159 | + status="draft", |
| 160 | + cover_image_url=None, |
| 161 | + project_id=project4.id, |
161 | 162 | ) |
162 | 163 | session.add(gallery4) |
163 | 164 |
|
164 | 165 | gallery5 = Gallery( |
165 | | - name="Lifestyle Shots", |
166 | | - date=today - timedelta(days=3), |
167 | | - photo_count=48, |
168 | | - photographer="Charlie Davis", |
169 | | - status="published", |
170 | | - cover_image_url="https://images.unsplash.com/photo-1556656793-08538906a9f8?w=400&h=300&fit=crop", |
171 | | - project_id=project2.id, |
172 | | - ) |
173 | | - session.add(gallery5) |
174 | | - |
175 | | - gallery6 = Gallery( |
176 | | - name="Mood Board & References", |
177 | | - date=today, |
178 | | - photo_count=15, |
179 | | - photographer="Alice Johnson", |
| 166 | + name=f"{project5.name} - Gallery", |
| 167 | + date=project5.start_date, |
| 168 | + photo_count=0, |
| 169 | + photographer=None, |
180 | 170 | status="draft", |
181 | | - cover_image_url="https://images.unsplash.com/photo-1542744173-8e7e53415bb0?w=400&h=300&fit=crop", |
182 | | - project_id=project3.id, |
183 | | - ) |
184 | | - session.add(gallery6) |
185 | | - |
186 | | - gallery7 = Gallery( |
187 | | - name="Menu Items - Appetizers", |
188 | | - date=today - timedelta(days=20), |
189 | | - photo_count=45, |
190 | | - photographer="David Lee", |
191 | | - status="published", |
192 | | - cover_image_url="https://images.unsplash.com/photo-1504674900247-0877df9cc836?w=400&h=300&fit=crop", |
193 | | - project_id=project5.id, |
194 | | - ) |
195 | | - session.add(gallery7) |
196 | | - |
197 | | - gallery8 = Gallery( |
198 | | - name="Menu Items - Main Courses", |
199 | | - date=today - timedelta(days=18), |
200 | | - photo_count=52, |
201 | | - photographer="David Lee", |
202 | | - status="published", |
203 | | - cover_image_url="https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=400&h=300&fit=crop", |
| 171 | + cover_image_url=None, |
204 | 172 | project_id=project5.id, |
205 | 173 | ) |
206 | | - session.add(gallery8) |
| 174 | + session.add(gallery5) |
207 | 175 |
|
208 | 176 | session.commit() |
209 | | - logger.info("Created 8 sample galleries") |
| 177 | + logger.info("Created 5 galleries (one per project)") |
210 | 178 | logger.info("Sample data seeding complete!") |
211 | 179 |
|
212 | 180 |
|
|
0 commit comments