content.py 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # TODO : [LibContent] Reenable this when API where availables
  2. # # -*- coding: utf-8 -*-
  3. # from depot.io.utils import FileIntent
  4. #
  5. # from tracim import models
  6. # from tracim.fixtures import Fixture
  7. # from tracim.fixtures.users_and_groups import Test
  8. # from tracim.lib.content import ContentApi
  9. # from tracim.lib.userworkspace import RoleApi
  10. # from tracim.lib.workspace import WorkspaceApi
  11. # from tracim.models.data import ContentType
  12. # from tracim.models.data import UserRoleInWorkspace
  13. #
  14. #
  15. # class Content(Fixture):
  16. # require = [Test]
  17. #
  18. # def insert(self):
  19. # admin = self._session.query(models.User) \
  20. # .filter(models.User.email == 'admin@admin.admin') \
  21. # .one()
  22. # bob = self._session.query(models.User) \
  23. # .filter(models.User.email == 'bob@fsf.local') \
  24. # .one()
  25. # admin_workspace_api = WorkspaceApi(admin)
  26. # bob_workspace_api = WorkspaceApi(bob)
  27. # content_api = ContentApi(admin)
  28. # role_api = RoleApi(admin)
  29. #
  30. # # Workspaces
  31. # w1 = admin_workspace_api.create_workspace('w1', save_now=True)
  32. # w2 = bob_workspace_api.create_workspace('w2', save_now=True)
  33. # w3 = admin_workspace_api.create_workspace('w3', save_now=True)
  34. #
  35. # # Workspaces roles
  36. # role_api.create_one(
  37. # user=bob,
  38. # workspace=w1,
  39. # role_level=UserRoleInWorkspace.CONTENT_MANAGER,
  40. # with_notif=False,
  41. # )
  42. #
  43. # # Folders
  44. # w1f1 = content_api.create(
  45. # content_type=ContentType.Folder,
  46. # workspace=w1,
  47. # label='w1f1',
  48. # do_save=True,
  49. # )
  50. # w1f2 = content_api.create(
  51. # content_type=ContentType.Folder,
  52. # workspace=w1,
  53. # label='w1f2',
  54. # do_save=True,
  55. # )
  56. #
  57. # w2f1 = content_api.create(
  58. # content_type=ContentType.Folder,
  59. # workspace=w2,
  60. # label='w2f1',
  61. # do_save=True,
  62. # )
  63. # w2f2 = content_api.create(
  64. # content_type=ContentType.Folder,
  65. # workspace=w2,
  66. # label='w2f2',
  67. # do_save=True,
  68. # )
  69. #
  70. # w3f1 = content_api.create(
  71. # content_type=ContentType.Folder,
  72. # workspace=w3,
  73. # label='w3f3',
  74. # do_save=True,
  75. # )
  76. #
  77. # # Pages, threads, ..
  78. # w1f1p1 = content_api.create(
  79. # content_type=ContentType.Page,
  80. # workspace=w1,
  81. # parent=w1f1,
  82. # label='w1f1p1',
  83. # do_save=True,
  84. # )
  85. # w1f1t1 = content_api.create(
  86. # content_type=ContentType.Thread,
  87. # workspace=w1,
  88. # parent=w1f1,
  89. # label='w1f1t1',
  90. # do_save=False,
  91. # )
  92. # w1f1t1.description = 'w1f1t1 description'
  93. # self._session.add(w1f1t1)
  94. # w1f1d1_txt = content_api.create(
  95. # content_type=ContentType.File,
  96. # workspace=w1,
  97. # parent=w1f1,
  98. # label='w1f1d1',
  99. # do_save=False,
  100. # )
  101. # w1f1d1_txt.file_extension = '.txt'
  102. # w1f1d1_txt.depot_file = FileIntent(
  103. # b'w1f1d1 content',
  104. # 'w1f1d1.txt',
  105. # 'text/plain',
  106. # )
  107. # self._session.add(w1f1d1_txt)
  108. # w1f1d2_html = content_api.create(
  109. # content_type=ContentType.File,
  110. # workspace=w1,
  111. # parent=w1f1,
  112. # label='w1f1d2',
  113. # do_save=False,
  114. # )
  115. # w1f1d2_html.file_extension = '.html'
  116. # w1f1d2_html.depot_file = FileIntent(
  117. # b'<p>w1f1d2 content</p>',
  118. # 'w1f1d2.html',
  119. # 'text/html',
  120. # )
  121. # self._session.add(w1f1d2_html)
  122. # w1f1f1 = content_api.create(
  123. # content_type=ContentType.Folder,
  124. # workspace=w1,
  125. # label='w1f1f1',
  126. # parent=w1f1,
  127. # do_save=True,
  128. # )
  129. #
  130. # w2f1p1 = content_api.create(
  131. # content_type=ContentType.Page,
  132. # workspace=w2,
  133. # parent=w2f1,
  134. # label='w2f1p1',
  135. # do_save=True,
  136. # )
  137. # self._session.flush()