No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lodelsites_em.py 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/python3
  2. #
  3. # This file is part of Lodel 2 (https://github.com/OpenEdition)
  4. #
  5. # Copyright (C) 2015-2017 Cléo UMS-3287
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License, version 3,
  9. # as published by the Free Software Foundation.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. from lodel.context import LodelContext
  20. LodelContext.init()
  21. from lodel.settings.settings import Settings as settings
  22. settings('globconf.d')
  23. from lodel.settings import Settings
  24. from lodel.editorial_model.components import *
  25. from lodel.editorial_model.exceptions import *
  26. from lodel.editorial_model.model import EditorialModel
  27. em = EditorialModel('LodelSites', 'LodelSites editorial model')
  28. base_group = em.new_group(
  29. 'base_group',
  30. display_name = 'Base group',
  31. help_text = 'Base group that implements base EM features (like classtype)'
  32. )
  33. em_lodel_site = em.new_class(
  34. 'LodelSite',
  35. group = base_group
  36. )
  37. em_lodel_site.new_field(
  38. 'name',
  39. display_name = 'lodelSiteName',
  40. help_text = 'Lodel site full name',
  41. group = base_group,
  42. data_handler = 'varchar'
  43. )
  44. em_lodel_site.new_field(
  45. 'shortname',
  46. display_text = 'lodelSiteShortName',
  47. help_text = 'Lodel site short string identifier',
  48. group = base_group,
  49. data_handler = 'varchar',
  50. max_length = 5,
  51. uniq = True
  52. )
  53. em_lodel_site.new_field(
  54. 'extensions',
  55. display_text = 'lodeSiteExtensions',
  56. help_text = 'Lodel site extensions',
  57. group = base_group,
  58. data_handler = 'varcharlist',
  59. delimiter = ' '
  60. )
  61. em_lodel_site.new_field(
  62. 'em_groups',
  63. display_text = 'lodelSiteEmGroups',
  64. help_text = 'Lodel site EM groups',
  65. group = base_group,
  66. data_handler = 'text',
  67. )
  68. pickle_file_path = 'examples/lodelsites_em.pickle'
  69. xml_file_path = 'examples/lodelsites_em.xml'
  70. em.save('xmlfile', filename=xml_file_path)
  71. em.save('picklefile', filename=pickle_file_path)