Skip to content

Commit 2a3b119

Browse files
committed
Add seed data for custom placeholders
1 parent 32689d9 commit 2a3b119

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

populate_db.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
# EventLocation
4141
from app.models.event_location import EventLocation
4242

43+
# Custom Placeholder
44+
from app.models.custom_placeholder import CustomPlaceholder
45+
4346
# User Permissions
4447
from app.models.user_permission import UserPermission
4548
SALES = 'sales'
@@ -174,7 +177,7 @@ def create_event_sub_topics():
174177
"Religion & Spirituality": ["Mysticism and Occult"],
175178
"Government & Politics": ["Non-partisan"]
176179
}
177-
eventopics=db.session.query(EventTopic).all()
180+
eventopics = db.session.query(EventTopic).all()
178181
for keysub_topic in event_sub_topic:
179182
for subtopic in event_sub_topic[keysub_topic]:
180183
get_or_create(EventSubTopic, name=subtopic, event_topic_id=next(x for x in eventopics if x.name==keysub_topic).id)
@@ -311,6 +314,11 @@ def create_admin_message_settings():
311314
)
312315

313316

317+
def create_custom_placeholders():
318+
custom_placeholder, _ = get_or_create(CustomPlaceholder, name='Hills', original_image_url='https://www.w3schools.com/html/pic_mountain.jpg', event_sub_topic_id=1)
319+
db.session.add(custom_placeholder)
320+
321+
314322
def populate():
315323
"""
316324
Create defined Roles, Services and Permissions.
@@ -347,6 +355,8 @@ def populate():
347355
create_event_locations()
348356
print('Creating admin message settings...')
349357
create_admin_message_settings()
358+
print('Creating custom placeholders...')
359+
create_custom_placeholders()
350360

351361

352362
def populate_without_print():
@@ -369,6 +379,7 @@ def populate_without_print():
369379
create_event_types()
370380
create_event_locations()
371381
create_admin_message_settings()
382+
create_custom_placeholders()
372383

373384
db.session.commit()
374385

tests/hook_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3658,7 +3658,7 @@ def event_sub_topic_custom_placeholder_get_detail(transaction):
36583658
event_sub_topic = EventSubTopicFactory()
36593659
db.session.add(event_sub_topic)
36603660

3661-
custom_placeholder = CustomPlaceholderFactory(event_sub_topic_id=1)
3661+
custom_placeholder = CustomPlaceholderFactory()
36623662
db.session.add(custom_placeholder)
36633663
db.session.commit()
36643664

0 commit comments

Comments
 (0)