katello 3.17.0 → 3.18.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

Files changed (272) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/registry/registry_proxies_controller.rb +38 -21
  3. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +3 -1
  4. data/app/controllers/katello/api/v2/activation_keys_controller.rb +10 -15
  5. data/app/controllers/katello/api/v2/capsule_content_controller.rb +2 -2
  6. data/app/controllers/katello/api/v2/content_credentials_controller.rb +1 -8
  7. data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +98 -0
  8. data/app/controllers/katello/api/v2/content_exports_controller.rb +84 -0
  9. data/app/controllers/katello/api/v2/content_imports_controller.rb +59 -0
  10. data/app/controllers/katello/api/v2/content_view_components_controller.rb +31 -14
  11. data/app/controllers/katello/api/v2/content_view_filters_controller.rb +17 -8
  12. data/app/controllers/katello/api/v2/content_view_repositories_controller.rb +1 -0
  13. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +65 -71
  14. data/app/controllers/katello/api/v2/content_views_controller.rb +37 -26
  15. data/app/controllers/katello/api/v2/environments_controller.rb +8 -8
  16. data/app/controllers/katello/api/v2/gpg_keys_controller.rb +5 -5
  17. data/app/controllers/katello/api/v2/host_collections_controller.rb +19 -16
  18. data/app/controllers/katello/api/v2/host_debs_controller.rb +1 -0
  19. data/app/controllers/katello/api/v2/host_errata_controller.rb +2 -2
  20. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +35 -6
  21. data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +1 -1
  22. data/app/controllers/katello/api/v2/products_controller.rb +9 -9
  23. data/app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb +1 -1
  24. data/app/controllers/katello/api/v2/repositories_controller.rb +10 -5
  25. data/app/controllers/katello/api/v2/repository_sets_controller.rb +24 -14
  26. data/app/controllers/katello/api/v2/subscriptions_controller.rb +1 -1
  27. data/app/controllers/katello/api/v2/sync_plans_controller.rb +8 -9
  28. data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +9 -2
  29. data/app/controllers/katello/concerns/api/v2/authorization.rb +19 -5
  30. data/app/controllers/katello/concerns/api/v2/bulk_hosts_extensions.rb +22 -18
  31. data/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +21 -0
  32. data/app/controllers/katello/concerns/api/v2/repository_content_controller.rb +1 -1
  33. data/app/controllers/katello/concerns/organizations_controller_extensions.rb +2 -1
  34. data/app/controllers/katello/concerns/registration_controller_extensions.rb +16 -0
  35. data/app/helpers/katello/katello_urls_helper.rb +5 -2
  36. data/app/lib/actions/candlepin/product/content_create.rb +2 -0
  37. data/app/lib/actions/candlepin/product/content_update.rb +2 -0
  38. data/app/lib/actions/helpers/smart_proxy_sync_history_helper.rb +24 -0
  39. data/app/lib/actions/katello/applicability/hosts/bulk_generate.rb +6 -2
  40. data/app/lib/actions/katello/capsule_content/sync.rb +1 -1
  41. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +16 -7
  42. data/app/lib/actions/katello/content_view/promote_to_environment.rb +1 -1
  43. data/app/lib/actions/katello/content_view/publish.rb +9 -9
  44. data/app/lib/actions/katello/content_view_version/import.rb +8 -13
  45. data/app/lib/actions/katello/content_view_version/import_library.rb +17 -0
  46. data/app/lib/actions/katello/content_view_version/incremental_update.rb +18 -3
  47. data/app/lib/actions/katello/host/hypervisors_update.rb +18 -0
  48. data/app/lib/actions/katello/host/update_system_purpose.rb +31 -0
  49. data/app/lib/actions/katello/host/upload_package_profile.rb +3 -1
  50. data/app/lib/actions/katello/host/upload_profiles.rb +8 -6
  51. data/app/lib/actions/katello/organization/manifest_delete.rb +0 -1
  52. data/app/lib/actions/katello/organization/manifest_import.rb +0 -1
  53. data/app/lib/actions/katello/organization/manifest_refresh.rb +0 -1
  54. data/app/lib/actions/katello/product/content_create.rb +7 -6
  55. data/app/lib/actions/katello/repository/filtered_index_content.rb +10 -1
  56. data/app/lib/actions/katello/repository/import_upload.rb +4 -1
  57. data/app/lib/actions/katello/repository/remove_content.rb +1 -1
  58. data/app/lib/actions/katello/repository/sync.rb +3 -1
  59. data/app/lib/actions/katello/repository/update.rb +5 -1
  60. data/app/lib/actions/katello/repository/upload_files.rb +1 -0
  61. data/app/lib/actions/middleware/record_smart_proxy_sync_history.rb +15 -0
  62. data/app/lib/actions/pulp/consumer/sync_capsule.rb +4 -2
  63. data/app/lib/actions/pulp/repository/distributor_publish.rb +1 -1
  64. data/app/lib/actions/pulp3/capsule_content/sync.rb +1 -0
  65. data/app/lib/actions/pulp3/content_migration.rb +10 -0
  66. data/app/lib/actions/pulp3/content_migration_presenter.rb +59 -0
  67. data/app/lib/actions/pulp3/content_view/delete_repository_references.rb +1 -1
  68. data/app/lib/actions/pulp3/content_view_version/create_importer.rb +7 -3
  69. data/app/lib/actions/pulp3/content_view_version/export.rb +7 -1
  70. data/app/lib/actions/pulp3/content_view_version/import.rb +7 -3
  71. data/app/lib/actions/pulp3/import_migration.rb +6 -1
  72. data/app/lib/actions/pulp3/orchestration/content_view_version/copy_version_units_to_library.rb +2 -1
  73. data/app/lib/actions/pulp3/orchestration/content_view_version/export.rb +38 -14
  74. data/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb +60 -0
  75. data/app/lib/actions/pulp3/orchestration/content_view_version/import.rb +16 -10
  76. data/app/lib/actions/pulp3/orchestration/repository/generate_metadata.rb +4 -1
  77. data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +16 -3
  78. data/app/lib/actions/pulp3/repository/commit_upload.rb +2 -1
  79. data/app/lib/actions/pulp3/repository/copy_content.rb +1 -1
  80. data/app/lib/actions/pulp3/repository/delete.rb +1 -1
  81. data/app/lib/actions/pulp3/repository/save_artifact.rb +1 -1
  82. data/app/lib/actions/pulp3/repository/save_version.rb +1 -1
  83. data/app/lib/actions/pulp3/repository/upload_tag.rb +18 -0
  84. data/app/lib/katello/resources/candlepin/consumer.rb +2 -2
  85. data/app/lib/katello/resources/candlepin/owner.rb +5 -0
  86. data/app/lib/katello/resources/candlepin/upstream_consumer.rb +6 -0
  87. data/app/lib/katello/resources/registry.rb +3 -3
  88. data/app/models/katello/authorization/activation_key.rb +4 -0
  89. data/app/models/katello/authorization/content_view.rb +13 -0
  90. data/app/models/katello/authorization/content_view_component.rb +15 -0
  91. data/app/models/katello/authorization/content_view_filter.rb +15 -0
  92. data/app/models/katello/authorization/content_view_version.rb +25 -2
  93. data/app/models/katello/authorization/content_view_version_export_history.rb +1 -1
  94. data/app/models/katello/authorization/gpg_key.rb +12 -4
  95. data/app/models/katello/authorization/lifecycle_environment.rb +8 -0
  96. data/app/models/katello/authorization/organization.rb +8 -0
  97. data/app/models/katello/authorization/sync_plan.rb +16 -0
  98. data/app/models/katello/concerns/operatingsystem_extensions.rb +2 -0
  99. data/app/models/katello/concerns/organization_extensions.rb +4 -5
  100. data/app/models/katello/concerns/smart_proxy_extensions.rb +6 -4
  101. data/app/models/katello/content_migration_progress.rb +4 -0
  102. data/app/models/katello/content_view.rb +30 -4
  103. data/app/models/katello/content_view_component.rb +2 -0
  104. data/app/models/katello/content_view_filter.rb +5 -0
  105. data/app/models/katello/content_view_history.rb +2 -1
  106. data/app/models/katello/content_view_package_filter.rb +1 -1
  107. data/app/models/katello/content_view_puppet_module.rb +8 -0
  108. data/app/models/katello/content_view_repository.rb +13 -1
  109. data/app/models/katello/content_view_version_export_history.rb +8 -1
  110. data/app/models/katello/glue/candlepin/pool.rb +9 -14
  111. data/app/models/katello/glue/pulp/repo.rb +8 -0
  112. data/app/models/katello/gpg_key.rb +1 -1
  113. data/app/models/katello/ping.rb +8 -3
  114. data/app/models/katello/repository.rb +33 -0
  115. data/app/models/katello/root_repository.rb +26 -1
  116. data/app/models/katello/smart_proxy_sync_history.rb +8 -0
  117. data/app/services/katello/candlepin/event_handler.rb +2 -0
  118. data/app/services/katello/candlepin/message_handler.rb +34 -0
  119. data/app/services/katello/candlepin/upstream_consumer.rb +28 -0
  120. data/app/services/katello/host_status_manager.rb +9 -0
  121. data/app/services/katello/pulp3/api/apt.rb +57 -0
  122. data/app/services/katello/pulp3/api/core.rb +8 -0
  123. data/app/services/katello/pulp3/api/docker.rb +4 -0
  124. data/app/services/katello/pulp3/content_view_version/export.rb +125 -8
  125. data/app/services/katello/pulp3/content_view_version/import.rb +39 -34
  126. data/app/services/katello/pulp3/content_view_version/import_export_common.rb +6 -16
  127. data/app/services/katello/pulp3/content_view_version/import_validator.rb +114 -0
  128. data/app/services/katello/pulp3/deb.rb +38 -0
  129. data/app/services/katello/pulp3/docker_manifest.rb +1 -0
  130. data/app/services/katello/pulp3/docker_tag.rb +1 -0
  131. data/app/services/katello/pulp3/migration.rb +51 -10
  132. data/app/services/katello/pulp3/pulp_content_unit.rb +5 -0
  133. data/app/services/katello/pulp3/repository.rb +10 -4
  134. data/app/services/katello/pulp3/repository/ansible_collection.rb +9 -0
  135. data/app/services/katello/pulp3/repository/apt.rb +63 -0
  136. data/app/services/katello/pulp3/repository/docker.rb +9 -0
  137. data/app/services/katello/pulp3/repository/yum.rb +14 -9
  138. data/app/services/katello/pulp3/repository_mirror.rb +9 -4
  139. data/app/services/katello/pulp3/task.rb +4 -0
  140. data/app/services/katello/pulp3/task_group.rb +4 -0
  141. data/app/services/katello/repository_type.rb +2 -1
  142. data/app/services/katello/smart_proxy_helper.rb +9 -0
  143. data/app/views/dashboard/_subscription_widget.html.erb +0 -5
  144. data/app/views/foreman/hosts/_registration.html.erb +12 -0
  145. data/app/views/katello/api/v2/content_view_version_export_histories/show.json.rabl +1 -1
  146. data/app/views/katello/api/v2/content_views/base.json.rabl +1 -0
  147. data/app/views/katello/api/v2/repositories/base.json.rabl +1 -1
  148. data/app/views/katello/layouts/react.html.erb +3 -2
  149. data/app/views/overrides/activation_keys/_host_tab_pane.html.erb +1 -5
  150. data/app/views/overrides/organizations/_index_row_override.html.erb +1 -1
  151. data/config/routes/api/v2.rb +24 -2
  152. data/config/routes/overrides.rb +1 -0
  153. data/db/migrate/20200929200357_create_katello_smart_proxy_sync_history.rb +13 -0
  154. data/db/migrate/20201008204114_add_os_versions_to_katello_root_repositories.rb +5 -0
  155. data/db/migrate/20201012172713_remove_gpg_key_perms.rb +23 -0
  156. data/db/migrate/20201012192035_add_metadata_to_katello_content_view_version_export_history.rb +5 -0
  157. data/db/migrate/20201021150008_add_import_only_to_katello_content_view.rb +5 -0
  158. data/db/migrate/20201119211133_pulp3_migration_progress.rb +9 -0
  159. data/db/seeds.d/111-upgrade_tasks.rb +2 -1
  160. data/engines/bastion/app/assets/javascripts/bastion/components/notification.service.js +1 -1
  161. data/engines/bastion/app/assets/javascripts/bastion/components/nutupane.factory.js +8 -13
  162. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-system-purpose-modal.controller.js +112 -0
  163. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-system-purpose-modal.html +78 -0
  164. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-host-modal-helper.service.js +11 -0
  165. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +5 -0
  166. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-debs-installed.controller.js +2 -42
  167. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +4 -0
  168. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-views.controller.js +6 -2
  169. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/content-view-details.controller.js +12 -0
  170. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-details.html +7 -7
  171. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-info.html +7 -1
  172. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/new/content-view-new.controller.js +17 -3
  173. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/new/views/content-view-new.html +16 -2
  174. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/views/content-views.html +5 -0
  175. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/host-collection-details.controller.js +4 -0
  176. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/views/host-collection-info.html +6 -0
  177. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-bulk-action.factory.js +2 -1
  178. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +92 -19
  179. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/de.po +17 -20
  180. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/es.po +17 -24
  181. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/fr.po +1292 -1170
  182. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/it.po +17 -20
  183. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ja.po +858 -807
  184. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ko.po +18 -19
  185. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/pt_BR.po +17 -24
  186. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ru.po +17 -18
  187. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_CN.po +986 -971
  188. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_TW.po +19 -20
  189. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/translations.js +9 -9
  190. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-advanced-sync-modal.controller.js +6 -7
  191. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +168 -155
  192. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +17 -2
  193. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +125 -113
  194. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +15 -3
  195. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/os-versions.service.js +46 -0
  196. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repository-types.service.js +8 -1
  197. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/content-access-mode-banner.html +1 -1
  198. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/details/views/sync-plan-details.html +1 -1
  199. data/lib/katello/engine.rb +2 -0
  200. data/lib/katello/permission_creator.rb +98 -69
  201. data/lib/katello/permissions/host_permissions.rb +1 -0
  202. data/lib/katello/plugin.rb +10 -2
  203. data/lib/katello/repository_types/deb.rb +9 -1
  204. data/lib/katello/tasks/pulp3_migration.rake +17 -3
  205. data/lib/katello/tasks/pulp3_migration_abort.rake +22 -0
  206. data/lib/katello/tasks/pulp3_migration_stats.rake +41 -0
  207. data/lib/katello/tasks/receptor/extract_orgs.rake +1 -1
  208. data/lib/katello/tasks/reset.rake +2 -1
  209. data/lib/katello/tasks/upgrades/3.18/add_cvv_export_history_metadata.rb +18 -0
  210. data/lib/katello/version.rb +1 -1
  211. data/locale/action_names.rb +51 -44
  212. data/locale/bn/katello.po +279 -55
  213. data/locale/cs/katello.po +278 -51
  214. data/locale/de/katello.po +279 -52
  215. data/locale/en/katello.po +278 -49
  216. data/locale/es/katello.po +279 -51
  217. data/locale/fr/katello.po +279 -51
  218. data/locale/gu/katello.po +279 -55
  219. data/locale/hi/katello.po +279 -55
  220. data/locale/it/katello.po +279 -51
  221. data/locale/ja/katello.po +279 -52
  222. data/locale/katello.pot +1379 -971
  223. data/locale/kn/katello.po +279 -55
  224. data/locale/ko/katello.po +279 -51
  225. data/locale/mr/katello.po +279 -55
  226. data/locale/or/katello.po +279 -55
  227. data/locale/pa/katello.po +279 -55
  228. data/locale/pt/katello.po +278 -52
  229. data/locale/pt_BR/katello.po +279 -51
  230. data/locale/ru/katello.po +279 -51
  231. data/locale/ta/katello.po +279 -55
  232. data/locale/te/katello.po +279 -55
  233. data/locale/zh_CN/katello.po +279 -51
  234. data/locale/zh_TW/katello.po +279 -52
  235. data/webpack/components/ActionableDetail.js +2 -1
  236. data/webpack/components/Search/Search.js +1 -1
  237. data/webpack/components/Table/MainTable.js +6 -2
  238. data/webpack/components/Table/TableWrapper.js +46 -9
  239. data/webpack/scenes/ContentViews/ContentViewSelectors.js +7 -3
  240. data/webpack/scenes/ContentViews/ContentViewsConstants.js +8 -0
  241. data/webpack/scenes/ContentViews/ContentViewsPage.js +2 -9
  242. data/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +25 -3
  243. data/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +14 -4
  244. data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +2 -1
  245. data/webpack/scenes/ContentViews/Details/Repositories/ContentCounts.js +56 -0
  246. data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +169 -0
  247. data/webpack/scenes/ContentViews/Details/Repositories/LastSync.js +47 -0
  248. data/webpack/scenes/ContentViews/Details/Repositories/RepoAddedStatus.js +17 -0
  249. data/webpack/scenes/ContentViews/Details/Repositories/RepoIcon.js +23 -0
  250. data/webpack/scenes/ContentViews/Details/Repositories/SelectableDropdown.js +49 -0
  251. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.fixtures.json +154 -0
  252. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.test.js +131 -0
  253. data/webpack/scenes/ContentViews/Details/__tests__/contentViewDetail.test.js +3 -0
  254. data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +4 -1
  255. data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +2 -2
  256. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +29 -19
  257. data/webpack/scenes/Subscriptions/Manifest/ManifestActions.js +17 -0
  258. data/webpack/scenes/Subscriptions/Manifest/ManifestConstants.js +4 -0
  259. data/webpack/scenes/Subscriptions/Manifest/SimpleContentAccess.js +19 -2
  260. data/webpack/scenes/Subscriptions/Manifest/__tests__/SimpleContentAccess.test.js +9 -1
  261. data/webpack/scenes/Subscriptions/Manifest/index.js +2 -1
  262. data/webpack/scenes/Subscriptions/SubscriptionConstants.js +1 -1
  263. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +3 -0
  264. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +8 -2
  265. data/webpack/scenes/Subscriptions/SubscriptionsSelectors.js +3 -0
  266. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +3 -0
  267. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsSelectors.test.js +6 -0
  268. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsSelectors.test.js.snap +6 -0
  269. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/SubscriptionsToolbar.js +1 -13
  270. data/webpack/test-utils/react-testing-lib-wrapper.js +3 -0
  271. metadata +74 -13
  272. data/webpack/__mocks__/foremanReact/components/common/Fill/GlobalFill.js +0 -3
@@ -1,7 +1,8 @@
1
1
  module Katello
2
2
  class Api::V2::ContentViewComponentsController < Api::V2::ApiController
3
- before_action :find_composite_content_view
4
- before_action :find_content_view_component, :only => [:show, :update]
3
+ before_action :find_composite_content_view, :only => [:show, :index]
4
+ before_action :find_composite_content_view_for_edit, :only => [:add_components, :remove_components, :update]
5
+ before_action :find_authorized_katello_resource, :only => [:show, :update]
5
6
 
6
7
  wrap_parameters :include => %w(composite_content_view_id content_view_version_id content_view_id latest)
7
8
 
@@ -13,7 +14,7 @@ module Katello
13
14
  end
14
15
 
15
16
  def index_response
16
- results = @view.content_view_components
17
+ results = @view.content_view_components.readable
17
18
  {
18
19
  :results => results.uniq,
19
20
  :subtotal => results.count,
@@ -31,15 +32,26 @@ module Katello
31
32
  param :latest, :bool, :desc => N_("true if the latest version of the component's content view is desired")
32
33
  end
33
34
  def add_components
35
+ @view.add_components(authorized_components)
36
+ @view.save!
37
+ respond_for_index(:collection => index_response, :template => "index")
38
+ end
39
+
40
+ private def authorized_components
34
41
  components = params.require(:components).map do |component|
35
42
  component = component.permit([:latest, :content_view_version_id, :content_view_id])
36
43
  options = {}
37
44
  options[:latest] = ::Foreman::Cast.to_bool(component[:latest]) if component.key?(:latest)
38
- options.merge(component.slice(:content_view_version_id, :content_view_id))
45
+ options.merge(component.slice(:content_view_version_id, :content_view_id)).with_indifferent_access
46
+ end
47
+
48
+ components.each do |component|
49
+ if component[:content_view_version_id] && Katello::ContentViewVersion.readable.find_by(id: component[:content_view_version_id]).nil?
50
+ throw_resource_not_found(name: 'content_view_version', id: component[:content_view_version_id])
51
+ elsif component[:content_view_id] && Katello::ContentView.readable.find_by(id: component[:content_view_id]).nil?
52
+ throw_resource_not_found(name: 'content_view', id: component[:content_view_id])
53
+ end
39
54
  end
40
- @view.add_components(components)
41
- @view.save!
42
- respond_for_index(:collection => index_response, :template => "index")
43
55
  end
44
56
 
45
57
  api :PUT, "/content_views/:composite_content_view_id/content_view_components/remove",
@@ -56,7 +68,7 @@ module Katello
56
68
  param :composite_content_view_id, :number, :desc => N_("composite content view numeric identifier"), :required => true
57
69
  param :id, :number, :desc => N_("content view component ID. Identifier of the component association"), :required => true
58
70
  def show
59
- respond :resource => @component
71
+ respond :resource => @content_view_component
60
72
  end
61
73
 
62
74
  api :PUT, "/content_views/:composite_content_view_id/content_view_components/:id",
@@ -67,6 +79,9 @@ module Katello
67
79
  param :latest, :bool, :desc => N_("true if the latest version of the components content view is desired")
68
80
  def update
69
81
  cvv_id = component_params[:content_view_version_id]
82
+ if cvv_id && Katello::ContentViewVersion.readable.find_by(id: cvv_id).nil?
83
+ throw_resource_not_found(name: 'content view version', id: cvv_id)
84
+ end
70
85
  if component_params.key?(:latest) && component_params.key?(:content_view_version_id)
71
86
  latest = ::Foreman::Cast.to_bool(component_params[:latest])
72
87
  if latest && cvv_id.present?
@@ -75,22 +90,24 @@ module Katello
75
90
  end
76
91
  end
77
92
  if cvv_id.present?
78
- @component.update!(:content_view_version_id => cvv_id, :latest => false)
93
+ @content_view_component.update!(:content_view_version_id => cvv_id, :latest => false)
79
94
  elsif component_params.key?(:latest)
80
95
  latest = ::Foreman::Cast.to_bool(component_params[:latest])
81
- @component.update!(:content_view_version_id => nil, :latest => latest)
96
+ @content_view_component.update!(:content_view_version_id => nil, :latest => latest)
82
97
  end
83
- respond :resource => @component
98
+ respond :resource => @content_view_component
84
99
  end
85
100
 
86
101
  private
87
102
 
88
103
  def find_composite_content_view
89
- @view = ContentView.composite.non_default.find(params[:composite_content_view_id])
104
+ @view = ContentView.composite.non_default.readable.find_by(id: params[:composite_content_view_id])
105
+ throw_resource_not_found(name: 'composite content view', id: params[:composite_content_view_id]) if @view.nil?
90
106
  end
91
107
 
92
- def find_content_view_component
93
- @component = ContentViewComponent.find(params[:id])
108
+ def find_composite_content_view_for_edit
109
+ @view = ContentView.composite.non_default.editable.find_by(id: params[:composite_content_view_id])
110
+ throw_resource_not_found(name: 'composite content view', id: params[:composite_content_view_id]) if @view.nil?
94
111
  end
95
112
 
96
113
  def component_params
@@ -2,9 +2,9 @@ module Katello
2
2
  class Api::V2::ContentViewFiltersController < Api::V2::ApiController
3
3
  include Katello::Concerns::FilteredAutoCompleteSearch
4
4
 
5
- before_action :find_content_view
5
+ before_action :find_editable_content_view, :only => [:create, :update, :destroy]
6
+ before_action :find_readable_content_view, :only => [:show, :index, :auto_complete_search]
6
7
  before_action :find_filter, :except => [:index, :create, :auto_complete_search]
7
-
8
8
  wrap_parameters :include => (ContentViewFilter.attribute_names + %w(repository_ids))
9
9
 
10
10
  api :get, "/content_views/:content_view_id/filters", N_("list filters")
@@ -73,7 +73,7 @@ module Katello
73
73
  respond :resource => @filter
74
74
  end
75
75
 
76
- api :delete, "/content_views/:content_view_id/filters/:id", N_("delete a filter")
76
+ api :delefind_filterte, "/content_views/:content_view_id/filters/:id", N_("delete a filter")
77
77
  api :delete, "/content_view_filters/:id", N_("delete a filter")
78
78
  param :content_view_id, :number, :desc => N_("content view identifier")
79
79
  param :id, :number, :desc => N_("filter identifier"), :required => true
@@ -84,18 +84,27 @@ module Katello
84
84
 
85
85
  private
86
86
 
87
- def find_content_view
88
- @view = ContentView.find(params[:content_view_id]) if params[:content_view_id]
87
+ def find_readable_content_view
88
+ @view = ContentView.readable.find_by(id: params[:content_view_id]) if params[:content_view_id]
89
+ throw_resource_not_found(name: 'content view', id: params[:content_view_id]) if params[:content_view_id] && @view.nil?
90
+ end
91
+
92
+ def find_editable_content_view
93
+ @view = ContentView.editable.find_by(id: params[:content_view_id]) if params[:content_view_id]
94
+ throw_resource_not_found(name: 'content view', id: params[:content_view_id]) if params[:content_view_id] && @view.nil?
89
95
  end
90
96
 
91
97
  def find_filter
92
98
  if @view
93
99
  @filter = @view.filters.find_by(:id => params[:id])
94
- fail HttpErrors::NotFound, _("Couldn't find ContentViewFilter with id=%s") % params[:id] unless @filter
100
+ elsif params[:action] == 'show'
101
+ @filter = ContentViewFilter.readable.find_by(id: params[:id])
102
+ @view = @filter&.content_view
95
103
  else
96
- @filter = ContentViewFilter.find(params[:id])
97
- @view = @filter.content_view
104
+ @filter = ContentViewFilter.editable.find_by(id: params[:id])
105
+ @view = @filter&.content_view
98
106
  end
107
+ fail HttpErrors::NotFound, _("Couldn't find ContentViewFilter with id=%s") % params[:id] unless @filter
99
108
  end
100
109
 
101
110
  def filter_params
@@ -25,6 +25,7 @@ module Katello
25
25
  SQL
26
26
 
27
27
  query = Katello::Repository.readable.in_default_view.in_organization(@organization)
28
+ query = query.with_type(params[:content_type]) if params[:content_type]
28
29
  # Use custom sort to perform the join and order since we need to order by specific content_view
29
30
  # and the ORDER BY query needs access to the katello_content_view_repositories table
30
31
  custom_sort = ->(sort_query) { sort_query.joins(:root).joins(join_query).order(order_query) }
@@ -3,8 +3,11 @@ module Katello
3
3
  include Concerns::Api::V2::BulkHostsExtensions
4
4
  include Katello::Concerns::FilteredAutoCompleteSearch
5
5
 
6
- before_action :find_content_view_version, :only => [:show, :update, :promote, :destroy, :export, :republish_repositories]
7
- before_action :find_content_view, :except => [:incremental_update]
6
+ before_action :find_authorized_katello_resource, :only => [:show, :update, :promote, :destroy, :export, :republish_repositories]
7
+ before_action :find_content_view_from_version, :only => [:show, :update, :promote, :destroy, :export, :republish_repositories]
8
+ before_action :find_optional_readable_content_view, :only => [:index]
9
+ before_action :find_publishable_content_view, :only => [:import]
10
+
8
11
  before_action :find_environment, :only => [:index]
9
12
  before_action :find_environments, :only => [:promote]
10
13
  before_action :validate_promotable, :only => [:promote]
@@ -46,7 +49,7 @@ module Katello
46
49
  api :GET, "/content_view_versions/:id", N_("Show content view version")
47
50
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
48
51
  def show
49
- respond :resource => @version
52
+ respond :resource => @content_view_version
50
53
  end
51
54
 
52
55
  api :POST, "/content_view_versions/:id/promote", N_("Promote a content view version")
@@ -57,7 +60,7 @@ module Katello
57
60
  def promote
58
61
  is_force = ::Foreman::Cast.to_bool(params[:force])
59
62
  task = async_task(::Actions::Katello::ContentView::Promote,
60
- @version, @environments, is_force, params[:description])
63
+ @content_view_version, @environments, is_force, params[:description])
61
64
  respond_for_async :resource => task
62
65
  end
63
66
 
@@ -65,96 +68,70 @@ module Katello
65
68
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
66
69
  param :description, String, :desc => N_("The description for the content view version"), :required => true
67
70
  def update
68
- history = @version.history.publish.successful.first
71
+ history = @content_view_version.history.publish.successful.first
69
72
  if history.blank?
70
73
  fail HttpErrors::BadRequest, _("This content view version doesn't have a history.")
71
74
  else
72
75
  history.notes = params[:description]
73
76
  history.save!
74
- respond_for_show(:resource => @version)
77
+ respond_for_show(:resource => @content_view_version)
75
78
  end
76
79
  end
77
80
 
78
81
  api :PUT, "/content_view_versions/:id/republish_repositories", N_("Forces a republish of the version's repositories' metadata")
79
82
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
80
83
  def republish_repositories
81
- task = async_task(::Actions::Katello::ContentViewVersion::RepublishRepositories, @version)
84
+ task = async_task(::Actions::Katello::ContentViewVersion::RepublishRepositories, @content_view_version)
82
85
  respond_for_async :resource => task
83
86
  end
84
87
 
85
- api :GET, "/content_view_versions/export_histories", N_("Show the export history for a content view version")
86
- param :content_view_version_id, :number, :desc => N_("Content view version identifier"), :required => false
87
- param :content_view_id, :number, :desc => N_("Content view identifier"), :required => false
88
- param :destination_server, String, :desc => N_("Destination Server name"), :required => false
89
- param :organization_id, :number, :desc => N_("Organization identifier"), :required => false
90
- param_group :search, Api::V2::ApiController
91
- add_scoped_search_description_for(ContentViewVersionExportHistory)
92
- def export_histories
93
- history = ContentViewVersionExportHistory.readable
94
- history = history.where(:content_view_version_id => params[:content_view_version_id]) unless params[:content_view_version_id].blank?
95
- history = history.where(:destination_server => params[:destination_server]) unless params[:destination_server].blank?
96
- history = history.with_organization_id(params[:organization_id]) unless params[:organization_id].blank?
97
- history = history.with_content_view_id(params[:content_view_id]) unless params[:content_view_id].blank?
98
- respond_for_index(:collection => scoped_search(history, 'id', 'asc', resource_class: ContentViewVersionExportHistory),
99
- :template => '../../../api/v2/content_view_version_export_histories/index')
100
- end
101
-
102
- api :POST, "/content_view_versions/:id/export", N_("Export a content view version")
88
+ api :POST, "/content_view_versions/:id/export", N_("Export a content view version. Relevant only for Pulp 2 repositories.")
103
89
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
104
- param :destination_server, String, :desc => N_("Destination Server name, required for Pulp3")
105
- param :export_to_iso, :bool, :desc => N_("Export to ISO format. Relevant only for Pulp 2 repositories"), :required => false
90
+ param :export_to_iso, :bool, :desc => N_("Export to ISO format."), :required => false
106
91
  param :iso_mb_size, :number, :desc => N_("maximum size of each ISO in MB. Relevant only for Pulp 2 repositories"), :required => false
107
92
  param :since, Date, :desc => N_("Optional date of last export (ex: 2010-01-01T12:00:00Z). Relevant only for Pulp 2 repositories"), :required => false
108
93
  def export
109
94
  if SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
110
- invalid_params = [:export_to_iso, :iso_mb_size, :since].reject { |param| params[param].blank? }
111
- unless invalid_params.empty?
112
- fail HttpErrors::BadRequest, _("Invalid parameters provided - %{params}. These are only relevant for Pulp 2 repositories" % { params: invalid_params.join(', ')})
113
- end
114
-
115
- if params[:destination_server].blank?
116
- fail HttpErrors::BadRequest, _("Destination Server Name required for Pulp3 repositories")
117
- end
118
-
119
- task = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::Export, @version, destination_server: params[:destination_server])
120
- else
121
- ::Foreman::Deprecation.api_deprecation_warning("Export is being deprecated and will be removed in a future version of Katello. Use hammer content-view version export instead.")
122
- if params[:export_to_iso].blank? && params[:iso_mb_size].present?
123
- fail HttpErrors::BadRequest, _("ISO export must be enabled when specifying ISO size")
124
- end
95
+ fail HttpErrors::BadRequest, _("Invalid usage for Pulp 3 repositories. "\
96
+ "Use hammer content-export for Yum repositories")
97
+ end
98
+ ::Foreman::Deprecation.api_deprecation_warning("Export is being deprecated and will be removed in a future version of Katello. Use hammer content-view version export instead.")
99
+ if params[:export_to_iso].blank? && params[:iso_mb_size].present?
100
+ fail HttpErrors::BadRequest, _("ISO export must be enabled when specifying ISO size")
101
+ end
125
102
 
126
- if (repos = @version.content_view.on_demand_repositories).any?
127
- fail HttpErrors::BadRequest, _("This content view has on demand repositories that cannot be exported: %{repos}" % {repos: repos.pluck(:label).join(", ")})
128
- end
103
+ if (repos = @content_view_version.content_view.on_demand_repositories).any?
104
+ fail HttpErrors::BadRequest, _("This content view has on demand repositories that cannot be exported: %{repos}" % {repos: repos.pluck(:label).join(", ")})
105
+ end
129
106
 
130
- if params[:since].present?
131
- begin
132
- params[:since].to_datetime
133
- rescue
134
- raise HttpErrors::BadRequest, _("Invalid date provided.")
135
- end
107
+ if params[:since].present?
108
+ begin
109
+ params[:since].to_datetime
110
+ rescue
111
+ raise HttpErrors::BadRequest, _("Invalid date provided.")
136
112
  end
137
- task = async_task(::Actions::Katello::ContentViewVersion::Export, @version,
138
- ::Foreman::Cast.to_bool(params[:export_to_iso]),
139
- params[:since].try(:to_datetime),
140
- params[:iso_mb_size])
141
113
  end
114
+ task = async_task(::Actions::Katello::ContentViewVersion::Export, @content_view_version,
115
+ ::Foreman::Cast.to_bool(params[:export_to_iso]),
116
+ params[:since].try(:to_datetime),
117
+ params[:iso_mb_size])
142
118
 
143
119
  respond_for_async :resource => task
144
120
  end
145
121
 
146
122
  api :POST, "/content_view_versions/import", N_("Import a content view version")
147
123
  param :content_view_id, :number, :desc => N_("Content view identifier"), :required => true
148
- param :path, String, :desc => N_("Import path"), :required => true
124
+ param :path, String, :desc => N_("Directory containing the exported Content View Version"), :required => true
125
+ param :metadata, Hash, :desc => N_("Metadata taken from the upstream export history for this Content View Version"), :required => true
149
126
  def import
150
- task = async_task(::Actions::Katello::ContentViewVersion::Import, @view, path: params[:path])
127
+ task = async_task(::Actions::Katello::ContentViewVersion::Import, @view, path: params[:path], metadata: metadata_params&.to_h)
151
128
  respond_for_async :resource => task
152
129
  end
153
130
 
154
131
  api :DELETE, "/content_view_versions/:id", N_("Remove content view version")
155
132
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
156
133
  def destroy
157
- task = async_task(::Actions::Katello::ContentViewVersion::Destroy, @version)
134
+ task = async_task(::Actions::Katello::ContentViewVersion::Destroy, @content_view_version)
158
135
  respond_for_async :resource => task
159
136
  end
160
137
 
@@ -194,7 +171,7 @@ module Katello
194
171
 
195
172
  validate_content(params[:add_content])
196
173
  resolve_dependencies = params.fetch(:resolve_dependencies, true)
197
- task = async_task(::Actions::Katello::ContentView::IncrementalUpdates, @version_environments, @composite_version_environments,
174
+ task = async_task(::Actions::Katello::ContentView::IncrementalUpdates, @content_view_version_environments, @composite_version_environments,
198
175
  params[:add_content], resolve_dependencies, hosts, params[:description])
199
176
  respond_for_async :resource => task
200
177
  end
@@ -220,17 +197,22 @@ module Katello
220
197
  find_bulk_hosts(:edit_hosts, params[:update_hosts], restrict_hosts)
221
198
  end
222
199
 
223
- def find_content_view_version
224
- @version = ContentViewVersion.find(params[:id])
225
- end
226
-
227
- def find_content_view
228
- @view = @version ? @version.content_view : ContentView.where(:id => params[:content_view_id]).first
200
+ def find_content_view_from_version
201
+ @view = @content_view_version.content_view
229
202
  if @view&.default? && params[:action] == "promote"
230
203
  fail HttpErrors::BadRequest, _("The default content view cannot be promoted")
231
204
  end
232
205
  end
233
206
 
207
+ def find_optional_readable_content_view
208
+ @view = ContentView.readable.find_by(:id => params[:content_view_id])
209
+ end
210
+
211
+ def find_publishable_content_view
212
+ @view = ContentView.publishable.find_by(:id => params[:content_view_id])
213
+ throw_resource_not_found(name: 'product', id: params[:product_id]) if @view.nil?
214
+ end
215
+
234
216
  def find_version_environments
235
217
  #Generates a data structure for incremental update:
236
218
  # [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
@@ -238,7 +220,7 @@ module Katello
238
220
  list = params[:content_view_version_environments]
239
221
  fail _("At least one Content View Version must be specified") if list.empty?
240
222
 
241
- @version_environments = []
223
+ @content_view_version_environments = []
242
224
  @composite_version_environments = []
243
225
  list.each do |combination|
244
226
  version_environment = {
@@ -262,7 +244,7 @@ module Katello
262
244
  if view.composite?
263
245
  @composite_version_environments << version_environment
264
246
  else
265
- @version_environments << version_environment
247
+ @content_view_version_environments << version_environment
266
248
  @composite_version_environments += lookup_all_composites(version_environment[:content_view_version]) if params[:propagate_all_composites]
267
249
  end
268
250
  end
@@ -281,7 +263,7 @@ module Katello
281
263
  def find_version_environments_for_hosts(include_composites)
282
264
  if include_composites
283
265
  version_environments_for_systems_map = {}
284
- @version_environments.each do |version_environment|
266
+ @content_view_version_environments.each do |version_environment|
285
267
  version_environment[:content_view_version].composites.each do |composite_version|
286
268
  version_environments_for_systems_map[composite_version.id] ||= {:content_view_version => composite_version,
287
269
  :environments => composite_version.environments}
@@ -290,7 +272,7 @@ module Katello
290
272
 
291
273
  version_environments_for_systems_map.values
292
274
  else
293
- @version_environments.select { |ve| !ve[:environments].blank? }
275
+ @content_view_version_environments.select { |ve| !ve[:environments].blank? }
294
276
  end
295
277
  end
296
278
 
@@ -333,13 +315,25 @@ module Katello
333
315
 
334
316
  def validate_promotable
335
317
  fail HttpErrors::BadRequest, _("Could not find environments for promotion") if @environments.blank?
336
- return deny_access unless @environments.all?(&:promotable_or_removable?) && @version.content_view.promotable_or_removable?
318
+ return deny_access unless @environments.all?(&:promotable_or_removable?) && @content_view_version.content_view.promotable_or_removable?
337
319
  true
338
320
  end
339
321
 
340
322
  def authorize_destroy
341
- return deny_access unless @version.content_view.deletable?
323
+ return deny_access unless @content_view_version.content_view.deletable?
342
324
  true
343
325
  end
326
+
327
+ def metadata_params
328
+ params.require(:metadata).permit(
329
+ :organization,
330
+ :content_view,
331
+ :repository_mapping,
332
+ :toc,
333
+ content_view_version: [:major, :minor]
334
+ ).tap do |nested|
335
+ nested[:repository_mapping] = params[:metadata].require(:repository_mapping).permit!
336
+ end
337
+ end
344
338
  end
345
339
  end
@@ -3,7 +3,8 @@ module Katello
3
3
  include Concerns::Authorization::Api::V2::ContentViewsController
4
4
  include Katello::Concerns::FilteredAutoCompleteSearch
5
5
 
6
- before_action :find_content_view, :except => [:index, :create, :auto_complete_search]
6
+ before_action :find_authorized_katello_resource, :except => [:index, :create, :copy, :auto_complete_search]
7
+ before_action :ensure_non_default, :except => [:index, :create, :copy, :auto_complete_search]
7
8
  before_action :find_organization, :only => [:create]
8
9
  before_action :find_optional_organization, :only => [:index, :auto_complete_search]
9
10
  before_action :find_environment, :only => [:index, :remove_from_environment]
@@ -20,6 +21,7 @@ module Katello
20
21
  param :component_ids, Array, :desc => N_("List of component content view version ids for composite views")
21
22
  param :auto_publish, :bool, :desc => N_("Enable/Disable auto publish of composite view")
22
23
  param :solve_dependencies, :bool, :desc => N_("Solve RPM dependencies by default on Content View publish, defaults to false")
24
+ param :import_only, :bool, :desc => N_("Designate this Content View for importing from upstream servers only. Defaults to false") if pulp3_yum?
23
25
  end
24
26
 
25
27
  def filtered_associations
@@ -29,6 +31,10 @@ module Katello
29
31
  }
30
32
  end
31
33
 
34
+ def self.pulp3_yum?
35
+ SmartProxy.pulp_primary&.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
36
+ end
37
+
32
38
  api :GET, "/organizations/:organization_id/content_views", N_("List content views")
33
39
  api :GET, "/content_views", N_("List content views")
34
40
  param :organization_id, :number, :desc => N_("organization identifier")
@@ -66,12 +72,16 @@ module Katello
66
72
  param :composite, :bool, :desc => N_("Composite content view")
67
73
  param_group :content_view
68
74
  def create
69
- @view = ContentView.create!(view_params) do |view|
75
+ if ::Foreman::Cast.to_bool(params[:content_view][:import_only])
76
+ fail HttpErrors::BadRequest, _("Import-only content views will be available in a future version.") unless self.class.pulp3_yum?
77
+ end
78
+
79
+ @content_view = ContentView.create!(view_params) do |view|
70
80
  view.organization = @organization
71
81
  view.label ||= labelize_params(params[:content_view])
72
82
  end
73
83
 
74
- respond :resource => @view
84
+ respond :resource => @content_view
75
85
  end
76
86
 
77
87
  api :PUT, "/content_views/:id", N_("Update a content view")
@@ -79,8 +89,8 @@ module Katello
79
89
  param :name, String, :desc => N_("New name for the content view")
80
90
  param_group :content_view
81
91
  def update
82
- sync_task(::Actions::Katello::ContentView::Update, @view, view_params)
83
- respond :resource => @view.reload
92
+ sync_task(::Actions::Katello::ContentView::Update, @content_view, view_params)
93
+ respond :resource => @content_view.reload
84
94
  end
85
95
 
86
96
  api :POST, "/content_views/:id/publish", N_("Publish a content view")
@@ -93,7 +103,7 @@ module Katello
93
103
  param :rpm_filenames, Array, of: String, :desc => N_("list of rpm filename strings to include in published version"), :required => true
94
104
  end
95
105
  def publish
96
- if params[:repos_units].present? && @view.composite?
106
+ if params[:repos_units].present? && @content_view.composite?
97
107
  fail HttpErrors::BadRequest, _("Directly setting package lists on composite content views is not allowed. Please " \
98
108
  "update the components, then re-publish the composite.")
99
109
  end
@@ -105,7 +115,7 @@ module Katello
105
115
  fail HttpErrors::BadRequest, _("Both major and minor parameters have to be used to override a CV version")
106
116
  end
107
117
 
108
- task = async_task(::Actions::Katello::ContentView::Publish, @view, params[:description],
118
+ task = async_task(::Actions::Katello::ContentView::Publish, @content_view, params[:description],
109
119
  :major => params[:major],
110
120
  :minor => params[:minor],
111
121
  :repos_units => params[:repos_units])
@@ -115,7 +125,7 @@ module Katello
115
125
  api :GET, "/content_views/:id", N_("Show a content view")
116
126
  param :id, :number, :desc => N_("content view numeric identifier"), :required => true
117
127
  def show
118
- respond :resource => @view
128
+ respond :resource => @content_view
119
129
  end
120
130
 
121
131
  api :GET, "/content_views/:id/available_puppet_modules",
@@ -123,9 +133,9 @@ module Katello
123
133
  param :id, :number, :desc => N_("content view numeric identifier"), :required => true
124
134
  param :name, String, :desc => N_("module name to restrict modules for"), :required => false
125
135
  def available_puppet_modules
126
- current_cv_puppet_modules = @view.content_view_puppet_modules.where("uuid is NOT NULL")
136
+ current_cv_puppet_modules = @content_view.content_view_puppet_modules.where("uuid is NOT NULL")
127
137
  current_uuids = current_cv_puppet_modules.pluck(:uuid)
128
- repositories = @view.organization.library.puppet_repositories
138
+ repositories = @content_view.organization.library.puppet_repositories
129
139
  query = PuppetModule.in_repositories(repositories)
130
140
  selected_latest_versions = []
131
141
  if params[:name]
@@ -154,9 +164,9 @@ module Katello
154
164
  N_("Get puppet modules names that are available to be added to the content view")
155
165
  param :id, :number, :desc => N_("content view numeric identifier"), :required => true
156
166
  def available_puppet_module_names
157
- current_names = @view.content_view_puppet_modules.where("name is NOT NULL").pluck(:name)
167
+ current_names = @content_view.content_view_puppet_modules.where("name is NOT NULL").pluck(:name)
158
168
 
159
- repos = @view.organization.library.puppet_repositories
169
+ repos = @content_view.organization.library.puppet_repositories
160
170
 
161
171
  modules = PuppetModule.in_repositories(repos)
162
172
  modules = modules.where('name NOT in (?)', current_names) if current_names.present?
@@ -169,12 +179,12 @@ module Katello
169
179
  param :id, :number, :desc => N_("content view numeric identifier"), :required => true
170
180
  param :environment_id, :number, :desc => N_("environment numeric identifier"), :required => true
171
181
  def remove_from_environment
172
- unless @view.environments.include?(@environment)
182
+ unless @content_view.environments.include?(@environment)
173
183
  fail HttpErrors::BadRequest, _("Content view '%{view}' is not in lifecycle environment '%{env}'.") %
174
- {view: @view.name, env: @environment.name}
184
+ {view: @content_view.name, env: @environment.name}
175
185
  end
176
186
 
177
- task = async_task(::Actions::Katello::ContentView::RemoveFromEnvironment, @view, @environment)
187
+ task = async_task(::Actions::Katello::ContentView::RemoveFromEnvironment, @content_view, @environment)
178
188
  respond_for_async :resource => task
179
189
  end
180
190
 
@@ -190,7 +200,7 @@ module Katello
190
200
  cv_envs = ContentViewEnvironment.where(:environment_id => params[:environment_ids],
191
201
  :content_view_id => params[:id]
192
202
  )
193
- versions = @view.versions.where(:id => params[:content_view_version_ids])
203
+ versions = @content_view.versions.where(:id => params[:content_view_version_ids])
194
204
 
195
205
  if cv_envs.empty? && versions.empty?
196
206
  fail _("There either were no environments nor versions specified or there were invalid environments/versions specified. "\
@@ -205,14 +215,14 @@ module Katello
205
215
  options[:content_view_versions] = versions
206
216
  options[:content_view_environments] = cv_envs
207
217
 
208
- task = async_task(::Actions::Katello::ContentView::Remove, @view, options)
218
+ task = async_task(::Actions::Katello::ContentView::Remove, @content_view, options)
209
219
  respond_for_async :resource => task
210
220
  end
211
221
 
212
222
  api :DELETE, "/content_views/:id", N_("Delete a content view")
213
223
  param :id, :number, :desc => N_("content view numeric identifier"), :required => true
214
224
  def destroy
215
- task = async_task(::Actions::Katello::ContentView::Destroy, @view)
225
+ task = async_task(::Actions::Katello::ContentView::Destroy, @content_view)
216
226
  respond_for_async :resource => task
217
227
  end
218
228
 
@@ -220,25 +230,26 @@ module Katello
220
230
  param :id, :number, :desc => N_("Content view numeric identifier"), :required => true
221
231
  param :name, String, :required => true, :desc => N_("New content view name")
222
232
  def copy
223
- new_content_view = @view.copy(params[:content_view][:name])
233
+ @content_view = Katello::ContentView.readable.find_by(:id => params[:id])
234
+ throw_resource_not_found(name: 'content_view', id: params[:id]) if @content_view.blank?
235
+ ensure_non_default
236
+ new_content_view = @content_view.copy(params[:content_view][:name])
224
237
  respond_for_create :resource => new_content_view
225
238
  end
226
239
 
227
240
  private
228
241
 
229
- def find_content_view
230
- @view = ContentView.find(params[:id])
231
-
232
- if @view.default? && !%w(show history).include?(params[:action])
242
+ def ensure_non_default
243
+ if @content_view.default? && !%w(show history).include?(params[:action])
233
244
  fail HttpErrors::BadRequest, _("The default content view cannot be edited, published, or deleted.")
234
245
  end
235
246
  end
236
247
 
237
248
  def view_params
238
- attrs = [:name, :description, :force_puppet_environment, :auto_publish, :solve_dependencies,
249
+ attrs = [:name, :description, :force_puppet_environment, :auto_publish, :solve_dependencies, :import_only,
239
250
  :default, :created_at, :updated_at, :next_version, {:component_ids => []}]
240
251
  attrs.push(:label, :composite) if action_name == "create"
241
- if (!@view || !@view.composite?)
252
+ if (!@content_view || !@content_view.composite?)
242
253
  attrs.push({:repository_ids => []}, :repository_ids)
243
254
  end
244
255
  params.require(:content_view).permit(*attrs).to_h
@@ -246,7 +257,7 @@ module Katello
246
257
 
247
258
  def find_environment
248
259
  return if !params.key?(:environment_id) && params[:action] == "index"
249
- @environment = KTEnvironment.find(params[:environment_id])
260
+ @environment = KTEnvironment.readable.find(params[:environment_id])
250
261
  end
251
262
 
252
263
  def add_use_latest_records(module_records, selected_latest_versions)