seed_education.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. import json
  2. from app import create_app, db
  3. from app.models import PageContent
  4. app = create_app()
  5. with app.app_context():
  6. education_data = {
  7. "banner": {
  8. "title": "助力高校AI + 内涵建设",
  9. "subtitle": "推动 AI 技术与专业教学深度融合,提升院校学科建设与人才培养质量",
  10. "bg_image_url": "", # 新增背景图字段
  11. "image_url": "https://images.unsplash.com/photo-1531482615713-2afd69097998?q=80&w=2070&auto=format&fit=crop"
  12. },
  13. "features": [
  14. { "icon": "School", "icon_url": "", "title": "教学", "subtitle": "人工智能培育" },
  15. { "icon": "OfficeBuilding", "icon_url": "", "title": "实训", "subtitle": "训战一体化" },
  16. { "icon": "DataLine", "icon_url": "", "title": "科研", "subtitle": "训战一体化" }
  17. ]
  18. }
  19. existing = PageContent.query.filter_by(page_key='education').first()
  20. if existing:
  21. existing.content = json.dumps(education_data, ensure_ascii=False)
  22. else:
  23. new_page = PageContent(
  24. page_key='education',
  25. page_name='产教融合',
  26. content=json.dumps(education_data, ensure_ascii=False)
  27. )
  28. db.session.add(new_page)
  29. db.session.commit()
  30. print("Education page data seeded successfully.")