Skip to content

Commit 301a90d

Browse files
prabhupantmrsaicharan1
authored andcommitted
Add seed data for custom placeholders (fossasia#5533)
1 parent 16e516e commit 301a90d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

populate_db.py

Lines changed: 16 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,15 @@ def create_admin_message_settings():
311314
)
312315

313316

317+
def create_custom_placeholders():
318+
custom_placeholder, _ = get_or_create(
319+
CustomPlaceholder, name='Hills',
320+
original_image_url='https://www.w3schools.com/html/pic_mountain.jpg',
321+
event_sub_topic_id=1
322+
)
323+
db.session.add(custom_placeholder)
324+
325+
314326
def populate():
315327
"""
316328
Create defined Roles, Services and Permissions.
@@ -347,6 +359,8 @@ def populate():
347359
create_event_locations()
348360
print('Creating admin message settings...')
349361
create_admin_message_settings()
362+
print('Creating custom placeholders...')
363+
create_custom_placeholders()
350364

351365

352366
def populate_without_print():
@@ -369,6 +383,7 @@ def populate_without_print():
369383
create_event_types()
370384
create_event_locations()
371385
create_admin_message_settings()
386+
create_custom_placeholders()
372387

373388
db.session.commit()
374389

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)