Skip to content

Commit

Permalink
Merge pull request #9397 from alphagov/revert-history-mode-form-contr…
Browse files Browse the repository at this point in the history
…ols-edition

Revert History Mode Controls view component addition
  • Loading branch information
ryanb-gds committed Aug 30, 2024
2 parents 36a8837 + c4edb4c commit af7c34a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 132 deletions.
31 changes: 0 additions & 31 deletions app/components/admin/editions/history_mode_form_controls.erb

This file was deleted.

32 changes: 0 additions & 32 deletions app/components/admin/editions/history_mode_form_controls.rb

This file was deleted.

24 changes: 23 additions & 1 deletion app/views/admin/editions/_standard_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,29 @@
<%= render "additional_significant_fields", form: form, edition: form.object %>
<%= render Admin::Editions::HistoryModeFormControls.new(@edition, current_user) %>
<% if edition.document&.live? && edition.can_be_marked_political? && can?(:mark_political, edition) %>
<div class="govuk-!-margin-bottom-8">
<%= form.hidden_field :political, value: "0" %>
<%= render "govuk_publishing_components/components/checkboxes", {
name: "edition[political]",
id: "edition_political",
heading: "Political",
heading_size: "l",
no_hint_text: true,
error: errors_for_input(edition.errors, :political),
items: [
{
label: "Associate with government of the time (currently set to #{edition.government&.name}).",
value: "1",
checked: edition.political,
},
],
} %>

<p class="govuk-body"><%= link_to "Read the history mode guidance", "https://www.gov.uk/guidance/how-to-publish-on-gov-uk/creating-and-updating-pages#history-mode", class: "govuk-link" %> for more information as to what this means.</p>
</div>
<% end %>
</div>

<%= render Admin::Editions::FirstPublishedAtComponent.new(
Expand Down
1 change: 0 additions & 1 deletion config/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@
# description: "Take over the world."
feature :govspeak_visual_editor, description: "Enables a visual editor for Govspeak fields", default: false
feature :content_object_store, description: "Enables the object store for sharable content", default: Rails.env.development?
feature :override_government, description: "Enables GDS Editors and Admins to override the government associated with a document", default: false
end
4 changes: 1 addition & 3 deletions lib/whitehall/authority/rules/edition_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def self.actions
review_editorial_remark
review_fact_check
see
select_government_for_history_mode
unpublish
unwithdraw
update
Expand Down Expand Up @@ -172,7 +171,7 @@ def departmental_editor_can?(action)
can_publish?
when :force_publish
can_force_publish?
when :unpublish, :mark_political, :perform_administrative_tasks, :select_government_for_history_mode
when :unpublish, :mark_political, :perform_administrative_tasks
false
else
true
Expand Down Expand Up @@ -201,7 +200,6 @@ def departmental_writer_can?(action)
force_publish
reject
mark_political
select_government_for_history_mode
perform_administrative_tasks
]

Expand Down
62 changes: 0 additions & 62 deletions test/components/admin/editions/history_mode_form_controls_test.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,26 @@ class Admin::GenericEditionsController::PolticalDocumentsTest < ActionController
assert_equal previous_government, new_draft.reload.government
end

view_test "displays the history mode form controls for privileged users " do
view_test "displays the political checkbox for privileged users " do
create(:current_government)
login_as :managing_editor
published_edition = create(:published_news_article, first_published_at: 2.days.ago)
new_draft = create(:news_article, document: published_edition.document, first_published_at: 2.days.ago)
get :edit, params: { id: new_draft }
assert_select "#edition_political"
end

view_test "doesn't display the political checkbox for non-privileged users " do
published_edition = create(:published_news_article)
new_draft = create(:news_article, document: published_edition.document)
get :edit, params: { id: new_draft }
assert_select "#edition_political"
assert_select "#edition_political", count: 0
end

view_test "doesn't display the political checkbox on creation" do
login_as :managing_editor
get :new
assert_select "#edition_political", count: 0
end

def edit_historic_document
Expand Down

0 comments on commit af7c34a

Please sign in to comment.