Moderate legislation proposals (#3602)
Moderate legislation proposals - added a controller for moderation/legislation - updated view to appropriate link + added route - added a spec - Feature test - test for faded - javascripts for visual effects
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
//= require moderator_proposals
|
//= require moderator_proposals
|
||||||
//= require moderator_budget_investments
|
//= require moderator_budget_investments
|
||||||
//= require moderator_proposal_notifications
|
//= require moderator_proposal_notifications
|
||||||
|
//= require moderator_legislation_proposals
|
||||||
//= require prevent_double_submission
|
//= require prevent_double_submission
|
||||||
//= require gettext
|
//= require gettext
|
||||||
//= require annotator
|
//= require annotator
|
||||||
|
|||||||
12
app/assets/javascripts/moderator_legislation_proposals.js
Normal file
12
app/assets/javascripts/moderator_legislation_proposals.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
(function() {
|
||||||
|
"use strict";
|
||||||
|
App.ModeratorLegislationProposals = {
|
||||||
|
add_class_faded: function(id) {
|
||||||
|
$("#" + id).addClass("faded");
|
||||||
|
$("#comments").addClass("faded");
|
||||||
|
},
|
||||||
|
hide_moderator_actions: function(id) {
|
||||||
|
$("#" + id + " .js-moderator-proposals-actions:first").hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}).call(this);
|
||||||
@@ -5,6 +5,8 @@ module Polymorphic
|
|||||||
def resource
|
def resource
|
||||||
if resource_model.to_s == "Budget::Investment"
|
if resource_model.to_s == "Budget::Investment"
|
||||||
@resource ||= instance_variable_get("@investment")
|
@resource ||= instance_variable_get("@investment")
|
||||||
|
elsif resource_model.to_s == "Legislation::Proposal"
|
||||||
|
@resource ||= instance_variable_get("@proposal")
|
||||||
else
|
else
|
||||||
@resource ||= instance_variable_get("@#{resource_name}")
|
@resource ||= instance_variable_get("@#{resource_name}")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
class Moderation::Legislation::ProposalsController < Moderation::BaseController
|
||||||
|
include ModerateActions
|
||||||
|
include FeatureFlags
|
||||||
|
|
||||||
|
has_filters %w[pending_flag_review all with_ignored_flag], only: :index
|
||||||
|
has_orders %w[flags created_at], only: :index
|
||||||
|
|
||||||
|
feature_flag :legislation
|
||||||
|
|
||||||
|
before_action :load_resources, only: [:index, :moderate]
|
||||||
|
|
||||||
|
load_and_authorize_resource class: "Legislation::Proposal"
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def resource_model
|
||||||
|
Legislation::Proposal
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<% if can? :hide, proposal %>
|
<% if can? :hide, proposal %>
|
||||||
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_proposal_path(proposal),
|
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_legislation_proposal_path(proposal),
|
||||||
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
|
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
<%= render "shared/geozone", geozonable: @proposal %>
|
<%= render "shared/geozone", geozonable: @proposal %>
|
||||||
|
|
||||||
<div class="js-moderator-proposal-actions margin">
|
<div class="js-moderator-proposal-actions margin">
|
||||||
<%= render "proposals/actions", proposal: @proposal %>
|
<%= render "legislation/proposals/actions", proposal: @proposal %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
3
app/views/moderation/legislation/proposals/hide.js.erb
Normal file
3
app/views/moderation/legislation/proposals/hide.js.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
var proposal_id = "<%= dom_id(@proposal) %>";
|
||||||
|
App.ModeratorLegislationProposals.add_class_faded(proposal_id);
|
||||||
|
App.ModeratorLegislationProposals.hide_moderator_actions(proposal_id);
|
||||||
@@ -18,6 +18,12 @@ namespace :moderation do
|
|||||||
put :moderate, on: :collection
|
put :moderate, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
namespace :legislation do
|
||||||
|
resources :proposals, only: :index do
|
||||||
|
put :hide, on: :member
|
||||||
|
put :moderate, on: :collection
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :comments, only: :index do
|
resources :comments, only: :index do
|
||||||
put :hide, on: :member
|
put :hide, on: :member
|
||||||
put :moderate, on: :collection
|
put :moderate, on: :collection
|
||||||
|
|||||||
27
spec/features/moderation/legislation_proposals_spec.rb
Normal file
27
spec/features/moderation/legislation_proposals_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe "Moderate legislation proposals" do
|
||||||
|
|
||||||
|
scenario "Hide", :js do
|
||||||
|
citizen = create(:user)
|
||||||
|
legislation_process = create(:legislation_process)
|
||||||
|
legislation_proposal = create(:legislation_proposal, legislation_process_id: legislation_process.id)
|
||||||
|
moderator = create(:moderator)
|
||||||
|
|
||||||
|
login_as(moderator.user)
|
||||||
|
visit legislation_process_proposal_path(legislation_process, legislation_proposal)
|
||||||
|
|
||||||
|
within("#legislation_proposal_#{legislation_proposal.id}") do
|
||||||
|
accept_confirm { click_link "Hide" }
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_css("#legislation_proposal_#{legislation_proposal.id}.faded")
|
||||||
|
|
||||||
|
logout
|
||||||
|
login_as(citizen)
|
||||||
|
visit legislation_process_proposals_path(legislation_process)
|
||||||
|
|
||||||
|
expect(page).to have_css(".proposal-content", count: 0)
|
||||||
|
expect(page).not_to have_link("Hide")
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user