feat: implement modular UMass theme components and supporting generation scripts for home page structure
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import oracledb
|
||||
import os
|
||||
import sys
|
||||
|
||||
def seed_template():
|
||||
print("Reading temp file...")
|
||||
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_main/html_snippets/content_main_blocks/temp', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
print("Connecting to Oracle...")
|
||||
try:
|
||||
# Connect to Oracle database
|
||||
connection = oracledb.connect(
|
||||
user="sisvietnam",
|
||||
password="sisvietnam",
|
||||
dsn="localhost:1521/sisvietnam"
|
||||
)
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
||||
# Check if it already exists
|
||||
cursor.execute("SELECT id FROM sis_component_template WHERE slug = :slug", slug='video-fallback')
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row:
|
||||
print(f"Template video-fallback already exists with ID {row[0]}. Updating content...")
|
||||
cursor.execute("""
|
||||
UPDATE sis_component_template
|
||||
SET html_template = :content
|
||||
WHERE id = :id
|
||||
""", content=content, id=row[0])
|
||||
else:
|
||||
print("Inserting new video-fallback template...")
|
||||
# We need to insert a new row. The ID might be auto-generated by sequence.
|
||||
# Assuming id is generated by sequence or identity column.
|
||||
# In Hibernate with Oracle, it usually uses a sequence sis_component_template_seq or SEQ_SIS_COMPONENT_TEMPLATE
|
||||
|
||||
# Let's try to insert without ID first (if it's identity column)
|
||||
try:
|
||||
cursor.execute("""
|
||||
INSERT INTO sis_component_template (id, slug, name, description, active, html_template, created_by, created_date)
|
||||
VALUES ((SELECT NVL(MAX(id), 0) + 1 FROM sis_component_template), :slug, :name, :description, :active, :content, 'system', CURRENT_TIMESTAMP)
|
||||
""", slug='video-fallback', name='Video Fallback Banner', description='Fallback for homepage hero video', active=1, content=content)
|
||||
except Exception as e:
|
||||
print(f"Insert with MAX(id) failed: {e}")
|
||||
|
||||
connection.commit()
|
||||
print("Successfully seeded video-fallback template!")
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
seed_template()
|
||||
Reference in New Issue
Block a user