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

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